From 495dcb42fbd8429d1d7261b3efb418fd8978bf2e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 13 Jan 2019 14:00:06 -0500 Subject: 0.4.2 xmls output, internal --- org/doc_reform.org | 2 +- org/output_xmls.org | 302 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 200 insertions(+), 104 deletions(-) (limited to 'org') diff --git a/org/doc_reform.org b/org/doc_reform.org index 6b2f87c..55bd41d 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -26,7 +26,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 4, 1); +enum _ver = Version(0, 4, 2); #+END_SRC ** compilation restrictions (supported compilers) diff --git a/org/output_xmls.org b/org/output_xmls.org index 29b999b..b9302bd 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -91,20 +91,13 @@ string div_delimit( #+name: xhtml_format_objects #+BEGIN_SRC d -string special_characters(O)( - const O obj, - string _txt -){ +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.nbsp_char, " "); - if (!(obj.metainfo.is_a == "code")) { - _txt = (_txt) - .replaceAll(rgx.xhtml_line_break, "
"); - } return _txt; } #+END_SRC @@ -113,13 +106,14 @@ string special_characters(O)( #+name: xhtml_format_objects #+BEGIN_SRC d -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.nbsp_char, " "); +string special_characters(O)( + const O obj, +){ + string _txt = special_characters_text(obj.text); + if (!(obj.metainfo.is_a == "code")) { + _txt = (_txt) + .replaceAll(rgx.xhtml_line_break, "
"); + } return _txt; } #+END_SRC @@ -170,19 +164,7 @@ string _xhtml_anchor_tags(O)(O obj) { auto header_metadata(M)( M doc_matters, ) { - string _title="Title"; - string _author="Author"; - string _publisher="Publisher"; - string _date="Date"; - string _date_created="Date"; - string _date_issued="Date"; - string _date_available="Date"; - string _date_valid="Date"; - string _date_modified="Date"; - string _language="en"; - string _rights="Copyright: Copyright (C) year holder"; - string _generator="doc_reform [DocReform 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)"; - string _generator_home="http://www.sisudoc.org"; + string _publisher="Publisher"; // TODO string o; o = format(q"¶ @@ -200,19 +182,19 @@ auto header_metadata(M)( ¶", - _title, - _author, - _publisher, - _date, - _date_created, - _date_issued, - _date_available, - _date_valid, - _date_modified, - _language, - _rights, - _generator, - _generator_home, + doc_matters.conf_make_meta.meta.title_full, + doc_matters.conf_make_meta.meta.creator_author, + _publisher, + doc_matters.conf_make_meta.meta.date_published, + doc_matters.conf_make_meta.meta.date_created, + doc_matters.conf_make_meta.meta.date_issued, + doc_matters.conf_make_meta.meta.date_available, + doc_matters.conf_make_meta.meta.date_valid, + doc_matters.conf_make_meta.meta.date_modified, + doc_matters.src.language, + doc_matters.conf_make_meta.meta.rights_copyright, + doc_matters.generator_program.name_and_version, + doc_matters.generator_program.url_home, ); return o; } @@ -242,7 +224,7 @@ auto site_info_button(M)( o = format(q"¶
%s
¶", - _locations, + _locations, ); return o; } @@ -385,18 +367,18 @@ auto epub3_seg_head(M)( - - - - - - - - - - - - + + + + + + + + + + + + @@ -408,6 +390,16 @@ auto epub3_seg_head(M)( doc_matters.conf_make_meta.meta.title_full, (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : ", " ~ doc_matters.conf_make_meta.meta.creator_author, + doc_matters.conf_make_meta.meta.date_published, + doc_matters.conf_make_meta.meta.date_created, + doc_matters.conf_make_meta.meta.date_issued, + doc_matters.conf_make_meta.meta.date_available, + doc_matters.conf_make_meta.meta.date_valid, + doc_matters.conf_make_meta.meta.date_modified, + doc_matters.src.language, + doc_matters.conf_make_meta.meta.rights_copyright, + doc_matters.generator_program.name_and_version, + doc_matters.generator_program.url_home, doc_matters.src.language, ); return o; @@ -786,8 +778,7 @@ auto nav_pre_next_svg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto heading(M,O)( - M doc_matters, +auto heading(O)( const O obj, string _txt, string _xml_type = "html", @@ -856,7 +847,7 @@ auto heading_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = heading(doc_matters, obj, _txt); + string o = heading(obj, _txt); return o; } #+END_SRC @@ -875,7 +866,7 @@ auto heading_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; - string o = heading(doc_matters, obj, _txt, _xml_type); + string o = heading(obj, _txt, _xml_type); auto u = tuple( o, _endnotes, @@ -889,8 +880,7 @@ auto heading_seg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto para(M,O)( - M doc_matters, +auto para(O)( const O obj, string _txt, ) { @@ -945,7 +935,7 @@ auto para_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = para(doc_matters, obj, _txt); + string o = para(obj, _txt); return o; } #+END_SRC @@ -964,7 +954,7 @@ auto para_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = para(doc_matters, obj, _txt); + string o = para(obj, _txt); auto u = tuple( o, _endnotes, @@ -978,8 +968,7 @@ auto para_seg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto quote(M,O)( - M doc_matters, +auto quote(O)( const O obj, string _txt, ) { @@ -1024,7 +1013,7 @@ auto quote_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = quote(doc_matters, obj, _txt); + string o = quote(obj, _txt); return o; } #+END_SRC @@ -1043,7 +1032,7 @@ auto quote_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = quote(doc_matters, obj, _txt); + string o = quote(obj, _txt); auto u = tuple( o, _endnotes, @@ -1057,8 +1046,7 @@ auto quote_seg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto group(M,O)( - M doc_matters, +auto group(O)( const O obj, string _txt, ) { @@ -1104,7 +1092,7 @@ auto group_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = group(doc_matters, obj, _txt); + string o = group(obj, _txt); return o; } #+END_SRC @@ -1123,7 +1111,7 @@ auto group_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = group(doc_matters, obj, _txt); + string o = group(obj, _txt); auto u = tuple( o, _endnotes, @@ -1137,8 +1125,7 @@ auto group_seg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto block(M,O)( - M doc_matters, +auto block(O)( const O obj, string _txt, ) { @@ -1180,7 +1167,7 @@ auto block_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = block(doc_matters, obj, _txt); + string o = block(obj, _txt); return o; } #+END_SRC @@ -1199,7 +1186,7 @@ auto block_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = block(doc_matters, obj, _txt); + string o = block(obj, _txt); auto u = tuple( o, _endnotes, @@ -1213,8 +1200,7 @@ auto block_seg(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto verse(M,O)( - M doc_matters, +auto verse(O)( const O obj, string _txt, ) { @@ -1256,7 +1242,7 @@ auto verse_scroll(M,O)( ) { auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); - string o = verse(doc_matters, obj, _txt); + string o = verse(obj, _txt); return o; } #+END_SRC @@ -1275,7 +1261,7 @@ auto verse_seg(M,O)( auto t = inline_markup_seg(doc_matters, obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; - string o = verse(doc_matters, obj, _txt); + string o = verse(obj, _txt); auto u = tuple( o, _endnotes, @@ -1288,8 +1274,7 @@ auto verse_seg(M,O)( #+name: xhtml_format_objects_code #+BEGIN_SRC d -auto code(M,O)( - M doc_matters, +auto code(O)( const O obj, string _txt, ) { @@ -1330,8 +1315,7 @@ align="left|right|center" #+name: xhtml_format_objects #+BEGIN_SRC d -auto tablarize(M,O)( - M doc_matters, +auto tablarize(O)( const O obj, string _txt, ) { @@ -1370,14 +1354,13 @@ auto tablarize(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto table(M,O)( - M doc_matters, +auto table(O)( const O obj, string _txt, ) { auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); - auto t = tablarize(doc_matters, obj, _txt); + auto t = tablarize(obj, _txt); _txt = t[0]; string _note = t[1]; string o; @@ -1406,8 +1389,7 @@ auto table(M,O)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto endnote(M,O)( - M doc_matters, +auto endnote(O)( const O obj, string _txt, ) { @@ -1456,11 +1438,23 @@ void scroll(D,M)( string suffix = ".html"; string previous_part = ""; string delimit = ""; +#+END_SRC + +**** the loops & outer switch (sections & objects) format output + +#+name: output_html_scroll +#+BEGIN_SRC d foreach (part; doc_matters.xml.keys_seq.scroll) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); - string _txt = xhtml_format.special_characters(obj, obj.text); + string _txt = xhtml_format.special_characters(obj); switch (obj.metainfo.is_of_part) { +#+END_SRC + +***** frontmatter + +#+name: output_html_scroll +#+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": @@ -1491,6 +1485,12 @@ void scroll(D,M)( break; } break; +#+END_SRC + +***** body + +#+name: output_html_scroll +#+BEGIN_SRC d case "body": assert(part == "body" || "head"); switch (obj.metainfo.is_of_type) { case "para": @@ -1528,10 +1528,10 @@ void scroll(D,M)( doc_html ~= xhtml_format.verse_scroll(doc_matters, obj, _txt, suffix); break; case "code": - doc_html ~= xhtml_format.code(doc_matters, obj, _txt); + doc_html ~= xhtml_format.code(obj, _txt); break; case "table": - doc_html ~= xhtml_format.table(doc_matters, obj, _txt); + doc_html ~= xhtml_format.table(obj, _txt); break; default: { /+ debug +/ @@ -1553,6 +1553,12 @@ void scroll(D,M)( break; } break; +#+END_SRC + +***** backmatter + +#+name: output_html_scroll +#+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { @@ -1608,6 +1614,12 @@ void scroll(D,M)( } } break; +#+END_SRC + +***** closings & post loop + +#+name: output_html_scroll +#+BEGIN_SRC d } } } @@ -1666,10 +1678,22 @@ void seg(D,M)( string suffix = ".html"; string previous_part = ""; string delimit = ""; +#+END_SRC + +**** ↻ the loop (sections & objects) format output + +#+name: output_html_seg +#+BEGIN_SRC d foreach (part; doc_matters.xml.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); - string _txt = xhtml_format.special_characters(obj, obj.text); + string _txt = xhtml_format.special_characters(obj); +#+END_SRC + +***** all headings + +#+name: output_html_seg +#+BEGIN_SRC d if (obj.metainfo.is_a == "heading") { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { @@ -1737,9 +1761,21 @@ void seg(D,M)( } break; } +#+END_SRC + +***** non-heading + +#+name: output_html_seg +#+BEGIN_SRC d } else { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { +#+END_SRC + +****** frontmatter + +#+name: output_html_seg +#+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": @@ -1768,6 +1804,12 @@ void seg(D,M)( break; } break; +#+END_SRC + +****** body + +#+name: output_html_seg +#+BEGIN_SRC d case "body": assert(part == "body"); switch (obj.metainfo.is_of_type) { case "para": @@ -1812,10 +1854,10 @@ void seg(D,M)( doc_html_endnotes[segment_filename] ~= t[1]; break; case "code": - doc_html[segment_filename] ~= xhtml_format.code(doc_matters, obj, _txt); + doc_html[segment_filename] ~= xhtml_format.code(obj, _txt); break; case "table": - doc_html[segment_filename] ~= xhtml_format.table(doc_matters, obj, _txt); + doc_html[segment_filename] ~= xhtml_format.table(obj, _txt); doc_html_endnotes[segment_filename] ~= ""; break; default: @@ -1838,6 +1880,12 @@ void seg(D,M)( break; } break; +#+END_SRC + +****** backmatter + +#+name: output_html_seg +#+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { @@ -1898,6 +1946,12 @@ void seg(D,M)( } break; } +#+END_SRC + +***** closings & post loop + +#+name: output_html_seg +#+BEGIN_SRC d } } } @@ -2081,7 +2135,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { auto xhtml_format = outputXHTMLs(); auto pth_epub3 = DocReformPathsEPUB!()(doc_matters.output_path, doc_matters.src.language); - string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! + string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! string content = format(q"¶ ¶", - uuid, + _uuid, xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_full), xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_main), (doc_matters.conf_make_meta.meta.title_sub.empty) @@ -2124,9 +2178,9 @@ string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.date_published), (doc_matters.conf_make_meta.meta.rights_copyright.empty) ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), - uuid, - uuid, - uuid, + _uuid, + _uuid, + _uuid, (pth_epub3.fn_oebps_css(doc_matters.src.filename)).chompPrefix("OEBPS/"), ); content ~= " " ~ "" ~ "\n "; @@ -2274,7 +2328,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { #+BEGIN_SRC d string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { int counter = 0; - string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere + string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); auto rgx = Rgx(); enum DomTags { none, open, close, close_and_open, open_still, } @@ -2301,7 +2355,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : " by " ~ doc_matters.conf_make_meta.meta.creator_author, // author - uuid, // uuid + _uuid, // uuid "3", // content depth doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" @@ -2379,9 +2433,21 @@ void outputEPub3(D,I)( string[string] oepbs_content_parts; string suffix = ".xhtml"; string[] doc_parts_; +#+END_SRC + +**** ↻ the loop (sections & objects) format output + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d foreach (part; doc_matters.xml.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { - string _txt = xhtml_format.special_characters(obj, obj.text); + string _txt = xhtml_format.special_characters(obj); +#+END_SRC + +***** all headings + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d if (obj.metainfo.is_a == "heading") { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { @@ -2445,9 +2511,21 @@ void outputEPub3(D,I)( } break; } +#+END_SRC + +***** non-heading + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d } else { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { +#+END_SRC + +****** frontmatter + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": @@ -2477,6 +2555,12 @@ void outputEPub3(D,I)( break; } break; +#+END_SRC + +****** body + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d case "body": assert(part == "body"); switch (obj.metainfo.is_of_type) { case "para": @@ -2521,10 +2605,10 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "code": - doc_epub3[segment_filename] ~= xhtml_format.code(doc_matters, obj, _txt); + doc_epub3[segment_filename] ~= xhtml_format.code(obj, _txt); break; case "table": - doc_epub3[segment_filename] ~= xhtml_format.table(doc_matters, obj, _txt); + doc_epub3[segment_filename] ~= xhtml_format.table(obj, _txt); doc_epub3_endnotes[segment_filename] ~= ""; break; default: @@ -2547,6 +2631,12 @@ void outputEPub3(D,I)( break; } break; +#+END_SRC + +****** backmatter + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { @@ -2652,6 +2742,12 @@ void outputEPub3(D,I)( obj.metainfo.object_number, ); } +#+END_SRC + +***** closings & post loop + +#+name: output_epub3_xhtml_seg +#+BEGIN_SRC d } } } -- cgit v1.2.3