Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions data/filters/wg21.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import re

embedded_md = re.compile('@@(.*?)@@|@(.*?)@')
expos_name = re.compile(r'\$([\w\-\s]*?)\$')
stable_names = {}
refs = {}

Expand Down Expand Up @@ -205,10 +206,27 @@ def repl(match_obj):
if group is not None:
return repl2(group)

def repl_expos(match_obj):
match = match_obj[1]
if not match or match.isspace(): # $ $
return match
if doc.format == 'latex':
pf.debug('Exposition-only names in latex is totally untested')
result = "\\textitalic{{{}}}".format(match)
elif doc.format == 'html':
result = '<em>{}</em>'.format(match)
else:
raise ValueError('Unsupported doc format for expos-name')
return result

if isinstance(elem, pf.Code):
result = pf.RawInline(embedded_md.sub(repl, text), doc.format)
text = embedded_md.sub(repl, text)
text = expos_name.sub(repl_expos, text)
result = pf.RawInline(text, doc.format)
elif isinstance(elem, pf.CodeBlock):
result = pf.RawBlock(embedded_md.sub(repl, text), doc.format)
text = embedded_md.sub(repl, text)
text = expos_name.sub(repl_expos, text)
result = pf.RawBlock(text, doc.format)

if 'diff' not in elem.classes:
return result
Expand Down
2 changes: 2 additions & 0 deletions data/syntax/isocpp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
<!-- Match embedded Markdown -->
<RegExpr attribute="Ignore" context="#stay" String="@@.*?@@" />
<RegExpr attribute="Ignore" context="#stay" String="@.*?@" />
<!-- Match exposition-only names -->
<RegExpr attribute="Ignore" context="#stay" String="\$[\w\-\s]*?\$" />
<!-- Match keywords -->
<IncludeRules context="match keywords" />
<!-- Match string literals -->
Expand Down