aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/out_sqlite.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/out_sqlite.org')
-rw-r--r--org/out_sqlite.org81
1 files changed, 52 insertions, 29 deletions
diff --git a/org/out_sqlite.org b/org/out_sqlite.org
index 2895b72..a9f1065 100644
--- a/org/out_sqlite.org
+++ b/org/out_sqlite.org
@@ -1268,35 +1268,58 @@ string html_table(M,O)(
string[] _table_cols;
string _table;
string _tablenote;
+ bool _in_head = false;
+ bool _in_body = false;
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>";
+ if ((_table_cols.length == 1)
+ && (_table_rows.length <= row_idx+2)) { // check row_idx+2 (rather than == ++row_idx)
+ _tablenote ~= _table_cols[0];
+ continue;
+ }
+ /+ ↓ a heading row goes in <thead>, the rest in <tbody> +/
+ if (row_idx == 0 && obj.table.heading) {
+ _table ~= "<thead>";
+ _in_head = true;
+ } else if (!_in_body) {
+ if (_in_head) { _table ~= "</thead>"; _in_head = false; }
+ _table ~= "<tbody>";
+ _in_body = true;
+ }
+ _table ~= "<tr>";
+ foreach(col_idx, cell; _table_cols) {
+ bool _is_th = (row_idx == 0 && obj.table.heading);
+ string _col_is = _is_th ? "th" : "td";
+ string _class = (col_idx < obj.table.column_aligns.length
+ && obj.table.column_aligns[col_idx] == "l") ? "left" : "right";
+ _table ~= "<"
+ ~ _col_is
+ ~ (_is_th ? " scope=\"col\"" : "")
+ ~ " class=\""
+ ~ _class
+ ~ "\">";
+ _table ~= cell;
+ _table ~= "</"
+ ~ _col_is
+ ~ ">";
}
+ _table ~= "</tr>";
+ }
+ if (_in_head) { _table ~= "</thead>"; }
+ else if (_in_body) { _table ~= "</tbody>"; }
+ /+ ↓ column widths as a <colgroup>, not a width attribute on every cell +/
+ string _colgroup;
+ if (obj.table.column_widths.length > 0) {
+ string _cols;
+ foreach(w; obj.table.column_widths) {
+ _cols ~= (w > 0)
+ ? "<col style=\"width:" ~ w.to!string ~ "%\" />"
+ : "<col />";
+ }
+ _colgroup = "<colgroup>" ~ _cols ~ "</colgroup>";
+ }
Tuple!(string, string) t = tuple(
- _table,
+ (_colgroup ~ _table),
_tablenote,
);
return t;
@@ -1305,15 +1328,15 @@ string html_table(M,O)(
Tuple!(string, string) t = _tablarize(obj, _txt);
_txt = t[0];
string _note = t[1];
- string o = format(q"┃<p class="%s">
- <table summary="normal text css" width="95%%" border="0" cellpadding="2" align="center">
+ string o = format(q"┃<div class="%s">
+ <table class="table">
%s
</table>
%s
- </p>┃",
+ </div>┃",
obj.metainfo.is_a,
_txt,
- _note
+ (_note.strip.empty) ? "" : ("<p class=\"tablenote\">" ~ _note.strip ~ "</p>")
);
return o;
}