From d4f57de1f51bb6330a1e7c267961783b317d0d6c Mon Sep 17 00:00:00 2001 From: timsong-cpp Date: Sun, 30 May 2021 11:00:57 -0500 Subject: [PATCH 1/2] Support $exposition-only-name$ --- data/filters/wg21.py | 22 ++++++++++++++++++++-- data/syntax/isocpp.xml | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/data/filters/wg21.py b/data/filters/wg21.py index c10c6b5..554fcb6 100755 --- a/data/filters/wg21.py +++ b/data/filters/wg21.py @@ -14,6 +14,7 @@ import re embedded_md = re.compile('@@(.*?)@@|@(.*?)@') +expos_name = re.compile('\$([\w\-\s]*?)\$') stable_names = {} refs = {} @@ -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 = '{}'.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 diff --git a/data/syntax/isocpp.xml b/data/syntax/isocpp.xml index 3fac946..0998f9b 100644 --- a/data/syntax/isocpp.xml +++ b/data/syntax/isocpp.xml @@ -300,6 +300,8 @@ + + From 41441a20b421fe195ea32d0faf0598525d31b15a Mon Sep 17 00:00:00 2001 From: Barry Revzin Date: Wed, 1 Jan 2025 11:00:42 -0600 Subject: [PATCH 2/2] Silencing warning --- data/filters/wg21.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/filters/wg21.py b/data/filters/wg21.py index 554fcb6..a842d3f 100755 --- a/data/filters/wg21.py +++ b/data/filters/wg21.py @@ -14,7 +14,7 @@ import re embedded_md = re.compile('@@(.*?)@@|@(.*?)@') -expos_name = re.compile('\$([\w\-\s]*?)\$') +expos_name = re.compile(r'\$([\w\-\s]*?)\$') stable_names = {} refs = {}