mirror of
https://gitea.tendokyu.moe/eamuse/docs.git
synced 2024-11-12 01:10:48 +01:00
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
# from pygments.lexer import RegexLexer
|
|
# from pygments.token import Text, Comment, Operator, Name, String
|
|
# from pygments.lexers import _lexer_cache
|
|
# from pygments.lexers._mapping import LEXERS
|
|
|
|
# def italic_attr(lexer, m):
|
|
# yield m.start(), String, '"'
|
|
# yield m.start() + 2, Comment, m.group()[3:-1]
|
|
# yield m.end() - 1, String, '"'
|
|
|
|
|
|
# def italic_generic(lexer, m):
|
|
# yield m.start(), Comment, m.group()
|
|
|
|
|
|
# def italic_tag(lexer, m):
|
|
# yield m.start(), Name.Tag, "<"
|
|
# name = m.group()[3:]
|
|
# if name.endswith(">"):
|
|
# yield m.start() + 1, Comment, name[:-1]
|
|
# yield m.end() - 1, Name.Tag, ">"
|
|
# else:
|
|
# yield m.start() + 1, Comment, name
|
|
|
|
|
|
# def italic_tag_close(lexer, m):
|
|
# yield m.start(), Name.Tag, "</"
|
|
# yield m.start() + 4, Comment, m.group()[4:-1]
|
|
# yield m.end() - 1, Name.Tag, ">"
|
|
|
|
|
|
# def repeat_tag_close(lexer, m):
|
|
# before, _, after = m.group().partition("[]")
|
|
# yield m.start(), Name.Tag, before
|
|
# yield m.start() + len(before), Operator, "[]"
|
|
# yield m.start() + len(before) + 2, Name.Tag, after
|
|
|
|
|
|
# def italic_attr_name(lexer, m):
|
|
# name, _, after = m.group().partition("*")
|
|
# yield m.start(), Name.Attribute, name
|
|
# yield m.start() + len(name), Operator, "*"
|
|
# yield m.start() + len(name) + 1, Name.Attribute, after
|
|
|
|
from pygments.lexer import RegexLexer, bygroups
|
|
from pygments.token import Comment, Name, String, Whitespace
|
|
from pygments.lexers import _lexer_cache
|
|
from pygments.lexers._mapping import LEXERS
|
|
|
|
|
|
class CustomIniLexer(RegexLexer):
|
|
name = 'amINI'
|
|
aliases = ['amini']
|
|
|
|
tokens = {
|
|
'root': [
|
|
(r'\s+', Whitespace),
|
|
(r'[;#].*', Comment.Single),
|
|
(r'([a-zA-Z0-9]+?)([ \t]+)([a-zA-Z0-9]+)', bygroups(Name.Attribute, Whitespace, String)),
|
|
]
|
|
}
|
|
|
|
|
|
_lexer_cache[CustomIniLexer.__name__] = CustomIniLexer
|
|
|
|
LEXERS["CustomIniLexer"] = ("ini_lexer", "CustomIniLexer", ("amini", ), (), ())
|
|
|
|
__all__ = ("CustomIniLexer", )
|