From f6d28b62f0e02b8a88a1832589e203c7a613f45b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Nov 2022 22:06:40 -0500 Subject: regex review, match speed & compile time, ctregex - improve match time - add interim fontface identifier marker - improve compile time - remove unused regexs - separate out some specialized output matches --- org/out_latex.org | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'org/out_latex.org') diff --git a/org/out_latex.org b/org/out_latex.org index 7e235b6..1c1442b 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -134,7 +134,6 @@ template outputLaTeX() { #+BEGIN_SRC d template outputLaTeXstyInit() { import doc_reform.io_out; - mixin spineRgxOut; auto paper = paperLaTeX; <> <> @@ -627,10 +626,14 @@ import std.outbuffer, std.uri, std.conv : to; -import doc_reform.io_out; -mixin InternalMarkup; // watch +import + doc_reform.io_out, + doc_reform.io_out.rgx, + doc_reform.io_out.rgx_latex; mixin spineRgxOut; static auto rgx = RgxO(); +mixin spineRgxLSC; +static auto rgx_sc = RgxLSC(); mixin spineLanguageCodes; auto lang = Lang(); auto paper = paperLaTeX; @@ -921,23 +924,23 @@ struct PaperType { ) { string _unescape_sp_char_esc()(string _txt) { _txt = _txt - .replaceAll(rgx.latex_special_char_escaped, + .replaceAll(rgx_sc.latex_special_char_escaped, format(q"┃%s┃", "$1")) - .replaceAll(rgx.latex_special_char_escaped_braced, + .replaceAll(rgx_sc.latex_special_char_escaped_braced, format(q"┃%s┃", "$1")); return _txt; } string _unescape_fontface_esc()(string _txt) { - _txt = _txt.replaceAll(rgx.latex_identify_inline_fontface, + _txt = _txt.replaceAll(rgx_sc.latex_identify_inline_fontface, format(q"┃%s%s┃", "$1", "$2")); return _txt; } - _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx.latex_special_char_for_escape); - _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx.latex_special_char_for_escape_and_braces); + _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx_sc.latex_special_char_for_escape); + _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx_sc.latex_special_char_for_escape_and_braces); _txt = replaceAll!(m => "''")(_txt, rgx.quotes_open_and_close); _txt = replaceAll!(m => "$\\cdot$")(_txt, rgx.middle_dot); - _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx.latex_identify_inline_link); - _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface); + _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_link); + _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_fontface); return _txt; } #+END_SRC @@ -986,7 +989,7 @@ struct PaperType { @safe string sp_char_esc_()( string _txt, ) { - _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx.latex_special_char); + _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx_sc.latex_special_char); return _txt; } #+END_SRC @@ -1125,8 +1128,8 @@ _txt = _txt } string _check_link(string _link) { _link = _link - .replaceFirst(rgx.latex_clean_internal_link, "") - .replaceAll(rgx.latex_special_char_for_escape_url, "\\$1"); + .replaceFirst(rgx_sc.latex_clean_internal_link, "") + .replaceAll(rgx_sc.latex_special_char_for_escape_url, "\\$1"); return _link; } if (obj.metainfo.is_a != "code") { @@ -1219,7 +1222,7 @@ _txt = _txt string _tex_para; _tex_para = q"┃%s┃"; _txt = format(_tex_para, - _txt.replaceAll(rgx.latex_clean_bookindex_linebreak, "\n") ~ "\n\\brln\n" + _txt.replaceAll(rgx_sc.latex_clean_bookindex_linebreak, "\n") ~ "\n\\brln\n" ); } return _txt; -- cgit v1.2.3