From 2cdc5d2a7c62e54009e915d6f6a9da87905e2699 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 29 Aug 2021 19:06:01 -0400 Subject: xmls, epub3 toc_nav.xhtml toc.ncx --- src/doc_reform/io_out/epub3.d | 297 ++++++++++++++++++++--------------- src/doc_reform/io_out/html.d | 56 +++---- src/doc_reform/io_out/paths_output.d | 2 +- src/doc_reform/io_out/xmls.d | 76 ++++----- 4 files changed, 237 insertions(+), 194 deletions(-) (limited to 'src/doc_reform/io_out') diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 1a8d924..b38fe3e 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -63,6 +63,16 @@ template outputEPub3() { doc_reform.io_out.xmls_css; mixin InternalMarkup; mixin outputXHTMLs; + static auto rgx = RgxO(); + @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.nbsp_char, " "); + return _txt; + } @safe string epub3_mimetypes() { string o; o = format(q"┃application/epub+zip┃") ~ "\n"; @@ -70,7 +80,7 @@ template outputEPub3() { } @safe string epub3_container_xml() { string o; - o = format(q"┃┃") ~ "\n"; + o = format(q"┃┃") ~ "\n"; o ~= format(q"┃ @@ -83,14 +93,13 @@ template outputEPub3() { auto xhtml_format = outputXHTMLs(); auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! - string content = format(q"┃ - + string content = format(q"┃ + - %s main %s @@ -101,18 +110,13 @@ template outputEPub3() { Copyright: %s %s urn:uuid:%s - - - - - - - + + + ┃", _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) ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_sub), @@ -127,13 +131,10 @@ template outputEPub3() { ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), _uuid, _uuid, - _uuid, (pth_epub3.fn_oebps_css).chompPrefix("OEBPS/"), ); - content ~= " " ~ "" ~ "\n "; content ~= parts["manifest_documents"]; // TODO sort jpg & png - content ~= " " ~ "" ~ "\n "; foreach (image; doc_matters.srcs.image_list) { content ~= format(q"┃ ┃", @@ -181,88 +182,111 @@ template outputEPub3() { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = RgxO(); - string toc =format(" + string toc; + string toc_head = format(q"┃ %s -
-
-

Contents

-
- -
- - \n"; + toc ~= _toc_nav_tail; return toc; } @safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { - int counter = 0; + int counter_play_order = 0; string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); static auto rgx = RgxO(); enum DomTags { none, open, close, close_and_open, open_still, } - string toc = format(q"┃ + string toc; + string toc_ = format(q"┃ ┃", - doc_matters.conf_make_meta.meta.title_full.replaceAll(regex("\""), """), - doc_matters.conf_make_meta.meta.creator_author, + special_characters_text(doc_matters.conf_make_meta.meta.title_full), + special_characters_text(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, + special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_text(doc_matters.conf_make_meta.meta.date_created), + special_characters_text(doc_matters.conf_make_meta.meta.date_issued), + special_characters_text(doc_matters.conf_make_meta.meta.date_available), + special_characters_text(doc_matters.conf_make_meta.meta.date_valid), + special_characters_text(doc_matters.conf_make_meta.meta.date_modified), doc_matters.src.language, - doc_matters.conf_make_meta.meta.rights_copyright, - doc_matters.opt.action.debug_do ? "" : doc_matters.generator_program.name_and_version, - doc_matters.generator_program.url_home, + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + doc_matters.opt.action.debug_do ? "" : special_characters_text(doc_matters.generator_program.name_and_version), + special_characters_text(doc_matters.generator_program.url_home), ); return o; } @@ -266,9 +266,9 @@ template outputXHTMLs() {
%s
%s%s┃", - doc_matters.conf_make_meta.meta.title_full, + special_characters_text(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, + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), header_metadata(doc_matters), ((type == "seg") ? "../" : ""), ((type == "seg") @@ -330,22 +330,22 @@ template outputXHTMLs() { ┃", html_simple, - doc_matters.conf_make_meta.meta.title_full.replaceAll(regex("\""), """), + special_characters_text(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.title_full, + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + special_characters_text(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, + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_text(doc_matters.conf_make_meta.meta.date_created), + special_characters_text(doc_matters.conf_make_meta.meta.date_issued), + special_characters_text(doc_matters.conf_make_meta.meta.date_available), + special_characters_text(doc_matters.conf_make_meta.meta.date_valid), + special_characters_text(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, + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + special_characters_text(doc_matters.generator_program.name_and_version), + special_characters_text(doc_matters.generator_program.url_home), doc_matters.src.language, ); return o; @@ -587,7 +587,7 @@ template outputXHTMLs() { } return _txt; } - @safe auto inline_markup_seg(O,M)( + @safe Tuple!(string, string[]) inline_markup_seg(O,M)( string _txt, const O obj, M doc_matters, @@ -792,7 +792,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; string o = heading(_txt, obj, doc_matters, _xml_type); @@ -872,7 +872,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = para(_txt, obj, doc_matters); @@ -935,7 +935,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = quote(_txt, obj, doc_matters); @@ -1001,7 +1001,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = group(_txt, obj, doc_matters); @@ -1063,7 +1063,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = block(_txt, obj, doc_matters); @@ -1123,7 +1123,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = verse(_txt, obj, doc_matters); -- cgit v1.2.3