aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2022-02-04 23:50:19 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2022-02-05 18:26:02 -0500
commit94f56fab73553aae75a9e92a7707c952c1e763fc (patch)
treeb42a58993bf3e4d0ee82cbbdb347b033aa38d8b2 /org
parentepub, work on (diff)
epub, navigation
Diffstat (limited to 'org')
-rw-r--r--org/out_xmls.org58
1 files changed, 34 insertions, 24 deletions
diff --git a/org/out_xmls.org b/org/out_xmls.org
index 0e9bafe..a113832 100644
--- a/org/out_xmls.org
+++ b/org/out_xmls.org
@@ -160,6 +160,7 @@ import
.replaceAll(rgx.xhtml_less_than, "&lt;") // "&#60;"
.replaceAll(rgx.xhtml_greater_than, "&gt;") // "&#62;"
.replaceAll(rgx.br_line, "<br />")
+ .replaceAll(rgx.br_newline_inline, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@@ -2519,6 +2520,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
auto markup = InlineMarkup();
static auto rgx = RgxO();
string toc;
+ bool _new_title_set = false;
string toc_head = format(q"┃<html xmlns="https://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
@@ -2530,7 +2532,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<h1>Contents</h1>
</header>
<nav epub:type="toc" id="toc">
- <li>┃",
+┃",
(doc_matters.conf_make_meta.meta.title_full).special_characters_text,
);
string _toc_nav_tail = "";
@@ -2538,17 +2540,9 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
foreach (sect; doc_matters.has.keys_seq.seg) {
foreach (obj; doc_abstraction[sect]) {
if ((sect == "head") && (obj.metainfo.is_a == "heading")) {
- toc = format(q"┃%s
- <a href="_the_title.xhtml">%s</a>
- </li>
-┃",
- toc_head,
- obj.text
- .replaceAll(rgx.inline_notes_al_gen, "")
- .replaceAll(rgx.br_newline_inline, "<br />")
- .strip,
- );
- } else if (sect == "tail") { // skip
+ toc = toc_head;
+ }
+ if (sect == "tail") { // skip
} else if ((sect != "tail") && (obj.metainfo.is_a == "heading")) {
string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip;
foreach_reverse (n; 0 .. 7) {
@@ -2564,23 +2558,39 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n";
goto default;
case DomTags.open :
- toc ~= markup.indent_by_spaces_provided(n, " ") ~ "<ol>" ~ "\n";
+ if (!(_new_title_set)) {
+ toc ~= markup.indent_by_spaces_provided(n, " ") ~ "<ol>" ~ "\n";
+ }
goto default;
default :
if ((obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.close_and_open ||
obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.open
)) {
- string _hashtag = "";
- if ((obj.metainfo.heading_lev_markup <= 4) && (obj.metainfo.ocn == 0)) {
- _hashtag = "#" ~ obj.metainfo.ocn.to!string;
+ if ((sect == "head") && (obj.metainfo.is_a == "heading")) {
+ toc ~= format(q"┃ <li>
+ <a href="_the_title.xhtml">%s</a>
+ </li>┃",
+ obj.text
+ .replaceAll(rgx.inline_notes_al_gen, "")
+ .replaceAll(rgx.br_newline_inline, "<br />")
+ .strip,
+ );
+ toc ~= "\n";
+ _new_title_set = true;
+ } else {
+ _new_title_set = false;
+ string _hashtag = "";
+ if ((obj.metainfo.heading_lev_markup <= 4) && (obj.metainfo.ocn == 0)) {
+ _hashtag = "#" ~ obj.metainfo.ocn.to!string;
+ }
+ string _href = "<a href=\""
+ ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml"
+ ~ _hashtag
+ ~ "\">";
+ toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n"
+ ~ markup.indent_by_spaces_provided((n + 2), " ")
+ ~ _href ~ _txt.special_characters_text ~ "</a>" ~ "\n";
}
- string _href = "<a href=\""
- ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml"
- ~ _hashtag
- ~ "\">";
- toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n"
- ~ markup.indent_by_spaces_provided((n + 2), " ")
- ~ _href ~ _txt.special_characters_text ~ "</a>" ~ "\n";
}
break;
}
@@ -2597,8 +2607,8 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
// case DomTags.open: case DomTags.close_and_open: case DomTags.open_still:
if (n != 0) {
_toc_nav_tail ~= " " ~ markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n";
+ _toc_nav_tail ~= " " ~ markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n";
}
- _toc_nav_tail ~= " " ~ markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n";
break;
default :
break;