module sdp.output.xmls; template outputXHTMLs() { import sdp.output; import std.digest.sha, std.file, std.outbuffer, std.zip, std.conv : to; import sdp.output.create_zip_file, sdp.output.xmls, sdp.output.xmls_css; mixin SiSUoutputRgxInit; struct outputXHTMLs { static auto rgx = Rgx(); string div_delimit( string part, return ref string previous_part ){ string delimit = ""; string delimit_ = ""; if (part != previous_part) { switch (part) { case "head": delimit_ ~= "\n<div class=\"doc_title\">\n" ; break; case "toc_seg": delimit_ ~= "\n<div class=\"doc_toc\">\n" ; break; case "toc_scroll": delimit_ ~= "\n<div class=\"doc_toc\">\n" ; break; case "bookindex_seg": delimit_ ~= "\n<div class=\"doc_bookindex\">\n" ; break; case "bookindex_scroll": delimit_ ~= "\n<div class=\"doc_bookindex\">\n" ; break; default: delimit_ ~= "\n<div class=\"doc_" ~ part ~ "\">\n" ; break; } if (previous_part.length > 0) { delimit ~= "\n</div>"; } previous_part = part; delimit ~= delimit_; } // you also need to close the last div, introduce a footer? return delimit; } string special_characters(O)( auto return ref const O obj, 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.is_a == "code")) { _txt = (_txt) .replaceAll(rgx.xhtml_line_break, "<br />"); } return _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, " "); return _txt; } string font_face(string _txt){ _txt = (_txt) .replaceAll(rgx.inline_emphasis, ("<em>$1</em>")) .replaceAll(rgx.inline_bold, ("<b>$1</b>")) .replaceAll(rgx.inline_underscore, ("<u>$1</u>")) .replaceAll(rgx.inline_italics, ("<i>$1</i>")) .replaceAll(rgx.inline_superscript, ("<sup>$1</sup>")) .replaceAll(rgx.inline_subscript, ("<sub>$1</sub>")) .replaceAll(rgx.inline_strike, ("<del>$1</del>")) .replaceAll(rgx.inline_insert, ("<ins>$1</ins>")) .replaceAll(rgx.inline_mono, ("<tt>$1</tt>")) .replaceAll(rgx.inline_cite, ("<cite>$1</cite>")); return _txt; } string _xhtml_anchor_tags(const(string[]) anchor_tags) { string tags=""; if (anchor_tags.length > 0) { foreach (tag; anchor_tags) { if (!(tag.empty)) { tags ~= "<a name=\"" ~ tag ~ "\"></a>"; } } } return tags; } auto header_metadata(Dm)( Dm 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="sdp [SiSU 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)"; string _generator_home="http://www.sisudoc.org"; string o; o = format(q"¶<!-- SiSU header metadata --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="dc.title" content="%s" /> <meta name="dc.author" content="%s" /> <meta name="dc.publisher" content="%s" /> <meta name="dc.date" content="%s" /> <meta name="dc.date.created" content="%s" /> <meta name="dc.date.issued" content="%syear" /> <meta name="dc.date.available" content="%syear" /> <meta name="dc.date.valid" content="%syear" /> <meta name="dc.date.modified" content="%syear" /> <meta name="dc.language" content="%s" /> <meta name="dc.rights" content="%s" /> <meta name="generator" content="%s" /> <link rel="generator" href="%s" /> <!-- SiSU header metadata -->¶", _title, _author, _publisher, _date, _date_created, _date_issued, _date_available, _date_valid, _date_modified, _language, _rights, _generator, _generator_home, ); return o; } auto site_info_button(Dm)( Dm 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, ("<p class=\"tiny_left\"><a href=\"$2\">$1</a></p>")) .replaceAll( rgx.br_line, "") .replaceAll( rgx.br_nl, ""); } else { _locations = "<p class=\"tiny_left\"><a href=\"http://www.sisudoc.org\">SiSU</a></p>\n<p class=\"tiny_left\"><a href=\"http://www.sisudoc.org\">www.sisudoc.org</a></p>\n<p class=\"tiny_left\"><a href=\"http://git.sisudoc.org/gitweb/\">sources / git</a></p>"; } string o; o = format(q"¶<div class="flex-menu-option"> %s </div>¶", _locations, ); return o; } auto inline_search_form(Dm)( Dm doc_matters, ) { string _action="http://www.sisudoc.org/cgi-bin/search.cgi"; string _db="SiSU.7a.manual"; string o; o = format(q"¶<div class="flex-menu-option"> <a name="search"></a> <form method="get" action="%s" target="_top"> <font size="2"> <input type="text" name="s1" size="24" maxlength="255" /> <input type="hidden" name="db" value="%s" /> <input type="hidden" name="ltd" value="1000" /> <input type="hidden" name="off" value="0" /> <input type="hidden" name="doc" value="live-manual" /><br /> <input type="submit" name="search" value="search doc" /> <input type="submit" name="search" value="search db" /> </font></form> </div>¶", _action, _db, ); return o; } auto html_head(Dm)( Dm doc_matters, string type, ) { string o; o = format(q"¶<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title> %s%s </title> <!-- metadata --> %s <!-- metadata --> <link rel="generator" href="http://www.sisudoc.org/" /> <link rel="shortcut icon" href="%s" /> <link href="%s" rel="stylesheet" /> </head> <body lang="%s"> <a name="top" id="top"></a> <div class='delimit headband'> <div class="flex-menu-bar"> %s <div class="flex-menu-option"> <a href="../../manifest/sisu.en.html" target="_top"> <font face="verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman" size="2"> [ document manifest ] </font> </a> </div> %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") ? "../../../" : "../../") ~ "image/rb7.ico", ((type == "seg") ? "../../../css/html_seg.css" : "../../css/html_scroll.css"), doc_matters.src.language, site_info_button(doc_matters), inline_search_form(doc_matters), ((type == "seg") ? "" : "\n</div>"), ); return o; } auto epub3_seg_head(Dm)( Dm doc_matters, ) { string html_base = format(q"¶<!DOCTYPE html> <html>¶", ); string html_simple = format(q"¶<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">¶", doc_matters.src.language, doc_matters.src.language, ); string html_strict = format(q"¶<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">¶", doc_matters.src.language, doc_matters.src.language, ); string o; o = format(q"¶%s <head> <title> %s%s </title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="dc.title" content="%s" /> <meta name="dc.author" content="%s" /> <meta name="dc.publisher" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> <meta name="dc.date" content="year" /> <meta name="dc.date.created" content="year" /> <meta name="dc.date.issued" content="year" /> <meta name="dc.date.available" content="year" /> <meta name="dc.date.valid" content="year" /> <meta name="dc.date.modified" content="year" /> <meta name="dc.language" content="US" /> <meta name="dc.rights" content="Copyright: Copyright (C) year holder" /> <meta name="generator" content="sdp [SiSU 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)" /> <link rel="generator" href="http://www.sisudoc.org/" /> <link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> <link rel="stylesheet" href="css/epub.css" type="text/css" id="main-css" /> </head> <body lang="%s"> <a name="top" id="top"></a>¶", html_simple, 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, (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : ", " ~ doc_matters.conf_make_meta.meta.creator_author, doc_matters.src.language, ); return o; } auto tail() { string o; o = format(q"¶ </div> <a name="bottom" id="bottom"></a> <a name="end" id="end"></a> </body> </html>¶"); return o; } auto inline_images(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "seg", ) { string _img_pth; if (_xml_type == "epub") { _img_pth = "image/"; } else if (_xml_type == "scroll") { _img_pth = "../../image/"; } else if (_xml_type == "seg") { _img_pth = "../../../image/"; } if (_txt.match(rgx.inline_image)) { _txt = (_txt) .replaceAll( // TODO bug where image dimensions (w or h) not given & consequently set to 0; should not be used (calculate earlier, abstraction) rgx.inline_image, ("$1<img src=\"" ~ _img_pth ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6")); } return _txt; } auto inline_links(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "seg", ) { if (obj.inline_links) { 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"); } _txt = (_txt) .replaceAll( rgx.inline_link_fn_suffix, ("$1" ~ _suffix)) .replaceAll( rgx.inline_link, ("<a href=\"$2\">$1</a>")) .replaceAll( rgx.mark_internal_site_lnk, ""); } debug(markup_links) { if (_txt.match(rgx.inline_link)) { writeln(__LINE__, " (missed) markup link identified (", obj.inline_links, "): ", obj.is_a, ": ", obj.text ); } } debug(markup) { if (_txt.match(rgx.inline_link)) { writeln(__LINE__, " (missed) markup link identified (", obj.inline_links, "): ", obj.is_a, ": ", obj.text ); } } return _txt; } auto inline_notes_scroll(O)( auto return ref const O obj, string _txt, ) { if (obj.inline_notes_reg) { _txt = font_face(_txt); _txt = (_txt).replaceAll( rgx.inline_notes_delimiter_al_regular_number_note, ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") ); } debug(markup_endnotes) { if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text); } } debug(markup) { if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text); } } return _txt; } auto inline_notes_seg(O)( auto return ref const O obj, string _txt, ) { string[] _endnotes; if (obj.inline_notes_reg) { _txt = font_face(_txt); /+ need markup for text, and separated footnote +/ foreach(m; _txt.matchAll(rgx.inline_notes_delimiter_al_regular_number_note)) { _endnotes ~= format( "%s%s%s%s\n %s%s%s%s%s\n %s\n%s", "<p class=\"endnote\">", "<a href=\"#noteref_", m.captures[1], "\">", "<note id=\"note_", m.captures[1], "\"> <sup>", m.captures[1], ".</sup></note></a>", m.captures[2], "</p>" ); } _txt = (_txt).replaceAll( rgx.inline_notes_delimiter_al_regular_number_note, ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") ); } else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { debug(markup) { writeln(__LINE__, " endnote: ", obj.is_a, ": ", obj.text); } } auto t = tuple( _txt, _endnotes, ); return t; } auto inline_markup_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", ) { _txt = inline_images(obj, _txt, _suffix, "scroll"); _txt = inline_links(obj, _txt, _suffix, "scroll"); _txt = inline_notes_scroll(obj, _txt); return _txt; } auto inline_markup_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "seg", ) { _txt = inline_images(obj, _txt, _suffix, _xml_type); _txt = inline_links(obj, _txt, _suffix, _xml_type); auto t = inline_notes_seg(obj, _txt); return t; } string lev4_heading_subtoc(O)( auto return ref const O obj, ) { char[] lev4_subtoc; lev4_subtoc ~= " <div class=\"nav\">\n"; foreach (subtoc; obj.lev4_subtoc) { if (auto m = subtoc.match(rgx.inline_link_subtoc)) { auto indent = m.captures[1].to!string; 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"¶ <p class="minitoc" indent="h%si%s"> <a href="%s">%s</a> </p> ¶", indent, indent, link, text, )); } } lev4_subtoc ~= " </div>\n"; return lev4_subtoc.to!string; } auto nav_pre_next_svg(O)( auto return ref const O obj, ) { string prev, next, toc; if (obj.segment_anchor_tag == "toc") { toc = ""; prev = ""; } else { toc = format(q"¶<a href="toc.html" target="_top"> <div class="toc-button menu"> <svg viewbox="0 0 100 100"> <path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/> </svg> </div> </a>¶", ); } if (obj.segname_prev == "") { prev = ""; } else { prev = format(q"¶<a href="%s.html" target="_top"> <div class="prev-next-button previous"> <svg viewbox="0 0 100 100"> <path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z" transform=" translate(15,0)"> </svg> </div> </a>¶", obj.segname_prev, ); } if (obj.segname_next == "") { next = ""; } else { next = format(q"¶<a href="%s.html" target="_top"> <div class="prev-next-button next"> <svg viewbox="0 0 100 100"> <path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z "transform="translate(85,100) rotate(180) "> </svg> </div> </a>¶", obj.segname_next, ); } string _toc_pre_next = format(q"¶ <div class="flex-menu-option"> <div class="nav-bar"> %s %s %s </div> </div> </div> </div>¶", toc, prev, next, ); string _pre_next = format(q"¶ <div class="flex-menu-option"> <div class="nav-bar"> %s %s </div> </div> </div> </div>¶", prev, next, ); struct bar { string toc_pre_next() { return _toc_pre_next; } string pre_next() { return _pre_next; } } return bar(); } auto heading(O)( auto return ref const O obj, string _txt, string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); string _horizontal_rule = "<hr />"; if ((_xml_type != "html") || (obj.heading_lev_markup == 0 || obj.heading_lev_markup > 4)) { _horizontal_rule = ""; } _txt = font_face(_txt); string o; if (obj.obj_cite_number.empty) { o = format(q"¶%s <div class="substance"> <h%s class="%s">%s %s </h%s> </div>¶", _horizontal_rule, obj.heading_lev_markup, obj.is_a, tags, _txt, obj.heading_lev_markup, ); } else { o = format(q"¶%s <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <h%s class="%s" id="%s"><a name="%s"></a>%s %s </h%s> </div>¶", _horizontal_rule, obj.obj_cite_number, obj.obj_cite_number, obj.heading_lev_markup, obj.is_a, obj.obj_cite_number, obj.obj_cite_number, tags, _txt, obj.heading_lev_markup, ); } return o; } auto heading_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = heading(obj, _txt); return o; } auto heading_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; string o = heading(obj, _txt, _xml_type); auto u = tuple( o, _endnotes, ); return u; } auto para(O)( auto return ref const O obj, string _txt, ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = font_face(_txt); string o; _txt = (obj.bullet) ? ("●  " ~ _txt) : _txt; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s" indent="h%si%s">%s %s </p> </div>¶", obj.is_a, obj.indent_hang, obj.indent_base, tags, _txt ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" indent="h%si%s" id="%s">%s %s </p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.indent_hang, obj.indent_base, obj.obj_cite_number, tags, _txt ); } return o; } auto para_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = para(obj, _txt); return o; } auto para_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = para(obj, _txt); auto u = tuple( o, _endnotes, ); return u; } auto quote(O)( auto return ref const O obj, string _txt, ) { _txt = font_face(_txt); string o; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s"> %s </p> </div>¶", obj.is_a, _txt ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s"> %s </p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, _txt ); } return o; } auto quote_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = quote(obj, _txt); return o; } auto quote_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = quote(obj, _txt); auto u = tuple( o, _endnotes, ); return u; } auto group(O)( auto return ref const O obj, string _txt, ) { _txt = font_face(_txt); string o; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s"> %s </p> </div>¶", obj.is_a, _txt ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s"> %s </p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, _txt ); } return o; } auto group_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = group(obj, _txt); return o; } auto group_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = group(obj, _txt); auto u = tuple( o, _endnotes, ); return u; } auto block(O)( auto return ref const O obj, string _txt, ) { _txt = font_face(_txt); string o; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s">%s</p> </div>¶", obj.is_a, _txt.stripRight ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s">%s</p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, _txt.stripRight ); } return o; } auto block_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = block(obj, _txt); return o; } auto block_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = block(obj, _txt); auto u = tuple( o, _endnotes, ); return u; } auto verse(O)( auto return ref const O obj, string _txt, ) { _txt = font_face(_txt); string o; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s">%s</p> </div>¶", obj.is_a, _txt ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s">%s</p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, _txt ); } return o; } auto verse_scroll(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = inline_markup_scroll(obj, _txt, _suffix); string o = verse(obj, _txt); return o; } auto verse_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", string _xml_type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; string o = verse(obj, _txt); auto u = tuple( o, _endnotes, ); return u; } auto tablarize(O)( auto return ref const O obj, string _txt, ) { 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 ~= "<tr>"; 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 ~= "</" ~ _col_is ~ ">"; } } _table ~= "</tr>"; } auto t = tuple( _table, _tablenote, ); return t; } auto table(O)( auto return ref const O obj, string _txt, ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); _txt = font_face(_txt); auto t = tablarize(obj, _txt); _txt = t[0]; string _note = t[1]; string o; o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s">%s <table summary="normal text css" width="95%%" border="0" bgcolor="white" cellpadding="2" align="center"> %s </table> %s </p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, tags, _txt, _note ); return o; } auto endnote(O)( auto return ref const O obj, string _txt, ) { string o; o = format(q"¶ <p class="%s" indent="h%si%s"> %s </p>¶", obj.is_a, obj.indent_hang, obj.indent_base, _txt ); return o; } auto code(O)( auto return ref const O obj, string _txt, ) { string o; if (obj.obj_cite_number.empty) { o = format(q"¶ <div class="substance"> <p class="%s">%s</p> </div>¶", obj.is_a, _txt ); } else { o = format(q"¶ <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> <p class="%s" id="%s">%s</p> </div>¶", obj.obj_cite_number, obj.obj_cite_number, obj.is_a, obj.obj_cite_number, _txt ); } return o; } } }