From 249e8d2d61f3650d934582b65200ca8fa0b47495 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 29 Dec 2016 20:36:41 -0500 Subject: dom structure, levels marked up & collapsed (use e.g. in epub toc) --- src/sdp/output_html.d | 134 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 38 deletions(-) (limited to 'src/sdp/output_html.d') diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d index 5cd1b26..0390799 100644 --- a/src/sdp/output_html.d +++ b/src/sdp/output_html.d @@ -16,23 +16,38 @@ template SiSUoutputHTML() { ) { auto tags = _html_anchor_tags(obj.anchor_tags); string o; - o = format(q"¶


+ if (obj.obj_cite_number.empty) { + o = format(q"¶


+
+ %s + %s + +
¶", + obj.heading_lev_markup, + obj.is_a, + tags, + obj.text, + obj.heading_lev_markup, + ); + } else { + o = format(q"¶


%s %s
¶", - obj.obj_cite_number, - obj.obj_cite_number, - obj.heading_lev_markup, - obj.is_a, - obj.obj_cite_number, - obj.obj_cite_number, - tags, - obj.text, - obj.heading_lev_markup, - ); + obj.obj_cite_number, + obj.obj_cite_number, + obj.heading_lev_markup, + obj.is_a, + obj.obj_cite_number, + obj.obj_cite_number, + tags, + obj.text, + obj.heading_lev_markup, + ); + } return o; } auto html_para(O)( @@ -42,13 +57,10 @@ template SiSUoutputHTML() { string o; if (obj.obj_cite_number.empty) { o = format(q"¶
-

%s %s

¶", - obj.obj_cite_number, - obj.obj_cite_number, obj.is_a, obj.indent_hang, obj.indent_base, @@ -78,18 +90,29 @@ template SiSUoutputHTML() { auto ref const O obj, ) { string o; - o = format(q"¶
+ if (obj.obj_cite_number.empty) { + o = format(q"¶
+

+ %s +

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

%s

¶", - obj.obj_cite_number, - obj.obj_cite_number, - obj.is_a, - obj.obj_cite_number, - obj.text - ); + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + obj.text + ); + } return o; } auto scroll_head_html() { @@ -99,7 +122,7 @@ template SiSUoutputHTML() { - Title + %s%s @@ -120,7 +143,10 @@ template SiSUoutputHTML() { - ¶"); + ¶", + dochead_meta["title"]["full"], + (dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], + ); return o; } auto html_toc(O)( @@ -175,7 +201,7 @@ template SiSUoutputHTML() { string[] doc; foreach (part; document_section_keys_sequenced["scroll"]) { foreach (obj; contents[part]) { - if (obj.use == "content") { + if (obj.use == "frontmatter") { switch (obj.is_of) { case "para": switch (obj.is_a) { @@ -185,22 +211,23 @@ template SiSUoutputHTML() { case "toc": body_html ~= html_toc(obj); break; - case "para": - body_html ~= html_para(obj); - break; - case "endnote": - body_html ~= html_endnote(obj); - break; - case "glossary": - body_html ~= html_para(obj); - break; - case "bibliography": - body_html ~= html_para(obj); + default: + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); break; - case "bookindex": - body_html ~= html_para(obj); + } + break; + default: + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + break; + } + } else if (obj.use == "body") { + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "heading": + body_html ~= html_heading(obj); break; - case "blurb": + case "para": body_html ~= html_para(obj); break; default: @@ -239,6 +266,37 @@ template SiSUoutputHTML() { writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); break; } + } else if (obj.use == "backmatter") { + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "heading": + body_html ~= html_heading(obj); + break; + case "endnote": + body_html ~= html_endnote(obj); + break; + case "glossary": + body_html ~= html_para(obj); + break; + case "bibliography": + body_html ~= html_para(obj); + break; + case "bookindex": + body_html ~= html_para(obj); + break; + case "blurb": + body_html ~= html_para(obj); + break; + default: + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + break; + } + break; + default: + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + break; + } } } } -- cgit v1.2.3