diff options
-rw-r--r-- | org/out_xmls.org | 58 | ||||
-rw-r--r-- | src/doc_reform/io_out/epub3.d | 58 | ||||
-rw-r--r-- | src/doc_reform/io_out/xmls.d | 1 |
3 files changed, 69 insertions, 48 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, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" .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; diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index a49304f..efdf12c 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -71,6 +71,7 @@ template outputEPub3() { .replaceAll(rgx.xhtml_less_than, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" .replaceAll(rgx.br_line, "<br />") + .replaceAll(rgx.br_newline_inline, "<br />") .replaceAll(rgx.nbsp_char, " "); return _txt; } @@ -183,6 +184,7 @@ template outputEPub3() { 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> @@ -194,7 +196,7 @@ template outputEPub3() { <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 = ""; @@ -202,17 +204,9 @@ template outputEPub3() { 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) { @@ -228,23 +222,39 @@ template outputEPub3() { 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; } @@ -261,8 +271,8 @@ template outputEPub3() { // 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; diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 6191fa9..fd9305a 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -100,6 +100,7 @@ template outputXHTMLs() { .replaceAll(rgx.xhtml_less_than, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" .replaceAll(rgx.br_line, "<br />") + .replaceAll(rgx.br_newline_inline, "<br />") .replaceAll(rgx.nbsp_char, " "); return _txt; } |