From 3f393a3c2955c5af64cab3f22b776b96aebebd66 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Jan 2019 12:34:03 -0500 Subject: rearrange some code --- src/doc_reform/output/xmls.d | 291 ++++++++++++++++++++----------------------- 1 file changed, 138 insertions(+), 153 deletions(-) (limited to 'src/doc_reform/output/xmls.d') diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index fe02338..97262a1 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -318,10 +318,10 @@ template outputXHTMLs() { ¶"); return o; } - auto inline_images(M,O)( - M doc_matters, - const O obj, + auto inline_images(O,M)( string _txt, + const O obj, + M doc_matters, string _suffix = ".html", string _xml_type = "seg", ) { @@ -342,18 +342,18 @@ template outputXHTMLs() { } return _txt; } - auto inline_links(M,O)( - M doc_matters, - const O obj, - string _txt, + auto inline_links(O,M)( + string _txt, + const O obj, + M doc_matters, string _suffix = ".html", string _xml_type = "seg", ) { string seg_lvs; if (obj.has.inline_links) { if (obj.metainfo.is_a != "code") { - _txt = replaceAll!(hit => - hit[1] ~ "┤" ~ to!string((obj.stow.link[hit[2].to!ulong])).encode ~ "├" + _txt = replaceAll!(m => + m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├" )(_txt, rgx.inline_link_number_only); } if ((_txt.match(rgx.mark_internal_site_lnk)) @@ -429,10 +429,10 @@ template outputXHTMLs() { } return _txt; } - auto inline_notes_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, + auto inline_notes_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, ) { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); @@ -453,10 +453,10 @@ template outputXHTMLs() { } return _txt; } - auto inline_notes_seg(M,O)( - M doc_matters, - const O obj, - string _txt, + auto inline_notes_seg(O,M)( + string _txt, + const O obj, + M doc_matters, ) { string[] _endnotes; if (obj.has.inline_notes_reg) { @@ -493,32 +493,32 @@ template outputXHTMLs() { ); return t; } - auto inline_markup_scroll(M,O)( - M doc_matters, - const O obj, + auto inline_markup_scroll(O,M)( string _txt, + const O obj, + M doc_matters, string _suffix = ".html", ) { - _txt = inline_images(doc_matters, obj, _txt, _suffix, "scroll"); - _txt = inline_links(doc_matters, obj, _txt, _suffix, "scroll"); - _txt = inline_notes_scroll(doc_matters, obj, _txt); + _txt = inline_images(_txt, obj, doc_matters, _suffix, "scroll"); + _txt = inline_links(_txt, obj, doc_matters, _suffix, "scroll"); + _txt = inline_notes_scroll(_txt, obj, doc_matters); return _txt; } - auto inline_markup_seg(M,O)( - M doc_matters, - const O obj, + auto inline_markup_seg(O,M)( string _txt, + const O obj, + M doc_matters, string _suffix = ".html", string _xml_type = "seg", ) { - _txt = inline_images(doc_matters, obj, _txt, _suffix, _xml_type); // TODO - _txt = inline_links(doc_matters, obj, _txt, _suffix, _xml_type); // TODO - auto t = inline_notes_seg(doc_matters, obj, _txt); + _txt = inline_images(_txt, obj, doc_matters, _suffix, _xml_type); // TODO + _txt = inline_links(_txt, obj, doc_matters, _suffix, _xml_type); // TODO + auto t = inline_notes_seg(_txt, obj, doc_matters); return t; } - string lev4_heading_subtoc(M,O)( - M doc_matters, - const O obj, + string lev4_heading_subtoc(O,M)( + const O obj, + M doc_matters, ) { char[] lev4_subtoc; lev4_subtoc ~= "
\n"; @@ -543,9 +543,9 @@ template outputXHTMLs() { lev4_subtoc ~= "
\n"; return lev4_subtoc.to!string; } - auto nav_pre_next_svg(M,O)( - M doc_matters, - const O obj, + auto nav_pre_next_svg(O,M)( + const O obj, + M doc_matters, ) { string prev, next, toc; if (obj.tags.segment_anchor_tag_epub == "toc") { @@ -622,8 +622,8 @@ template outputXHTMLs() { return bar(); } auto heading(O)( - const O obj, string _txt, + const O obj, string _xml_type = "html", ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); @@ -680,28 +680,28 @@ template outputXHTMLs() { } return o; } - auto heading_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", + auto heading_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = heading(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = heading(_txt, obj); return o; } - auto heading_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html" + auto heading_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; - string o = heading(obj, _txt, _xml_type); + string o = heading(_txt, obj, _xml_type); auto u = tuple( o, _endnotes, @@ -709,8 +709,8 @@ template outputXHTMLs() { return u; } auto para(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); @@ -753,28 +753,28 @@ template outputXHTMLs() { } return o; } - auto para_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", + auto para_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = para(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = para(_txt, obj); return o; } - auto para_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto para_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = para(obj, _txt); + string o = para(_txt, obj); auto u = tuple( o, _endnotes, @@ -782,8 +782,8 @@ template outputXHTMLs() { return u; } auto quote(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); @@ -816,28 +816,28 @@ template outputXHTMLs() { } return o; } - auto quote_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", + auto quote_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = quote(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = quote(_txt, obj); return o; } - auto quote_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto quote_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = quote(obj, _txt); + string o = quote(_txt, obj); auto u = tuple( o, _endnotes, @@ -845,8 +845,8 @@ template outputXHTMLs() { return u; } auto group(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); @@ -879,29 +879,29 @@ template outputXHTMLs() { } return o; } - auto group_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto group_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = group(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = group(_txt, obj); return o; } - auto group_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto group_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = group(obj, _txt); + string o = group(_txt, obj); auto u = tuple( o, _endnotes, @@ -909,8 +909,8 @@ template outputXHTMLs() { return u; } auto block(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); @@ -939,29 +939,29 @@ template outputXHTMLs() { } return o; } - auto block_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto block_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = block(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = block(_txt, obj); return o; } - auto block_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto block_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = block(obj, _txt); + string o = block(_txt, obj); auto u = tuple( o, _endnotes, @@ -969,8 +969,8 @@ template outputXHTMLs() { return u; } auto verse(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); @@ -999,29 +999,29 @@ template outputXHTMLs() { } return o; } - auto verse_scroll(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto verse_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj); - _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = verse(obj, _txt); + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = verse(_txt, obj); return o; } - auto verse_seg(M,O)( - M doc_matters, - const O obj, - string _txt, - string _suffix = ".html", - string _xml_type = "html", + auto verse_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", ) { - auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); + auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = verse(obj, _txt); + string o = verse(_txt, obj); auto u = tuple( o, _endnotes, @@ -1029,8 +1029,8 @@ template outputXHTMLs() { return u; } auto tablarize(O)( - const O obj, string _txt, + const O obj, ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; @@ -1062,8 +1062,8 @@ template outputXHTMLs() { return t; } auto table(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); @@ -1071,7 +1071,7 @@ template outputXHTMLs() { assert(obj.metainfo.is_a == "table"); auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); - auto t = tablarize(obj, _txt); + auto t = tablarize(_txt, obj); _txt = t[0]; string _note = t[1]; string o; @@ -1094,24 +1094,9 @@ template outputXHTMLs() { ); return o; } - auto endnote(O)( - const O obj, - string _txt, - ) { - string o; - o = format(q"¶

- %s -

¶", - obj.metainfo.is_a, - obj.attrib.indent_hang, - obj.attrib.indent_base, - _txt - ); - return o; - } auto code(O)( - const O obj, string _txt, + const O obj, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); -- cgit v1.2.3