diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-04-26 10:58:57 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 9d171f94a491efdd68c9557c52914d48ccd33a28 (patch) | |
tree | 5cb50365db213472f52a064da43a9bf081813588 /src/sdp/output_xhtmls.d | |
parent | 0.14.0 reorganized files, and paths (diff) |
xml family css
Diffstat (limited to 'src/sdp/output_xhtmls.d')
-rw-r--r-- | src/sdp/output_xhtmls.d | 757 |
1 files changed, 0 insertions, 757 deletions
diff --git a/src/sdp/output_xhtmls.d b/src/sdp/output_xhtmls.d deleted file mode 100644 index b85123e..0000000 --- a/src/sdp/output_xhtmls.d +++ /dev/null @@ -1,757 +0,0 @@ -template outputXHTMLs() { - private import - std.algorithm, - std.array, - std.container, - std.digest.sha, - std.exception, - std.file, - std.getopt, - std.json, - std.outbuffer, - std.path, - std.process, - std.range, - std.regex, - std.stdio, - std.string, - std.traits, - std.typecons, - std.uni, - std.utf, - std.zip, - std.conv : to; - import - create_zip_file, - defaults, - output_rgx, - output_xhtmls, - paths_output; - mixin SiSUoutputRgxInit; - struct outputXHTMLs { - auto rgx = Rgx(); - string special_characters(string _txt){ - _txt = (_txt) - .replaceAll(rgx.xhtml_ampersand, "&") - .replaceAll(rgx.xhtml_less_than, "<") - .replaceAll(rgx.xhtml_greater_than, ">") - .replaceAll(rgx.xhtml_line_break, "<br />"); - return _txt; - } - string font_face(string _txt){ - _txt = (_txt) - .replaceAll(rgx.inline_emphasis, ("<emph>$1</emph>")) - .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 scroll_head(Me)( - Me dochead_meta, - ) { - debug(asserts) { - static assert(is(typeof(dochead_meta) == string[string][string])); - } - string o; - o = format(q"¶<!DOCTYPE html> - <html> - <head> - <meta charset="utf-8"> - <title> - %s%s - </title> - <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> - <meta name="dc.title" content="Title" /> - <meta name="dc.author" content="Author" /> - <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)" /> - </meta> - <link rel="generator" href="http://www.sisudoc.org/" /> - <link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> - <link href="../../_sisu/css/html.css" rel="stylesheet" /> - <link href="../../../_sisu/css/html.css" rel="stylesheet" /> - </head> - <body lang="en"> - <a name="top" id="top"></a>¶", - dochead_meta["title"]["full"], - (dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], - ); - return o; - } - auto seg_head(Me)( - Me dochead_meta, - ) { - debug(asserts) { - static assert(is(typeof(dochead_meta) == string[string][string])); - } - string o; - o = format(q"¶<!DOCTYPE html> - <html> - <head> - <meta charset="utf-8"> - <title> - %s%s - </title> - <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> - <meta name="dc.title" content="Title" /> - <meta name="dc.author" content="Author" /> - <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)" /> - </meta> - <link rel="generator" href="http://www.sisudoc.org/" /> - <link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> - <link href="../../_sisu/css/html.css" rel="stylesheet" /> - <link href="../../../_sisu/css/html.css" rel="stylesheet" /> - </head> - <body lang="en"> - <a name="top" id="top"></a>¶", - dochead_meta["title"]["full"], - (dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], - ); - return o; - } - auto tail() { - string o; - o = format(q"¶ <a name="bottom" id="bottom"></a> - <a name="end" id="end"></a> - </body> - </html>¶"); - return o; - } - auto inline_links(O)( - auto return ref const O obj, - string _txt, - string _suffix = ".html", - string seg_scroll = "seg", - ) { - if (obj.inline_links) { - if ((seg_scroll == "scroll") - && _txt.match(rgx.mark_internal_site_lnk)) { - _txt = (_txt).replaceAll( - rgx.inline_seg_link, - "$1"); - } - _txt = (_txt).replaceAll( - rgx.inline_link_fn_suffix, - ("$1" ~ _suffix)); - _txt = (_txt).replaceAll( - rgx.inline_link, - ("<a href=\"$2\">$1</a>")); - _txt = (_txt).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 = (_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); - } - } - // if (obj.inline_notes_star) { - // _txt = replaceAll( - // _txt, - // rgx.inline_notes_delimiter_al_regular_number_note, - // ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") - // ); - // } - return _txt; - } - auto inline_notes_seg(O)( - auto return ref const O obj, - string _txt, - ) { - string[] _endnotes; - if (obj.inline_notes_reg) { - /+ 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 _suffix = ".html", - ) { - string _txt = obj.text; - _txt = special_characters(_txt); - _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 _suffix = ".html", - ) { - string _txt = obj.text; - _txt = special_characters(_txt); - _txt = inline_links(obj, _txt, _suffix, "seg"); - auto t = inline_notes_seg(obj, _txt); - return t; - } - auto toc(O)( - auto return ref const O obj, - ) { - string o; - o = format(q"¶ <div class="substance"> - <p class="%s" indent="h%si%s"> - %s - </p> - </div>¶", - obj.is_a, - obj.indent_hang, - obj.indent_base, - obj.text - ); - return o; - } - auto heading(O)( - auto return ref const O obj, - string _txt, - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _horizontal_rule = "<hr />"; - if (obj.heading_lev_markup == 0) { - _horizontal_rule = ""; - } - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = heading(obj, _txt); - return o; - } - auto heading_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = t[0]; - string[] _endnotes = t[1]; - string o = heading(obj, _txt); - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = para(obj, _txt); - return o; - } - auto para_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = to!string(t[0]); - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = quote(obj, _txt); - return o; - } - auto quote_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = to!string(t[0]); - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = group(obj, _txt); - return o; - } - auto group_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = to!string(t[0]); - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = block(obj, _txt); - return o; - } - auto block_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = to!string(t[0]); - string[] _endnotes = t[1]; - string o = block(obj, _txt); - auto u = tuple( - o, - _endnotes, - ); - return u; - } - auto verse(O)( // using code from code block, review - auto return ref const O obj, - string _txt, - ) { - _txt = font_face(_txt); - _txt = (_txt) - .replaceAll(rgx.newline, "<br />\n") - .replaceAll(rgx.two_spaces, " " ~ " " ~ " " ~ " ") - .replaceAll(rgx.nbsp_and_space, " " ~ " ") - .replaceAll(rgx.strip_br, ""); - 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 _suffix = ".html", - ) { - auto tags = _xhtml_anchor_tags(obj.anchor_tags); - string _txt = inline_markup_scroll(obj, _suffix); // issue - string o = verse(obj, _txt); - return o; - } - auto verse_seg(O)( - auto return ref const O obj, - string _suffix = ".html", - ) { - auto t = inline_markup_seg(obj, _suffix); - string _txt = to!string(t[0]); - 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)) { // check row_idx+2 (rather than == ++row_idx) - _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 = obj.text; - 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 o; - o = format(q"¶ <p class="%s" indent="h%si%s"> - %s - </p>¶", - obj.is_a, - obj.indent_hang, - obj.indent_base, - obj.text - ); - return o; - } - auto code(O)( - auto return ref const O obj, - ) { - string _txt = obj.text; - _txt = (_txt) - .replaceAll(rgx.newline, "<br />\n") - .replaceAll(rgx.nbsp_char, " "); - 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; - } - } -} |