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_xmls.org | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'org/out_xmls.org') diff --git a/org/out_xmls.org b/org/out_xmls.org index 78176a0..1ec53af 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -35,8 +35,10 @@ module doc_reform.io_out.xmls; template outputXHTMLs() { <> mixin spineRgxOut; + mixin spineRgxXHTML; struct outputXHTMLs { static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); <> <> <> @@ -95,6 +97,9 @@ import std.conv : to; import doc_reform.io_out, + doc_reform.io_out.rgx, + doc_reform.meta.rgx_files, + doc_reform.io_out.rgx_xhtml, doc_reform.io_out.create_zip_file, doc_reform.io_out.xmls, doc_reform.io_out.xmls_css; @@ -112,6 +117,8 @@ import std.conv : to; import doc_reform.io_out, + doc_reform.io_out.rgx, + doc_reform.io_out.rgx_xhtml, doc_reform.io_out.create_zip_file, doc_reform.io_out.xmls, doc_reform.io_out.xmls_css; @@ -160,10 +167,10 @@ import #+BEGIN_SRC d @safe string special_characters_text(string _txt) { _txt = _txt - .replaceAll(rgx.xhtml_ampersand, "&") // "&" - .replaceAll(rgx.xhtml_quotation, """) // """ - .replaceAll(rgx.xhtml_less_than, "<") // "<" - .replaceAll(rgx.xhtml_greater_than, ">") // ">" + .replaceAll(rgx_xhtml.ampersand, "&") // "&" + .replaceAll(rgx_xhtml.quotation, """) // """ + .replaceAll(rgx_xhtml.less_than, "<") // "<" + .replaceAll(rgx_xhtml.greater_than, ">") // ">" .replaceAll(rgx.br_line, "
") .replaceAll(rgx.br_line_inline, "
") .replaceAll(rgx.br_line_spaced, "
\n
") @@ -238,7 +245,7 @@ import } if (!(obj.metainfo.is_a == "code")) { _txt = (_txt) - .replaceAll(rgx.xhtml_line_break, "
"); + .replaceAll(rgx_xhtml.line_break, "
"); } return _txt; } @@ -1756,8 +1763,10 @@ template outputHTML() { M doc_matters, ) { mixin spineRgxOut; + mixin spineRgxXHTML; auto xhtml_format = outputXHTMLs(); static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); string[] doc_html; string[] doc; string suffix = ".html"; @@ -1990,7 +1999,9 @@ default: M doc_matters, ) { mixin spineRgxOut; + mixin spineRgxXHTML; static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); auto xhtml_format = outputXHTMLs(); string[][string] doc_html; string[][string] doc_html_endnotes; @@ -2289,11 +2300,11 @@ default: debug(asserts) { static assert(is(typeof(doc_html) == string[][string])); } - mixin spineRgxOut; - static auto rgx = RgxO(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); auto xhtml_format = outputXHTMLs(); - auto m = doc_matters.src.filename.matchFirst(rgx.src_fn); + auto m = doc_matters.src.filename.matchFirst(rgx_files.src_fn); try { if (!exists(pth_html.seg(doc_matters.src.filename))) { pth_html.seg(doc_matters.src.filename).mkdirRecurse; @@ -2398,6 +2409,7 @@ template outputEPub3() { mixin InternalMarkup; mixin outputXHTMLs; static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); <> <> <> @@ -2572,6 +2584,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); string toc; bool _new_title_set = false; string toc_head = format(q"┃ I doc_matters, ) { mixin spineRgxOut; + mixin spineRgxXHTML; auto xhtml_format = outputXHTMLs(); static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); string[] doc; string segment_filename; string[] top_level_headings = ["","","",""]; @@ -3065,6 +3080,7 @@ zip -0 file.epub mimetype && zip -r -9 file.epub META-INF OEBPS static assert(is(typeof(epub_write.oebps_content_opf) == string)); } static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); auto xhtml_format = outputXHTMLs(); /+ zip file +/ -- cgit v1.2.3