aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/output/xmls.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc_reform/output/xmls.d')
-rw-r--r--src/doc_reform/output/xmls.d60
1 files changed, 42 insertions, 18 deletions
diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d
index 7a1a812..47053f3 100644
--- a/src/doc_reform/output/xmls.d
+++ b/src/doc_reform/output/xmls.d
@@ -89,7 +89,8 @@ template outputXHTMLs() {
.replaceAll(rgx.inline_cite, ("<cite>$1</cite>"));
return _txt;
}
- 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) {
@@ -351,13 +352,28 @@ template outputXHTMLs() {
}
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
+ );
}
}
}
@@ -592,7 +608,9 @@ template outputXHTMLs() {
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)) {
@@ -600,10 +618,16 @@ template outputXHTMLs() {
}
_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>¶",
@@ -611,7 +635,7 @@ template outputXHTMLs() {
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,
);
@@ -619,7 +643,7 @@ template outputXHTMLs() {
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>¶",
@@ -631,7 +655,7 @@ template outputXHTMLs() {
obj.metainfo.object_number,
obj.metainfo.object_number,
tags,
- obj.tags.segment_anchor_tag,
+ heading_lev_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
@@ -644,7 +668,7 @@ template outputXHTMLs() {
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;
@@ -671,7 +695,7 @@ template outputXHTMLs() {
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;
@@ -712,7 +736,7 @@ template outputXHTMLs() {
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;
@@ -772,7 +796,7 @@ template outputXHTMLs() {
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;
@@ -833,7 +857,7 @@ template outputXHTMLs() {
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;
@@ -890,7 +914,7 @@ template outputXHTMLs() {
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;
@@ -947,7 +971,7 @@ template outputXHTMLs() {
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;
@@ -1008,7 +1032,7 @@ template outputXHTMLs() {
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];