diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-11-25 22:06:40 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-12-23 18:17:41 -0500 |
commit | f6d28b62f0e02b8a88a1832589e203c7a613f45b (patch) | |
tree | b5d6462e45bae998190194784e02b143a83f79a3 /src/doc_reform/io_out/latex.d | |
parent | gitignore & things nix (diff) |
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
Diffstat (limited to 'src/doc_reform/io_out/latex.d')
-rw-r--r-- | src/doc_reform/io_out/latex.d | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d index 992887d..f7dee74 100644 --- a/src/doc_reform/io_out/latex.d +++ b/src/doc_reform/io_out/latex.d @@ -325,10 +325,14 @@ template outputLaTeX() { 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; @@ -337,23 +341,23 @@ template outputLaTeX() { ) { 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; } @safe string sp_char_esc(O)( @@ -461,8 +465,8 @@ template outputLaTeX() { } 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") { @@ -529,7 +533,7 @@ template outputLaTeX() { 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; @@ -1381,7 +1385,6 @@ template outputLaTeX() { } template outputLaTeXstyInit() { import doc_reform.io_out; - mixin spineRgxOut; auto paper = paperLaTeX; void writeOutputLaTeXstyStatic( string latex_sty, |