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 --- org/output.org | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 129 insertions(+), 6 deletions(-) (limited to 'org/output.org') diff --git a/org/output.org b/org/output.org index 657b32f..1b2ee5f 100644 --- a/org/output.org +++ b/org/output.org @@ -776,6 +776,46 @@ auto para_seg(O)( } #+END_SRC +**** poem verse + +#+name: xhtml_format_objects +#+BEGIN_SRC d +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; +} +#+END_SRC + **** nugget #+name: xhtml_format_objects @@ -831,6 +871,90 @@ auto endnote(O)( } #+END_SRC +**** table + +***** TODO tablarize + +align="left|right|center" +$100 + +"style=\"text-align:right\"" +"style=\"text-align:left\"" + +"style=\"text-align:" ~ "right\"" + +#+name: xhtml_format_objects +#+BEGIN_SRC d +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; +} +#+END_SRC + +***** table + +#+name: xhtml_format_objects +#+BEGIN_SRC d +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; +} +#+END_SRC + **** code #+name: xhtml_format_objects_code @@ -948,7 +1072,7 @@ void scroll(D,I)( case "poem": break; case "verse": - doc_html ~= xhtml_format.nugget(obj); + doc_html ~= xhtml_format.verse(obj); break; case "group": doc_html ~= xhtml_format.nugget(obj); @@ -960,7 +1084,7 @@ void scroll(D,I)( doc_html ~= xhtml_format.nugget(obj); break; case "table": - doc_html ~= xhtml_format.para_scroll(obj, suffix); + doc_html ~= xhtml_format.table(obj); break; case "code": doc_html ~= xhtml_format.code(obj); @@ -1182,7 +1306,7 @@ void seg(D,I)( case "poem": break; case "verse": - doc_html[segment_filename] ~= xhtml_format.nugget(obj); + doc_html[segment_filename] ~= xhtml_format.verse(obj); break; case "group": doc_html[segment_filename] ~= xhtml_format.nugget(obj); @@ -1194,9 +1318,8 @@ void seg(D,I)( doc_html[segment_filename] ~= xhtml_format.nugget(obj); break; case "table": - auto t = xhtml_format.para_seg(obj, suffix); - doc_html[segment_filename] ~= t[0]; - doc_html_endnotes[segment_filename] ~= t[1]; + doc_html[segment_filename] ~= xhtml_format.table(obj); + doc_html_endnotes[segment_filename] ~= ""; break; case "code": doc_html[segment_filename] ~= xhtml_format.code(obj); -- cgit v1.2.3