From c37eb0768635a42686ea986343ff95ae03f08c1d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 30 Oct 2018 11:46:44 -0400 Subject: 0.3.0 internal links, anchor tags & segment associations --- src/doc_reform/output/xmls.d | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/doc_reform/output/xmls.d') diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index bc93271..6154010 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -25,16 +25,10 @@ template outputXHTMLs() { case "head": delimit_ ~= "\n
\n" ; break; - case "toc_seg": + case "toc": delimit_ ~= "\n
\n" ; break; - case "toc_scroll": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_seg": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_scroll": + case "bookindex": delimit_ ~= "\n
\n" ; break; default: @@ -343,6 +337,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "seg", ) { + string seg_lvs; if (obj.has.inline_links) { if ((_txt.match(rgx.mark_internal_site_lnk)) && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault @@ -351,9 +346,13 @@ template outputXHTMLs() { "$1"); } if (_xml_type == "seg" || _xml_type == "epub") { + seg_lvs = (_xml_type == "epub") ? "seg_lv1_to_4" : "seg_lv4"; foreach (m; _txt.match(rgx.inline_link_hash)) { if (m.captures[3] in doc_matters.xml.tag_associations) { - if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { + if ( + m.captures[3] + == doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤$3" ~ _suffix ~ "├" @@ -362,7 +361,7 @@ template outputXHTMLs() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" @@ -370,7 +369,9 @@ template outputXHTMLs() { } } else { writeln( - "WARNING on internal document links, anchor to link not found in document, " + "WARNING on internal document links, anchor to link <<" + ~ m.captures[3] + ~ ">> not found in document, " ~ "anchor: " ~ m.captures[3] ~ " document: " ~ doc_matters.src.filename ); -- cgit v1.2.3