Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom pygments lexers: regex #25

Closed
1 of 3 tasks
jemand771 opened this issue Aug 12, 2021 · 1 comment
Closed
1 of 3 tasks

custom pygments lexers: regex #25

jemand771 opened this issue Aug 12, 2021 · 1 comment
Labels
enhancement New feature or request feature something the container does good first issue Good for newcomers help wanted Extra attention is needed

Comments

@jemand771
Copy link
Owner

jemand771 commented Aug 12, 2021

the container should support custom lexers for pygments. they can be installed by copying the lexer files to /usr/lib/python3.x/site-packages/pygments/lexers and running python _mapping.py in that folder.

colin suggested a regex lexer from here:

from pygments.lexer import RegexLexer, bygroups
from pygments.token import *

__all__ = ['regexLexer']

class regexLexer(RegexLexer):
    name = 'regex'
    aliases = ['regex']
    filenames = []

    tokens = {
        'root': [
            (r'\w+', Name),
            (r'\d+', Number),
            (r'[\s\,\:\-\"\']+', Text),
            (r'[\$\^]', Token),
            (r'[\+\*\.\?]', Operator),
            (r'(\()([\?\<\>\!\=\:]{2,3}.+?)(\))', bygroups(Keyword.Namespace, Name.Function, Keyword.Namespace)),
            (r'(\()(\?\#.+?)(\))', bygroups(Comment, Comment, Comment)),
            (r'[\(\)]', Keyword.Namespace),
            (r'[\[\]]', Name.Class),
            (r'\\\w', Keyword),
            (r'[\{\}]', Operator),
        ],
    }

todo:

  • test the lexer without the container (no point in adding it if it doesn't work as expected) -> colin
  • create a new directory for lexers and load them into their target folders
  • figure out how to determine python version (maybe pin to specific minor version)
@jemand771 jemand771 added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers feature something the container does labels Aug 12, 2021
@jemand771
Copy link
Owner Author

closed in #28
released in #29 (v1.6.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature something the container does good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant