Skip to content

Commit 1696a9b

Browse files
Fix Pygments lexers for minted escaping
1 parent 0422f5c commit 1696a9b

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

syntax_highlighting/en/pygments/catala_en_lexer/lexer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class CustomLexer(RegexLexer):
1515
'root' : [
1616
(u'(^\\s*[\\#]+.*)', bygroups(Generic.Heading)),
1717
(u'(^\\s*[\\#]+\\s*\\[[^\\]\\n\\r]\\s*].*)', bygroups(Generic.Heading)),
18-
(u'([^`\\n\\r])', bygroups(String)),
19-
(u'(^```catala$)', bygroups(String), 'code'),
20-
(u'(^```catala-metadata$)', bygroups(String), 'code'),
21-
(u'(^```catala-test-inline$)', bygroups(String), 'test'),
22-
('(\n|\r|\r\n)', String),
23-
('.', String),
18+
(u'([^`\\n\\r])', bygroups(Text)),
19+
(u'(^```catala$)', bygroups(Text), 'code'),
20+
(u'(^```catala-metadata$)', bygroups(Text), 'code'),
21+
(u'(^```catala-test-inline$)', bygroups(Text), 'test'),
22+
('(\n|\r|\r\n)', Whitespace),
23+
('.', Text),
2424
],
2525
'code' : [
26-
(u'(^```$)', bygroups(String), 'root'),
26+
(u'(^```$)', bygroups(Text), 'root'),
2727
(u'(\\s*\\#.*$)', bygroups(Comment.Single)),
28-
(u'(context|input|output|internal)(\\s*)(|output)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, String, Keyword.Declaration, String, Name.Variable)),
28+
(u'(context|input|output|internal)(\\s*)(|output)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Variable)),
2929
(u'\\b(match|with\\s+pattern|but\\s+replace|fixed|by|decreasing|increasing|varies|with|we\\s+have|let|in|scope|depends\\s+on|declaration|includes|content|rule|under\\s+condition|condition|data|consequence|fulfilled|equals|assertion|definition|state|label|exception)\\b', bygroups(Keyword.Reserved)),
3030
(u'\\b(contains|number|sum|such\\s+that|exists|for|all|of|if|then|else|is|list\\s+empty|among|maximum|minimum|round|combine|initially)\\b', bygroups(Keyword.Declaration)),
3131
(u'(\\|[0-9]+\\-[0-9]+\\-[0-9]+\\|)', bygroups(Number.Integer)),
@@ -35,16 +35,16 @@ class CustomLexer(RegexLexer):
3535
(u'(\\-\\>|\\+\\.|\\+\\@|\\+\\^|\\+\\$|\\+|\\-\\.|\\-\\@|\\-\\^|\\-\\$|\\-|\\*\\.|\\*\\@|\\*\\^|\\*\\$|\\*|/\\.|/\\@|/\\$|/|\\!|>\\.|>=\\.|<=\\.|<\\.|>\\@|>=\\@|<=\\@|<\\@|>\\$|>=\\$|<=\\$|<\\$|>\\^|>=\\^|<=\\^|<\\^|>|>=|<=|<|=|not|or|xor|and|\\$|\u20ac|%|year|month|day)', bygroups(Operator)),
3636
(u'\\b(structure|enumeration|list\\s+of|integer|boolean|date|duration|money|text|decimal)\\b', bygroups(Keyword.Type)),
3737
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Class, Operator, Name.Variable)),
38-
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\'\\.]*)\\b', bygroups(Name.Variable, Operator, String)),
38+
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\'\\.]*)\\b', bygroups(Name.Variable, Operator, Text)),
3939
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Variable)),
4040
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Class)),
41-
('(\n|\r|\r\n)', String),
42-
('.', String),
41+
('(\n|\r|\r\n)', Whitespace),
42+
('.', Text),
4343
],
4444
'test' : [
45-
(u'(^```$)', bygroups(String), 'root'),
45+
(u'(^```$)', bygroups(Text), 'root'),
4646
(u'(^[$] catala \\S*)', bygroups(Keyword.Constant)),
47-
('(\n|\r|\r\n)', String),
48-
('.', String),
47+
('(\n|\r|\r\n)', Whitespace),
48+
('.', Text),
4949
]
5050
}

syntax_highlighting/fr/pygments/catala_fr_lexer/lexer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class CustomLexer(RegexLexer):
1515
'root' : [
1616
(u'(^\\s*[\\#]+.*)', bygroups(Generic.Heading)),
1717
(u'(^\\s*[\\#]+\\s*\\[[^\\]\\n\\r]\\s*].*)', bygroups(Generic.Heading)),
18-
(u'([^`\\n\\r])', bygroups(String)),
19-
(u'(^```catala$)', bygroups(String), 'code'),
20-
(u'(^```catala-metadata$)', bygroups(String), 'code'),
21-
(u'(^```catala-test-inline$)', bygroups(String), 'test'),
22-
('(\n|\r|\r\n)', String),
23-
('.', String),
18+
(u'([^`\\n\\r])', bygroups(Text)),
19+
(u'(^```catala$)', bygroups(Text), 'code'),
20+
(u'(^```catala-metadata$)', bygroups(Text), 'code'),
21+
(u'(^```catala-test-inline$)', bygroups(Text), 'test'),
22+
('(\n|\r|\r\n)', Whitespace),
23+
('.', Text),
2424
],
2525
'code' : [
26-
(u'(^```$)', bygroups(String), 'root'),
26+
(u'(^```$)', bygroups(Text), 'root'),
2727
(u'(\\s*\\#.*$)', bygroups(Comment.Single)),
28-
(u'(contexte|entr\xe9e|r\xe9sultat|interne)(\\s*)(|r\xe9sultat)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, String, Keyword.Declaration, String, Name.Variable)),
28+
(u'(contexte|entr\xe9e|r\xe9sultat|interne)(\\s*)(|r\xe9sultat)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Variable)),
2929
(u'\\b(selon|sous\\s+forme|mais\\s+en\\s+rempla\xe7ant|fix\xe9|par|d\xe9croissant|croissant|varie|avec|on\\s+a|soit|dans|champ\\s+d\'application|d\xe9pend\\s+de|d\xe9claration|inclusion|contenu|r\xe8gle|sous\\s+condition|condition|donn\xe9e|cons\xe9quence|rempli|\xe9gal\\s+\xe0|assertion|d\xe9finition|\xe9tat|\xe9tiquette|exception)\\b', bygroups(Keyword.Reserved)),
3030
(u'\\b(contient|nombre|somme|tel\\s+que|existe|pour|tout|de|si|alors|sinon|est|liste\\s+vide|parmi|maximum|minimum|arrondi|combinaison\\s+de|initialement)\\b', bygroups(Keyword.Declaration)),
3131
(u'(\\|[0-9]+\\-[0-9]+\\-[0-9]+\\|)', bygroups(Number.Integer)),
@@ -36,16 +36,16 @@ class CustomLexer(RegexLexer):
3636
(u'\\b(non|ou\\s+bien|ou|et|an|mois|jour)\\b', bygroups(Operator)),
3737
(u'\\b(structure|\xe9num\xe9ration|liste\\s+de|entier|bool\xe9en|date|dur\xe9e|argent|texte|d\xe9cimal|d\xe9cret|loi|nombre|somme)\\b', bygroups(Keyword.Type)),
3838
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Class, Operator, Name.Variable)),
39-
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\'\\.]*)\\b', bygroups(Name.Variable, Operator, String)),
39+
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)(\\.)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\'\\.]*)\\b', bygroups(Name.Variable, Operator, Text)),
4040
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Variable)),
4141
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Class)),
42-
('(\n|\r|\r\n)', String),
43-
('.', String),
42+
('(\n|\r|\r\n)', Whitespace),
43+
('.', Text),
4444
],
4545
'test' : [
46-
(u'(^```$)', bygroups(String), 'root'),
46+
(u'(^```$)', bygroups(Text), 'root'),
4747
(u'(^[$] catala \\S*)', bygroups(Keyword.Constant)),
48-
('(\n|\r|\r\n)', String),
49-
('.', String),
48+
('(\n|\r|\r\n)', Whitespace),
49+
('.', Text),
5050
]
5151
}

tests/literate/good/test_grave_char_en.catala_en

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ let () = print_endline "Hello world!"
8080
\end{verbatim}
8181

8282
\begin{Verbatim}[commandchars=\\\{\},numbers=left,firstnumber=19,stepnumber=1,label={\hspace*{\fill}\texttt{test\_grave\_char\_en.catala\_en}}]
83-
\PY{l+s}{```catala}
84-
\PY{k+kr}{declaration}\PY{l+s}{ }\PY{k+kr}{scope}\PY{l+s}{ }\PY{n+nc}{A}\PY{o}{:}
85-
\PY{l+s}{ }\PY{l+s}{ }\PY{k+kd}{context}\PY{l+s}{ }\PY{k+kd}{output}\PY{l+s}{ }\PY{n+nv}{literate\PYZus{}parsing\PYZus{}is\PYZus{}ok}\PY{l+s}{ }\PY{k+kr}{content}\PY{l+s}{ }\PY{k+kt}{boolean}
83+
\```catala
84+
\PY{k+kr}{declaration} \PY{k+kr}{scope} \PY{n+nc}{A}\PY{o}{:}
85+
\PY{k+kd}{context}\PY{+w}{ }\PY{k+kd}{output}\PY{+w}{ }\PY{n+nv}{literate\PYZus{}parsing\PYZus{}is\PYZus{}ok} \PY{k+kr}{content} \PY{k+kt}{boolean}
8686

87-
\PY{k+kr}{scope}\PY{l+s}{ }\PY{n+nc}{A}\PY{o}{:}
88-
\PY{l+s}{ }\PY{l+s}{ }\PY{k+kr}{definition}\PY{l+s}{ }\PY{n+nv}{literate\PYZus{}parsing\PYZus{}is\PYZus{}ok}\PY{l+s}{ }\PY{k+kr}{equals}\PY{l+s}{ }\PY{k+kc}{true}
89-
\PY{l+s}{```}
87+
\PY{k+kr}{scope} \PY{n+nc}{A}\PY{o}{:}
88+
\PY{k+kr}{definition} \PY{n+nv}{literate\PYZus{}parsing\PYZus{}is\PYZus{}ok} \PY{k+kr}{equals} \PY{k+kc}{true}
89+
\```
9090
\end{Verbatim}
9191

9292

0 commit comments

Comments
 (0)