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/ao_output_debugs.d | 93 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-) (limited to 'src/sdp/ao_output_debugs.d') diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d index e4eaccb..35e250c 100644 --- a/src/sdp/ao_output_debugs.d +++ b/src/sdp/ao_output_debugs.d @@ -26,7 +26,7 @@ template SiSUoutputDebugs() { ); foreach (key; document_section_keys_sequenced["seg"]) { foreach (obj; contents[key]) { - if (obj.use == "content") { + if (obj.use != "empty") { if (obj.is_a == "heading") { writefln( "%s node: %s heading: %s %s", @@ -48,7 +48,7 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj.use == "content") { + if (obj.use != "empty") { writefln( "[%s][%s]\n%s", obj.obj_cite_number, @@ -58,6 +58,21 @@ template SiSUoutputDebugs() { } } } + void out_segnames(S)( + auto ref const S contents, + string[] keys, + string[] html_segnames, + ) { + foreach (key; keys) { + if (contents[key].length > 1) { + foreach (obj; contents[key]) { + if (obj.heading_lev_markup == 4) { + writeln(obj.ptr_html_segnames, ". (", html_segnames[obj.ptr_html_segnames], ") -> ", obj.text); + } + } + } + } + } void out_toc(S)( auto ref const S contents, string key, @@ -128,6 +143,28 @@ template SiSUoutputDebugs() { key="toc_scroll"; out_toc(contents, key); } + debug(segnames) { + key="toc_scroll"; + writeln(__LINE__); + string[] keys; + keys ~= [ "toc_seg", "body" ]; + if (contents["endnotes_seg"].length > 1) { + keys ~= "endnotes_seg"; + } + if (contents["glossary"].length > 1) { + keys ~= "glossary"; + } + if (contents["bibliography"].length > 1) { + keys ~= "bibliography"; + } + if (contents["bookindex_seg"].length > 1) { + keys ~= "bookindex_seg"; + } + if (contents["blurb"].length > 1) { + keys ~= "blurb"; + } + out_segnames(contents, keys, html_segnames); + } debug(section_body) { key="body"; if (contents[key].length > 1) { @@ -141,6 +178,54 @@ template SiSUoutputDebugs() { } } } + debug(dom) { + enum DomTags { none, open, close, close_and_open, open_still, } + foreach (sect; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[sect]) { + if (obj.is_a == "heading") { + foreach_reverse (k; 0 .. 7) { + switch (obj.dom_markedup[k]) { + case DomTags.close : + writeln(markup.indent_by_spaces_provided(k), ""); + break; + case DomTags.close_and_open : + writeln(markup.indent_by_spaces_provided(k), ""); + writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); + break; + case DomTags.open : + writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); + break; + default : + break; + } + } + } + } + } + writeln("--------------------"); + foreach (sect; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[sect]) { + if (obj.is_a == "heading") { + foreach_reverse (k; 0 .. 7) { + switch (obj.dom_collapsed[k]) { + case DomTags.close : + writeln(markup.indent_by_spaces_provided(k), ""); + break; + case DomTags.close_and_open : + writeln(markup.indent_by_spaces_provided(k), ""); + writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); + break; + case DomTags.open : + writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); + break; + default : + break; + } + } + } + } + } + } debug(section_endnotes) { key="endnotes_seg"; out_endnotes(contents, key); @@ -212,7 +297,7 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj.use == "content") { + if (obj.use != "empty") { writefln( "* [%s][%s] %s", obj.obj_cite_number, @@ -435,7 +520,7 @@ template SiSUoutputDebugs() { debug(checkdoc) { foreach (k; document_section_keys_sequenced["seg"]) { foreach (obj; contents[k]) { - if (obj.use == "content") { + if (obj.use != "empty") { if (!empty(obj.obj_cite_number)) { check["last_obj_cite_number"] = obj.obj_cite_number; } -- cgit v1.2.3