From cdaba1c73f0555e1128a7a35addddcfaf715dbde Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 22 Mar 2017 14:54:07 -0400 Subject: 0.13.7 tables ao and html output, poem html output --- src/sdp/output_xhtmls.d | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'src/sdp/output_xhtmls.d') diff --git a/src/sdp/output_xhtmls.d b/src/sdp/output_xhtmls.d index 4ee5a79..971dd95 100644 --- a/src/sdp/output_xhtmls.d +++ b/src/sdp/output_xhtmls.d @@ -419,6 +419,40 @@ template outputXHTMLs() { ); return u; } + auto verse(O)( // using code from code block, review + auto return ref const O obj, + ) { + string _txt = obj.text; + _txt = (_txt) + .replaceAll(rgx.newline, "
\n") + .replaceAll(rgx.two_spaces, " " ~ " " ~ " " ~ " ") + .replaceAll(rgx.nbsp_and_space, " " ~ " "); + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶
+

+ %s +

+
¶", + obj.is_a, + _txt + ); + } else { + o = format(q"¶
+ +

+ %s +

+
¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt + ); + } + return o; + } auto nugget(O)( auto return ref const O obj, ) { @@ -462,6 +496,68 @@ template outputXHTMLs() { ); return o; } + 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 ~= ""; + 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 ~= ""; + } + } + _table ~= ""; + } + 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"¶
+ +

%s + + %s +
+ %s +

+
¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + tags, + _txt, + _note + ); + return o; + } auto code(O)( auto return ref const O obj, ) { -- cgit v1.2.3