/+ - Name: Spine, Doc Reform [a part of] - Description: documents, structuring, processing, publishing, search - static content generator - Author: Ralph Amissah [ralph.amissah@gmail.com] - Copyright: (C) 2015 - 2021 Ralph Amissah, All Rights Reserved. - License: AGPL 3 or later: Spine (SiSU), a framework for document structuring, publishing and search Copyright (C) Ralph Amissah This program is free software: you can redistribute it and/or modify it under the terms of the GNU AFERO General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see [https://www.gnu.org/licenses/]. If you have Internet connection, the latest version of the AGPL should be available at these locations: [https://www.fsf.org/licensing/licenses/agpl.html] [https://www.gnu.org/licenses/agpl.html] - Spine (by Doc Reform, related to SiSU) uses standard: - docReform markup syntax - standard SiSU markup syntax with modified headers and minor modifications - docReform object numbering - standard SiSU object citation numbering & system - Hompages: [https://www.doc_reform.org] [https://www.sisudoc.org] - Git [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] +/ module doc_reform.io_out.xmls; template outputXHTMLs() { import std.file, std.outbuffer, std.uri, std.conv : to; import doc_reform.io_out, doc_reform.io_out.create_zip_file, doc_reform.io_out.xmls, doc_reform.io_out.xmls_css; mixin spineRgxOut; struct outputXHTMLs { static auto rgx = RgxO(); @safe string div_delimit( string part, return ref string previous_part ) { string delimit = ""; string delimit_ = ""; if (part != previous_part) { switch (part) { case "head": delimit_ ~= "\n
\n" ; break; case "toc": delimit_ ~= "\n
\n" ; break; case "bookindex": delimit_ ~= "\n
\n" ; break; default: delimit_ ~= "\n
\n" ; break; } if (previous_part.length > 0) { delimit ~= "\n
"; } previous_part = part; delimit ~= delimit_; } // you also need to close the last div, introduce a footer? return delimit; } @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 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; } @safe string font_face(string _txt) { _txt = _txt .replaceAll(rgx.inline_emphasis, ("$1")) .replaceAll(rgx.inline_bold, ("$1")) .replaceAll(rgx.inline_underscore, ("$1")) .replaceAll(rgx.inline_italics, ("$1")) .replaceAll(rgx.inline_superscript, ("$1")) .replaceAll(rgx.inline_subscript, ("$1")) .replaceAll(rgx.inline_strike, ("$1")) .replaceAll(rgx.inline_insert, ("$1")) .replaceAll(rgx.inline_mono, ("$1")) .replaceAll(rgx.inline_cite, ("$1")); return _txt; } @safe string _xhtml_anchor_tags(O)(O obj) { string tags=""; if (obj.tags.anchor_tags.length > 0) { foreach (tag; obj.tags.anchor_tags) { if (!(tag.empty)) { tags ~= ""; } } } return tags; } @safe string header_metadata(M)( M doc_matters, ) { string _publisher="Publisher"; // TODO string o; o = format(q"┃ ┃", doc_matters.conf_make_meta.meta.title_full.replaceAll(regex("\""), """), 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.opt.action.debug_do ? "" : doc_matters.generator_program.name_and_version, doc_matters.generator_program.url_home, ); return o; } @safe string site_info_button(M)( M doc_matters, ) { string _locations; if (doc_matters.conf_make_meta.make.home_button_text.length > 0) { _locations = (doc_matters.conf_make_meta.make.home_button_text) .replaceAll( rgx.inline_link, ("

$1

")) .replaceAll( rgx.br_line, "") .replaceAll( rgx.br_nl, ""); } else { _locations = "

spine

\n

sources / git

\n

www.sisudoc.org

"; } string o; o = format(q"┃
%s
┃", _locations, ); return o; } @safe string inline_search_form(M)( M doc_matters, ) { string o; string _form; if (doc_matters.opt.action.html_search_link) { o = format(q"┃
┃", doc_matters.conf_make_meta.conf.w_srv_cgi_action, (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty) ? "" : "\n ", doc_matters.src.filename_base, ); } else { o = ""; } return o; } @safe string html_head(M)( M doc_matters, string type, ) { string o; string metadata_links = ((doc_matters.opt.action.html_harvest_link) ? format(q"┃

[ m | A | T ]

┃", (type == "seg") ? "../" : "", doc_matters.src.filename_base, (type == "seg") ? "../" : "", (type == "seg") ? "../" : "", ) : ""); o = format(q"┃ %s%s %s
%s
%s
%s%s┃", 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, header_metadata(doc_matters), ((type == "seg") ? "../" : ""), ((type == "seg") ? "../../../css/html_seg.css" : "../../css/html_scroll.css"), doc_matters.src.language, site_info_button(doc_matters), metadata_links, inline_search_form(doc_matters), (type == "seg") ? "" : "\n
", ); return o; } @safe string epub3_seg_head(M)( M doc_matters, ) { string html_base = format(q"┃ ┃", ); string html_simple = format(q"┃ ┃", doc_matters.src.language, doc_matters.src.language, ); string html_strict = format(q"┃ ┃", doc_matters.src.language, doc_matters.src.language, ); string o; o = format(q"┃%s %s%s ┃", html_simple, doc_matters.conf_make_meta.meta.title_full.replaceAll(regex("\""), """), (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, (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; } @safe string tail() { string o; o = format(q"┃ ┃"); return o; } @safe string inline_images(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", ) { string _img_pth; switch (_xml_type) { case "epub": _img_pth = "image/"; break; case "scroll": _img_pth = format(q"┃%s/image/┃", "../.."); break; case "seg": _img_pth = format(q"┃%s/image/┃", "../../.."); break; default: break; } if (_txt.match(rgx.inline_image)) { _txt = _txt .replaceAll(rgx.inline_image, ("$1 $6")) .replaceAll( rgx.inline_link_empty, ("$1")); } return _txt; } @safe string 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!(m => m[1] ~ "┤" ~ (replaceAll!(n => n["type"] ~ n["path"] ~ (n["file"].encodeComponent) )((obj.stow.link[m["num"].to!ulong]).to!string, rgx.uri_identify_components)) ~ "├" )(_txt, rgx.inline_link_number_only); } if ((_txt.match(rgx.mark_internal_site_lnk)) && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault _txt = _txt.replaceAll( rgx.inline_seg_link, "$1"); } if (_xml_type == "seg" || _xml_type == "epub") { seg_lvs = (_xml_type == "epub") ? "seg_lv1_to_4" : "seg_lv4"; foreach (m; _txt.match(rgx.inline_link_hash)) { if (m.captures["hash"] in doc_matters.has.tag_associations) { if ( m.captures["hash"] == doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤$3" ~ _suffix ~ "├" ); } else { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" ~ doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" ); } } else { if (!(doc_matters.opt.action.quiet)) { writeln( "WARNING on internal document links, anchor to link <<" ~ m.captures["hash"] ~ ">> not found in document, " ~ "anchor: " ~ m.captures["hash"] ~ " document: " ~ doc_matters.src.filename ); } } } } _txt = _txt .replaceAll( rgx.inline_link_fn_suffix, ("$1" ~ _suffix)) .replaceAll( rgx.inline_link, ("$1")) .replaceAll( rgx.mark_internal_site_lnk, ""); } debug(markup_links) { if (_txt.match(rgx.inline_link)) { writeln(__LINE__, " (missed) markup link identified (", obj.has.inline_links, "): ", obj.metainfo.is_a, ": ", obj.text ); } } debug(markup) { if (_txt.match(rgx.inline_link)) { writeln(__LINE__, " (missed) markup link identified (", obj.has.inline_links, "): ", obj.metainfo.is_a, ": ", obj.text ); } } return _txt; } @safe string inline_notes_scroll(O,M)( string _txt, const O obj, M doc_matters, ) { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); _txt = _txt.replaceAll( rgx.inline_notes_al_regular_number_note, (" $1 ") ); } if (obj.has.inline_notes_star) { _txt = font_face(_txt); _txt = _txt.replaceAll( rgx.inline_notes_al_special_char_note, (" $1 ") ); } debug(markup_endnotes) { if (_txt.match(rgx.inline_notes_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); } } debug(markup) { if (_txt.match(rgx.inline_notes_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); } } return _txt; } @safe Tuple!(string, string[]) inline_notes_seg(O,M)( string _txt, const O obj, M doc_matters, ) { string[] _endnotes; if (obj.has.inline_notes_star) { _txt = font_face(_txt); /+ need markup for text, and separated footnote +/ foreach(m; _txt.matchAll(rgx.inline_notes_al_special_char_note)) { _endnotes ~= format( "%s%s%s%s\n %s%s%s%s%s %s\n%s", "

", "", " ", m.captures[1], ".", m.captures[2], "

" ); } _txt = _txt.replaceAll( rgx.inline_notes_al_special_char_note, (" $1 ") ); } if (obj.has.inline_notes_reg) { _txt = font_face(_txt); /+ need markup for text, and separated footnote +/ foreach(m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { _endnotes ~= format( "%s%s%s%s\n %s%s%s%s%s %s\n%s", "

", "", " ", m.captures[1], ".", m.captures[2], "

" ); } _txt = _txt.replaceAll( rgx.inline_notes_al_regular_number_note, (" $1 ") ); } else if (_txt.match(rgx.inline_notes_al_regular_number_note)) { debug(markup) { writeln(__LINE__, " endnote: ", obj.metainfo.is_a, ": ", obj.text); } } Tuple!(string, string[]) t = tuple( _txt, _endnotes, ); return t; } @safe string inline_markup_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", ) { if (obj.metainfo.dummy_heading && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { _txt = ""; } else { _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; } @safe auto inline_markup_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", ) { if (obj.metainfo.dummy_heading && ((_xml_type == "epub" && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) || obj.metainfo.is_a == "heading") ) { _txt = ""; } else { _txt = inline_images(_txt, obj, doc_matters, _suffix, _xml_type); // TODO _txt = inline_links(_txt, obj, doc_matters, _suffix, _xml_type); // TODO } Tuple!(string, string[]) t = inline_notes_seg(_txt, obj, doc_matters); return t; } @safe string lev4_heading_subtoc(O,M)( const O obj, M doc_matters, ) { char[] lev4_subtoc; lev4_subtoc ~= "
\n"; foreach (subtoc; obj.tags.lev4_subtoc) { if (auto m = subtoc.match(rgx.inline_link_subtoc)) { auto indent = (m.captures[1].to!int - 3).to!string; // css assumptions based on use of em for left margin & indent auto text = m.captures[2].to!string; text = font_face(text); auto link = m.captures[3].to!string; lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc, format(q"┃

۰ %s

┃", indent, indent, link, text, )); } } lev4_subtoc ~= "
\n"; return lev4_subtoc.to!string; } @safe 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") { toc = ""; prev = ""; } else { toc = format(q"┃ ┃", ); } if (obj.tags.segname_prev == "") { prev = ""; } else { prev = format(q"┃ ┃", obj.tags.segname_prev, ); } if (obj.tags.segname_next == "") { next = ""; } else { next = format(q"┃ ┃", obj.tags.segname_next, ); } string _toc_pre_next = format(q"┃
┃", toc, prev, next, ); string _pre_next = format(q"┃
┃", prev, next, ); struct bar { string toc_pre_next() { return _toc_pre_next; } string pre_next() { return _pre_next; } } return bar(); } @safe string heading(O,M)( string _txt, const O obj, M doc_matters, string _xml_type = "html", ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); assert(obj.metainfo.is_a == "heading"); string tags = _xhtml_anchor_tags(obj); string heading_lev_anchor_tag; string _horizontal_rule = "
"; if ((_xml_type != "html") || (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) { _horizontal_rule = ""; } _txt = font_face(_txt); string o; heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) ? "" : ""; if (_txt.empty) { o = format(q"┃%s ┃", _horizontal_rule, ); } else if (!(obj.metainfo.identifier.empty)) { o = format(q"┃%s
%s%s %s
┃", _horizontal_rule, obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.heading_lev_markup, obj.metainfo.is_a, obj.metainfo.identifier, obj.metainfo.identifier, tags, heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); } else { o = format(q"┃%s
%s%s %s
┃", _horizontal_rule, obj.metainfo.heading_lev_markup, obj.metainfo.is_a, tags, heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); } return o; } @safe string heading_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = heading(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) heading_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe string para(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); assert(obj.metainfo.is_a == "para" || "toc" || "endnote" || "glossary" || "bibliography" || "bookindex" || "blurb"); string tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); string o; _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; _txt = _txt.replaceFirst(rgx.inline_link_anchor, ""); if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s %s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.attrib.indent_hang, obj.attrib.indent_base, obj.metainfo.identifier, tags, _txt ); } else { o = format(q"┃

%s %s

┃", obj.metainfo.is_a, obj.attrib.indent_hang, obj.attrib.indent_base, tags, _txt ); } return o; } @safe string para_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", ) { if (obj.metainfo.is_a == "toc" && _txt.match(rgx.inline_link_toc_to_backmatter)) { _txt = _txt.replaceAll(rgx.inline_link_toc_to_backmatter, "┤#section_$1├"); } _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = para(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) para_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe string quote(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "quote"); _txt = font_face(_txt); string o; if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.identifier, _txt ); } else { o = format(q"┃

%s

┃", obj.metainfo.is_a, _txt ); } return o; } @safe string quote_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = quote(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) quote_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe string group(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "group"); _txt = font_face(_txt); string o; if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.identifier, _txt ); } else { o = format(q"┃

%s

┃", obj.metainfo.is_a, _txt ); } return o; } @safe string group_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = group(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) group_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe string block(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "block"); _txt = font_face(_txt); string o; if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.identifier, _txt.stripRight ); } else { o = format(q"┃

%s

┃", obj.metainfo.is_a, _txt.stripRight ); } return o; } @safe string block_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = block(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) block_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe string verse(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "verse"); _txt = font_face(_txt); string o; if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.identifier, _txt ); } else { o = format(q"┃

%s

┃", obj.metainfo.is_a, _txt ); } return o; } @safe string verse_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = verse(_txt, obj, doc_matters); return o; } @safe Tuple!(string, string[]) verse_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", ) { auto 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); Tuple!(string, string[]) u = tuple( o, _endnotes, ); return u; } @safe Tuple!(string, string) tablarize(O)( string _txt, const O obj, ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; string _tablenote; foreach(row_idx, row; _table_rows) { _table_cols = row.split(rgx.table_delimiter_col); _table ~= ""; foreach(col_idx, cell; _table_cols) { if ((_table_cols.length == 1) && (_table_rows.length <= row_idx+2)) { _tablenote ~= cell; } else { string _col_is = (row_idx == 0 && obj.table.heading) ? "th" : "td"; string _align = ("style=\"text-align:" ~ ((obj.table.column_aligns[col_idx] == "l") ? "left\"" : "right\"")); _table ~= "<" ~ _col_is ~ " width=\"" ~ obj.table.column_widths[col_idx].to!string ~ "%\" " ~ _align ~ ">"; _table ~= cell; _table ~= ""; } } _table ~= ""; } Tuple!(string, string) t = tuple( _table, _tablenote, ); return t; } @safe string table(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "table"); string tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); auto t = tablarize(_txt, obj); _txt = t[0]; string _note = t[1]; string o; o = format(q"┃

%s %s
%s

┃", obj.metainfo.object_number, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.object_number, tags, _txt, _note ); return o; } @safe string code(O,M)( string _txt, const O obj, M doc_matters, ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "code"); string o; string codelines(string _txt) { string _codelines; if (obj.code_block.linenumbers) { string[] _block_lines = (_txt).split(rgx.br_newlines_linebreaks); _codelines = "
\n";
          foreach (k, _line; _block_lines) {
            if (k == 1) {
              _codelines ~= format(q"┃    %s
    ┃",
                _line,
              );
            } else {
              _codelines ~= format(q"┃    %s
    ┃",
                _line,
              );
            }
          }
          _codelines ~= "  
"; } else { _codelines = "
\n";
          _codelines ~= _txt;
          _codelines ~= "  
"; } return _codelines; } if (!(obj.metainfo.identifier.empty)) { o = format(q"┃

%s

┃", obj.metainfo.identifier, (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), obj.metainfo.is_a, obj.metainfo.identifier, codelines(_txt) ); } else { o = format(q"┃

%s

┃", obj.metainfo.is_a, codelines(_txt) ); } return o; } } }