From 60f70c541879cccfd379c7f75ed6aff62e793caf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Oct 2018 12:12:33 -0400 Subject: xmls segmented heading inline links --- org/output_xmls.org | 94 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 35 deletions(-) (limited to 'org/output_xmls.org') diff --git a/org/output_xmls.org b/org/output_xmls.org index 441ed95..cb7830a 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -153,7 +153,8 @@ string font_face(string _txt){ #+name: xhtml_format_objects #+BEGIN_SRC d -string _xhtml_anchor_tags(const(string[]) anchor_tags) { +string _xhtml_anchor_tags(O)(O obj) { + const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { foreach (tag; anchor_tags) { @@ -466,13 +467,28 @@ auto inline_links(M,O)( } if (_xml_type == "seg" || _xml_type == "epub") { if (auto m = _txt.match(rgx.inline_link_hash)) { - foreach (segname; doc_matters.xml.segnames) { - if (auto n = segname.match(m.captures[3])) { + if (m.captures[3] in doc_matters.xml.tag_associations) { + if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, - "┥$1┝┤$3" ~ _suffix ~ "├"); - break; + "┥$1┝┤$3" ~ _suffix ~ "├" + ); + } else { + _txt = _txt.replaceFirst( + rgx.inline_link_hash, + "┥$1┝┤" + ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ _suffix + ~ "#" ~ "$3" + ~ "├" + ); } + } else { + writeln( + "WARNING on internal document links, anchor to link not found in document, " + ~ "anchor: " ~ m.captures[3] + ~ " document: " ~ doc_matters.src.filename + ); } } } @@ -753,7 +769,9 @@ auto heading(M,O)( string _txt, string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); + string seg_anchor_tag; + string heading_lev_anchor_tag; string _horizontal_rule = "
"; if ((_xml_type != "html") || (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) { @@ -761,10 +779,16 @@ auto heading(M,O)( } _txt = font_face(_txt); string o; + seg_anchor_tag = (obj.tags.segment_anchor_tag.empty) + ? "" + : ""; + heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) + ? "" + : ""; if (obj.metainfo.object_number.empty) { o = format(q"¶%s
- %s + %s%s %s
¶", @@ -772,7 +796,7 @@ auto heading(M,O)( obj.metainfo.heading_lev_markup, obj.metainfo.is_a, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -780,7 +804,7 @@ auto heading(M,O)( o = format(q"¶%s
- %s + %s%s %s
¶", @@ -792,7 +816,7 @@ auto heading(M,O)( obj.metainfo.object_number, obj.metainfo.object_number, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -811,7 +835,7 @@ auto heading_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = heading(doc_matters, obj, _txt); return o; @@ -851,7 +875,7 @@ auto para(M,O)( const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); string o; _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; @@ -898,7 +922,7 @@ auto para_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = para(doc_matters, obj, _txt); return o; @@ -977,7 +1001,7 @@ auto quote_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = quote(doc_matters, obj, _txt); return o; @@ -1057,7 +1081,7 @@ auto group_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = group(doc_matters, obj, _txt); return o; @@ -1133,7 +1157,7 @@ auto block_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = block(doc_matters, obj, _txt); return o; @@ -1209,7 +1233,7 @@ auto verse_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = verse(doc_matters, obj, _txt); return o; @@ -1330,7 +1354,7 @@ auto table(M,O)( const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); auto t = tablarize(doc_matters, obj, _txt); _txt = t[0]; @@ -1933,7 +1957,7 @@ template outputEPub3() { #+END_SRC ** special (epub) files :format: -*** DONE static +*** static **** _identify doc filetype_ (mimetype) [static] - mimetype file indicating that zip file contains an EPUB @@ -2114,7 +2138,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -2123,7 +2147,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -2133,7 +2157,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -2142,7 +2166,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -2225,7 +2249,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -2239,7 +2263,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -2481,41 +2505,41 @@ void outputEPub3(D,I)( oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); } else if (obj.metainfo.heading_lev_markup > 4) { oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); } -- cgit v1.2.3