Skip to content

Commit 2cc9a4d

Browse files
authored
Fix: regex fails to capture certain langs (#30)
Languages with non alphanumeric characters (i.e. c++) would not be captured by the regex for syntax highlighting.
1 parent a3ac623 commit 2cc9a4d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

wikitexthtml/render/preprocess.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
ONLYINCLUDE_PATTERN = regex.compile(r"<onlyinclude>([\s\S]*?)(?></onlyinclude>|\Z)")
1919
PRE_PATTERN = regex.compile(r"<pre>([\s\S]*?)(?></pre>|\Z)")
2020
SYNTAXHIGHLIGHT_PATTERN = regex.compile(
21-
r"<syntaxhighlight( lang=\")?(?P<lang>[a-zA-z]+)?\"?"
22-
r"(?P<line> line(?P<lineStart> \d*)?)?>(?P<code>[\s\S]*?)(?></syntaxhighlight>|\Z)"
21+
r"<syntaxhighlight( lang=\"(?P<lang>[^\"]+)\")?"
22+
r"(?P<line> line( start=\"(?P<lineStart>\d+)\")?)?>"
23+
r"(?P<code>[\s\S]*?)(</syntaxhighlight>|\Z)"
2324
)
2425

2526

0 commit comments

Comments
 (0)