diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2021-08-29 19:06:01 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2021-09-09 22:03:12 -0400 |
commit | 2cdc5d2a7c62e54009e915d6f6a9da87905e2699 (patch) | |
tree | acb5e8af2cccc20546effef9722fe5526064f947 /src | |
parent | config nix (diff) |
xmls, epub3 toc_nav.xhtml toc.ncx
Diffstat (limited to 'src')
-rw-r--r-- | src/doc_reform/io_out/epub3.d | 297 | ||||
-rw-r--r-- | src/doc_reform/io_out/html.d | 56 | ||||
-rw-r--r-- | src/doc_reform/io_out/paths_output.d | 2 | ||||
-rw-r--r-- | src/doc_reform/io_out/xmls.d | 76 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 11 |
5 files changed, 244 insertions, 198 deletions
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"┃<?xml version="1.0" encoding="UTF-8"?>┃") ~ "\n"; + o = format(q"┃<?xml version="1.0" encoding="utf-8"?>┃") ~ "\n"; o ~= format(q"┃<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> @@ -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"┃ <?xml version="1.0" encoding="UTF-8"?> - <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="EPB-UUID"> + string content = format(q"┃<?xml version="1.0" encoding="utf-8"?> + <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" prefix="rendition: http://www.idpf.org/vocab/rendition/#"> <metadata xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:dcterms="https://purl.org/dc/terms/" xmlns:dc="https://purl.org/dc/elements/1.1/" unique-identifier="urn:uuid:%s" version="2.0"> - <!-- <dc:title id="title">%s</dc:title> --> <dc:title id="title">%s</dc:title> <meta refines="#title" property="title-type">main</meta> <dc:title id="subtitle">%s</dc:title> @@ -101,18 +110,13 @@ template outputEPub3() { <dc:rights>Copyright: %s</dc:rights> <dc:identifier scheme="URI">%s</dc:identifier> <dc:identifier id="bookid">urn:uuid:%s</dc:identifier> - <!-- <dc:identifier id="EPB-UUID">urn:uuid:%s</dc:identifier> --> </metadata> <manifest> - <!-- NCX epub2 navigation --> - <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" /> - <!-- CSS Style Sheets --> - <link rel="stylesheet" href="%s" type="text/css" id="main-css" /> - <!-- nav epub3 navigation --> - <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> + <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" /> + <link rel="stylesheet" href="%s" type="text/css" id="main-css" /> + <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> ┃", _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 ~= " " ~ "<!-- Content Documents -->" ~ "\n "; content ~= parts["manifest_documents"]; // TODO sort jpg & png - content ~= " " ~ "<!-- Images -->" ~ "\n "; foreach (image; doc_matters.srcs.image_list) { content ~= format(q"┃ <item id="%s" href="%s/%s" media-type="image/%s" /> ┃", @@ -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("<html xmlns=\"https://www.w3.org/1999/xhtml\" - xmlns:epub=\"http://www.idpf.org/2007/ops\"> + string toc; + string toc_head = format(q"┃<html xmlns="https://www.w3.org/1999/xhtml" + xmlns:epub="http://www.idpf.org/2007/ops"> <head> <title>%s</title> </head> <body> - <section epub:type=\"frontmatter toc\"> - <header> - <h1>Contents</h1> - </header> - <nav epub:type=\"toc\" id=\"toc\">\n", - doc_matters.conf_make_meta.meta.title_full, - ); + <section epub:type="frontmatter toc"> + <header> + <h1>Contents</h1> + </header> + <nav epub:type="toc" id="toc"> + <ol> + <li>┃", + (doc_matters.conf_make_meta.meta.title_full).special_characters_text, + ); + string _toc_nav_tail = ""; + // writeln(doc_matters.has.keys_seq.seg); // DEBUG line foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { - if (obj.metainfo.is_a == "heading") { + if ((sect == "head") && (obj.metainfo.is_a == "heading")) { + toc = format(q"┃%s + <a href="_the_title.xhtml">%s</a> + </li> + ┃", + toc_head, + obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip, + ); + } else if (sect == "tail") { // skip + } else if ((sect != "tail") && (obj.metainfo.is_a == "heading")) { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; foreach_reverse (n; 0 .. 7) { string k = n.to!string; switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { + case DomTags.none : + break; case DomTags.close : - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; - toc ~= markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n"; + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; + toc ~= markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n"; break; case DomTags.close_and_open : - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; - if (obj.metainfo.heading_lev_markup < 4) { - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" - ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" ~ "\">" - ~ _txt - ~ "</a>" ~ "\n"; - } else { - string hashtag =(obj.metainfo.heading_lev_markup == 4) - ? "" - : ("#" ~ obj.metainfo.ocn.to!string); - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" - ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" ~ hashtag ~ "\">" - ~ _txt - ~ "</a>" ~ "\n"; - } - break; + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; + goto default; case DomTags.open : - toc ~= markup.indent_by_spaces_provided(n, " ") ~ "<ol>" ~ "\n"; - if (obj.metainfo.heading_lev_markup < 4) { - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" - ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" ~ "\">" - ~ _txt - ~ "</a>" ~ "\n"; - } else { - string hashtag =(obj.metainfo.heading_lev_markup == 4) - ? "" - : ("#" ~ obj.metainfo.ocn.to!string); - toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" - ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" ~ hashtag ~ "\">" - ~ _txt - ~ "</a>" ~ "\n"; - } - break; + toc ~= markup.indent_by_spaces_provided(n, " ") ~ "<ol>" ~ "\n"; + goto default; default : + if ((obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.close_and_open || + obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.open + )) { + string _hashtag = ""; + if ((obj.metainfo.heading_lev_markup <= 4) && (obj.metainfo.ocn == 0)) { + _hashtag = "#" ~ obj.metainfo.ocn.to!string; + } + string _href = "<a href=\"" + ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" + ~ _hashtag + ~ "\">"; + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" + ~ markup.indent_by_spaces_provided((n + 2), " ") + ~ _href ~ _txt.special_characters_text ~ "</a>" ~ "\n"; + } break; } + if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) { + // writeln(n, ": ", sect, ": ", _txt, " - ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG + // read last heading (heading prior to closing) and determine what those instructions imply still need to be done + // CLOSE // DomTags { 0 none, 1 open, 2 close, 3 close_and_open, 4 open_still, } + if (n == 6) {_toc_nav_tail = "";} + switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { + case 0: case 2: + // case DomTags.none: case DomTags.close: + break; + case 1: case 3: case 4: + // case DomTags.open: case DomTags.close_and_open: case DomTags.open_still: + if (n != 0) { + _toc_nav_tail ~= " " ~ markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; + } + _toc_nav_tail ~= " " ~ markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n"; + break; + default : + break; + } + if (n == 0) { + _toc_nav_tail ~="</nav> + </section> + </body> + </html>\n"; + } + } } } } } - toc ~="</nav> - </section> - </body> - </html>\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"┃<?xml version="1.0" encoding="UTF-8"?> + string toc; + string toc_ = format(q"┃<?xml version="1.0" encoding="utf-8"?> <ncx xmlns="https://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <!-- four required metadata items (for all NCX documents, @@ -281,70 +305,89 @@ template outputEPub3() { <text>%s</text> </docAuthor> <navMap>┃", - doc_matters.conf_make_meta.meta.title_full, // title + (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" - : " by " ~ doc_matters.conf_make_meta.meta.creator_author, // author + : " by " ~ (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author _uuid, // uuid "3", // content depth - doc_matters.conf_make_meta.meta.title_full, // title + (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" - : doc_matters.conf_make_meta.meta.creator_author, // author + : (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author ); + string _toc_ncx_tail = ""; foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { + if (sect == "head") { toc = toc_; + } if (obj.metainfo.is_a == "heading") { - string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; - string hashtag =(obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string); + string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip.special_characters_text; + // writeln(_txt, " --- ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG line + string hashtag = (obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string); foreach_reverse (k; 0 .. 7) { - switch (obj.metainfo.dom_structure_markedup_tags_status[k]) { + switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) { // for epub may need to construct for levels 1 to 4 only case DomTags.close : - toc ~= "\n </navPoint>"; + if (sect != "head") { + toc ~= "\n </navPoint>"; // issue at start of some documents + } break; case DomTags.close_and_open : - ++counter; toc ~= "\n </navPoint>"; - toc ~= format(q"┃ - <navPoint class="chapter" id="navpoint" playOrder="%s"> - <navLabel> - <text>%s</text> - </navLabel> - <content src="%s.xhtml%s" />┃", - counter, - _txt, - obj.tags.segment_anchor_tag_epub, - hashtag, - ); - break; + goto default; case DomTags.open : - ++counter; - toc ~= format(q"┃ + goto default; + default : + string _toc; + if ((obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open + || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open + // || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open_still + )) { + ++counter_play_order; + _toc = format(q"┃ <navPoint class="chapter" id="navpoint" playOrder="%s"> <navLabel> <text>%s</text> </navLabel> <content src="%s.xhtml%s" />┃", - counter, - _txt, - obj.tags.segment_anchor_tag_epub, - hashtag, - ); - break; - default : + counter_play_order, + _txt, + obj.tags.segment_anchor_tag_epub, + hashtag, + ); + } + if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open) { + toc ~= _toc; + } else if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open) { + toc ~= _toc; + } break; } + if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) { + if (k == 6) {_toc_ncx_tail = "";} + switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) { + case 0: case 2: + // case DomTags.none: case DomTags.close: + break; + case 1: case 3: case 4: + // case DomTags.open: case DomTags.close_and_open: case DomTags.open_still: + if (k != 0) { + } + _toc_ncx_tail ~= " " ~ markup.indent_by_spaces_provided(k, " ") ~ "</navPoint>" ~ "\n"; + break; + default : + break; + } + if (k == 0) { + _toc_ncx_tail ~= format(q"┃ </navMap> + </ncx>┃"); + } + } } } } } - toc ~= format(q"┃ - </navPoint> - </navPoint> - </navPoint> - </navMap> - </ncx>┃"); + toc ~= _toc_ncx_tail; return toc; } - @system void outputEPub3(D,I)( const D doc_abstraction, I doc_matters, @@ -400,7 +443,7 @@ template outputEPub3() { default: epubWrite.doc_parts ~= obj.tags.segment_anchor_tag_epub; epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc_matters); - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= t[0]; epubWrite.doc_epub3_endnotes[obj.tags.segment_anchor_tag_epub] ~= t[1]; break; @@ -409,12 +452,12 @@ template outputEPub3() { case 4: segment_filename = obj.tags.segment_anchor_tag_epub; epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters); - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -438,13 +481,14 @@ template outputEPub3() { } } else { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); + Tuple!(string, string[]) t; switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { case "toc": - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -473,7 +517,7 @@ template outputEPub3() { case "para": switch (obj.metainfo.is_a) { case "para": - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -490,24 +534,24 @@ template outputEPub3() { case "block": switch (obj.metainfo.is_a) { case "quote": - auto t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "group": - auto t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "block": - auto t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "poem": break; case "verse": - auto t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -544,26 +588,26 @@ template outputEPub3() { case "para": switch (obj.metainfo.is_a) { case "endnote": assert(part == "endnotes"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; break; case "glossary": assert(part == "glossary"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "bibliography": assert(part == "bibliography"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "bookindex": assert(part == "bookindex"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "blurb": assert(part == "blurb"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -604,25 +648,25 @@ template outputEPub3() { if (obj.metainfo.heading_lev_markup <= 4) { oepbs_content_parts["manifest_documents"] ~= format(q"┃ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, obj.tags.segment_anchor_tag_epub, ); oepbs_content_parts["spine"] ~= format(q"┃ <itemref idref="%s.xhtml" linear="yes" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, ); oepbs_content_parts["guide"] ~= format(q"┃ <reference type="%s" href="%s" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, obj.tags.segment_anchor_tag_epub, ); } else if (obj.metainfo.heading_lev_markup > 4) { oepbs_content_parts["manifest_documents"] ~= format(q"┃ <item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, obj.metainfo.object_number, obj.tags.segment_anchor_tag_epub, @@ -630,13 +674,13 @@ template outputEPub3() { ); oepbs_content_parts["spine"] ~= format(q"┃ <itemref idref="%s.xhtml#%s" linear="yes" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, obj.metainfo.object_number, ); oepbs_content_parts["guide"] ~= format(q"┃ <reference type="%s#%s" href="%s#%s" /> - ┃", + ┃", obj.tags.segment_anchor_tag_epub, obj.metainfo.object_number, obj.tags.segment_anchor_tag_epub, @@ -858,5 +902,4 @@ template outputEPub3() { } } } - } diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d index ceaf9f9..5c55bd7 100644 --- a/src/doc_reform/io_out/html.d +++ b/src/doc_reform/io_out/html.d @@ -299,7 +299,7 @@ template outputHTML() { top_level_headings[3] = ""; goto default; default: - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); top_level_headings[obj.metainfo.heading_lev_markup] = t[0]; break; } @@ -313,13 +313,13 @@ template outputHTML() { foreach (top_level_heading; top_level_headings) { doc_html[segment_filename] ~= top_level_heading; } - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc_matters); doc_html_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: - auto t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; doc_html_endnotes[segment_filename] ~= t[1]; break; @@ -343,13 +343,14 @@ template outputHTML() { } } else { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); + Tuple!(string, string[]) t; switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { case "toc": - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; break; default: @@ -377,7 +378,7 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "para": - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; doc_html_endnotes[segment_filename] ~= t[1]; break; @@ -394,27 +395,19 @@ template outputHTML() { case "block": switch (obj.metainfo.is_a) { case "quote": - auto t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "seg"); - doc_html[segment_filename] ~= t[0].to!string; - doc_html_endnotes[segment_filename] ~= t[1]; - break; + t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "seg"); + goto default; case "group": - auto t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "seg"); - doc_html[segment_filename] ~= t[0].to!string; - doc_html_endnotes[segment_filename] ~= t[1]; - break; + t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "seg"); + goto default; case "block": - auto t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "seg"); - doc_html[segment_filename] ~= t[0].to!string; - doc_html_endnotes[segment_filename] ~= t[1]; - break; + t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "seg"); + goto default; case "poem": break; case "verse": - auto t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "seg"); - doc_html[segment_filename] ~= t[0].to!string; - doc_html_endnotes[segment_filename] ~= t[1]; - break; + t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "seg"); + goto default; case "code": doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters); break; @@ -423,7 +416,14 @@ template outputHTML() { doc_html_endnotes[segment_filename] ~= ""; break; default: - { /+ debug +/ + if ((obj.metainfo.is_a == "quote" + || obj.metainfo.is_a == "group" + || obj.metainfo.is_a == "block" + || obj.metainfo.is_a == "verse" + )) { + doc_html[segment_filename] ~= t[0].to!string; + doc_html_endnotes[segment_filename] ~= t[1]; + } else { /+ debug +/ if (doc_matters.opt.action.debug_do && doc_matters.opt.action.verbose) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); @@ -448,26 +448,26 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "endnote": assert(part == "endnotes"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; break; case "glossary": assert(part == "glossary"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "bibliography": assert(part == "bibliography"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "bookindex": assert(part == "bookindex"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "blurb": assert(part == "blurb"); - auto t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; @@ -560,7 +560,7 @@ template outputHTML() { M doc_matters, ) { { /+ (copy html images) +/ - + auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (!exists(pth_html.image)) { pth_html.image.mkdirRecurse; diff --git a/src/doc_reform/io_out/paths_output.d b/src/doc_reform/io_out/paths_output.d index 96ef12d..86f418a 100644 --- a/src/doc_reform/io_out/paths_output.d +++ b/src/doc_reform/io_out/paths_output.d @@ -445,7 +445,7 @@ template spinePathsEPUB() { return dbg_docdir(fn_src).chainPath("OEBPS").array; } string dbg_doc_oebps_css(string fn_src) { - return dbg_doc_oebps(fn_src).chainPath("css").array; + return dbg_doc_oebps(fn_src).chainPath("Styles").array; } string dbg_doc_oebps_image(string fn_src) { return dbg_doc_oebps(fn_src).chainPath("image").array; diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 703df3d..ab80a09 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -95,10 +95,10 @@ template outputXHTMLs() { } @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.nbsp_char, " "); return _txt; } @@ -131,7 +131,7 @@ template outputXHTMLs() { if (obj.tags.anchor_tags.length > 0) { foreach (tag; obj.tags.anchor_tags) { if (!(tag.empty)) { - tags ~= "<a name=\"" ~ tag ~ "\"></a>"; + tags ~= "<a name=\"" ~ special_characters_text(tag) ~ "\"></a>"; } } } @@ -158,19 +158,19 @@ template outputXHTMLs() { <meta name="generator" content="%s" /> <link rel="generator" href="%s" /> <!-- spine DocReform header metadata -->┃", - 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() { <div class="flex-menu-option"> %s </div>%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() { <body lang="%s"> <a name="top" id="top"></a>┃", 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); diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index d306df5..bc19ec2 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -452,6 +452,9 @@ template docAbstraction() { reset_note_numbers = true; lev_anchor_tag = ""; anchor_tag = ""; + // dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + // dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + // dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; } mixin spineNode; auto node_para_int_ = node_metadata_para_int; @@ -2468,10 +2471,10 @@ template docAbstraction() { html_segnames_ptr = 0; html_segnames_ptr_cntr = 0; content_non_header = "8"; - dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; lev_anchor_tag = ""; anchor_tag = ""; @safe auto doc_has() { |