aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/output_xmls.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2018-10-07 12:12:33 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-04-10 15:14:15 -0400
commit60f70c541879cccfd379c7f75ed6aff62e793caf (patch)
tree0914c4410eabe2794d901bc95c2c14363724eebb /org/output_xmls.org
parentoutput xmls, work on internal links (diff)
xmls segmented heading inline links
Diffstat (limited to 'org/output_xmls.org')
-rw-r--r--org/output_xmls.org94
1 files changed, 59 insertions, 35 deletions
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 = "<hr />";
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)
+ ? ""
+ : "<a name=\"" ~ obj.tags.segment_anchor_tag ~ "\"></a>";
+ heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty)
+ ? ""
+ : "<a name=\"" ~ obj.tags.heading_lev_anchor_tag ~ "\"></a>";
if (obj.metainfo.object_number.empty) {
o = format(q"¶%s
<div class="substance">
- <h%s class="%s">%s<a name="%s"></a>
+ <h%s class="%s">%s%s
%s
</h%s>
</div>¶",
@@ -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
<div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <h%s class="%s" id="%s"><a name="%s"></a>%s<a name="%s"></a>
+ <h%s class="%s" id="%s"><a name="%s"></a>%s%s
%s
</h%s>
</div>¶",
@@ -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) ? ("●&#160;&#160;" ~ _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), " ") ~ "<li>" ~ "\n"
~ markup.indent_by_spaces_provided((n + 2), " ")
- ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ "\">"
+ ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ "\">"
~ _txt
~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n"
~ markup.indent_by_spaces_provided((n + 2), " ")
- ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">"
+ ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ hashtag ~ "\">"
~ _txt
~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n"
~ markup.indent_by_spaces_provided((n + 2), " ")
- ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ "\">"
+ ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ "\">"
~ _txt
~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n"
~ markup.indent_by_spaces_provided((n + 2), " ")
- ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">"
+ ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ hashtag ~ "\">"
~ _txt
~ "</a>" ~ "\n";
}
@@ -2225,7 +2249,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) {
<content src="%s.xhtml%s" />¶",
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) {
<content src="%s.xhtml%s" />¶",
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"¶ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" />
¶",
- 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"¶ <itemref idref="%s.xhtml" linear="yes" />
¶",
- obj.tags.segment_anchor_tag,
+ obj.tags.segment_anchor_tag_is,
);
oepbs_content_parts["guide"] ~=
format(q"¶ <reference type="%s" href="%s" />
¶",
- 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"¶ <item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" />
¶",
- 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"¶ <itemref idref="%s.xhtml#%s" linear="yes" />
¶",
- obj.tags.segment_anchor_tag,
+ obj.tags.segment_anchor_tag_is,
obj.metainfo.object_number,
);
oepbs_content_parts["guide"] ~=
format(q"¶ <reference type="%s#%s" href="%s#%s" />
¶",
- 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,
);
}