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) --- org/output.org | 96 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 24 deletions(-) (limited to 'org/output.org') diff --git a/org/output.org b/org/output.org index eae453a..e9253dc 100644 --- a/org/output.org +++ b/org/output.org @@ -117,23 +117,38 @@ auto html_heading(O)( ) { 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; } #+END_SRC @@ -149,13 +164,10 @@ auto html_para(O)( 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, @@ -191,18 +203,29 @@ auto html_nugget(O)( 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; } #+END_SRC @@ -218,7 +241,7 @@ auto scroll_head_html() { - Title + %s%s @@ -239,7 +262,10 @@ auto scroll_head_html() { -¶"); +¶", +dochead_meta["title"]["full"], +(dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], +); return o; } #+END_SRC @@ -319,7 +345,7 @@ void scroll(C)( string[] doc; foreach (part; document_section_keys_sequenced["scroll"]) { foreach (obj; contents[part]) { - if (obj.use == "body") { + if (obj.use == "frontmatter") { switch (obj.is_of) { case "para": switch (obj.is_a) { @@ -329,6 +355,22 @@ void scroll(C)( case "toc": body_html ~= html_toc(obj); break; + default: + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + break; + } + 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 "para": body_html ~= html_para(obj); break; @@ -402,6 +444,12 @@ void scroll(C)( } } } +#+END_SRC + +**** scroll output file + +#+name: output_html +#+BEGIN_SRC d doc = scroll_head_html ~ body_html ~ scroll_tail_html; auto m = matchFirst(fn_src, rgx.src_fn); auto fn = m["fn_base"] ~ ".html"; -- cgit v1.2.3