diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/python/Pygments/py2/pygments/lexers/diff.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/lexers/diff.py')
-rw-r--r-- | contrib/python/Pygments/py2/pygments/lexers/diff.py | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/contrib/python/Pygments/py2/pygments/lexers/diff.py b/contrib/python/Pygments/py2/pygments/lexers/diff.py index 5ff8375c67..234b9b4342 100644 --- a/contrib/python/Pygments/py2/pygments/lexers/diff.py +++ b/contrib/python/Pygments/py2/pygments/lexers/diff.py @@ -5,17 +5,17 @@ Lexers for diff/patch formats. - :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ -import re - +import re + from pygments.lexer import RegexLexer, include, bygroups from pygments.token import Text, Comment, Operator, Keyword, Name, Generic, \ Literal -__all__ = ['DiffLexer', 'DarcsPatchLexer', 'WDiffLexer'] +__all__ = ['DiffLexer', 'DarcsPatchLexer', 'WDiffLexer'] class DiffLexer(RegexLexer): @@ -106,60 +106,60 @@ class DarcsPatchLexer(RegexLexer): (r'[^\n\[]+', Generic.Deleted), ], } - - -class WDiffLexer(RegexLexer): - """ - A `wdiff <https://www.gnu.org/software/wdiff/>`_ lexer. - - Note that: - - * only to normal output (without option like -l). - * if target files of wdiff contain "[-", "-]", "{+", "+}", - especially they are unbalanced, this lexer will get confusing. - - .. versionadded:: 2.2 - """ - - name = 'WDiff' - aliases = ['wdiff'] - filenames = ['*.wdiff'] - mimetypes = [] - - flags = re.MULTILINE | re.DOTALL - - # We can only assume "[-" after "[-" before "-]" is `nested`, - # for instance wdiff to wdiff outputs. We have no way to - # distinct these marker is of wdiff output from original text. - - ins_op = r"\{\+" - ins_cl = r"\+\}" - del_op = r"\[\-" - del_cl = r"\-\]" - normal = r'[^{}[\]+-]+' # for performance - tokens = { - 'root': [ - (ins_op, Generic.Inserted, 'inserted'), - (del_op, Generic.Deleted, 'deleted'), - (normal, Text), - (r'.', Text), - ], - 'inserted': [ - (ins_op, Generic.Inserted, '#push'), - (del_op, Generic.Inserted, '#push'), - (del_cl, Generic.Inserted, '#pop'), - - (ins_cl, Generic.Inserted, '#pop'), - (normal, Generic.Inserted), - (r'.', Generic.Inserted), - ], - 'deleted': [ - (del_op, Generic.Deleted, '#push'), - (ins_op, Generic.Deleted, '#push'), - (ins_cl, Generic.Deleted, '#pop'), - - (del_cl, Generic.Deleted, '#pop'), - (normal, Generic.Deleted), - (r'.', Generic.Deleted), - ], - } + + +class WDiffLexer(RegexLexer): + """ + A `wdiff <https://www.gnu.org/software/wdiff/>`_ lexer. + + Note that: + + * only to normal output (without option like -l). + * if target files of wdiff contain "[-", "-]", "{+", "+}", + especially they are unbalanced, this lexer will get confusing. + + .. versionadded:: 2.2 + """ + + name = 'WDiff' + aliases = ['wdiff'] + filenames = ['*.wdiff'] + mimetypes = [] + + flags = re.MULTILINE | re.DOTALL + + # We can only assume "[-" after "[-" before "-]" is `nested`, + # for instance wdiff to wdiff outputs. We have no way to + # distinct these marker is of wdiff output from original text. + + ins_op = r"\{\+" + ins_cl = r"\+\}" + del_op = r"\[\-" + del_cl = r"\-\]" + normal = r'[^{}[\]+-]+' # for performance + tokens = { + 'root': [ + (ins_op, Generic.Inserted, 'inserted'), + (del_op, Generic.Deleted, 'deleted'), + (normal, Text), + (r'.', Text), + ], + 'inserted': [ + (ins_op, Generic.Inserted, '#push'), + (del_op, Generic.Inserted, '#push'), + (del_cl, Generic.Inserted, '#pop'), + + (ins_cl, Generic.Inserted, '#pop'), + (normal, Generic.Inserted), + (r'.', Generic.Inserted), + ], + 'deleted': [ + (del_op, Generic.Deleted, '#push'), + (ins_op, Generic.Deleted, '#push'), + (ins_cl, Generic.Deleted, '#pop'), + + (del_cl, Generic.Deleted, '#pop'), + (normal, Generic.Deleted), + (r'.', Generic.Deleted), + ], + } |