aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2022-02-04 18:48:25 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2022-02-05 18:26:02 -0500
commit30b6d716f3e4448667ee61bdda044df739d6ad68 (patch)
tree8cbe98e04605f388bc52cb368198833121cf1f8a
parentcodegen cgi search removed (using src in org-mode) (diff)
epub, work on
-rw-r--r--org/default_misc.org2
-rw-r--r--org/default_regex.org3
-rw-r--r--org/metaverse.org12
-rw-r--r--org/out_xmls.org183
-rw-r--r--src/doc_reform/io_out/defaults.d2
-rw-r--r--src/doc_reform/io_out/epub3.d156
-rw-r--r--src/doc_reform/io_out/rgx.d2
-rw-r--r--src/doc_reform/io_out/xmls.d20
-rw-r--r--src/doc_reform/meta/defaults.d2
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d12
-rw-r--r--src/doc_reform/meta/rgx.d3
11 files changed, 77 insertions, 320 deletions
diff --git a/org/default_misc.org b/org/default_misc.org
index 5c71dee..429e13a 100644
--- a/org/default_misc.org
+++ b/org/default_misc.org
@@ -237,7 +237,7 @@ template InternalMarkup() {
string mark_internal_site_lnk = "¤";
string nbsp = "░";
string br_line = "┘";
- string br_nl = "┙";
+ string br_newline_inline = "┙";
string br_paragraph = "┚";
string br_obj = "break_obj";
string br_page_line = "┼";
diff --git a/org/default_regex.org b/org/default_regex.org
index 6734b62..636d767 100644
--- a/org/default_regex.org
+++ b/org/default_regex.org
@@ -105,6 +105,7 @@ static trailing_linebreak = ctRegex!(",[ ]{1,2}\\\\\
static newline_eol_delimiter = ctRegex!("\n");
static newline_eol_strip_preceding = ctRegex!("[ ]*\n");
static newline_eol_delimiter_only = ctRegex!("^\n");
+static markup_inline_linebreak = ctRegex!(`\s*\\\\s*`, "m");
static line_delimiter_ws_strip = ctRegex!("[ ]*\n[ ]*");
static para_delimiter = ctRegex!("\n[ ]*\n+");
static table_col_delimiter = ctRegex!("[ ]*\n+", "mg");
@@ -526,7 +527,7 @@ static src_formalised_file_path_parts = ctRegex!(`(?P<pth>(?:[/a
static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg");
static br_newlines_linebreaks = ctRegex!(`[\n┘┙]`, "mg");
static br_line = ctRegex!(`┘`, "mg");
-static br_nl = ctRegex!(`┙`, "mg");
+static br_newline_inline = ctRegex!(`┙`, "mg");
#+END_SRC
*** inline (internal program) markup footnotes endnotes :inline:footnote:
diff --git a/org/metaverse.org b/org/metaverse.org
index b97bd2f..a3896c2 100644
--- a/org/metaverse.org
+++ b/org/metaverse.org
@@ -5170,11 +5170,11 @@ if (pith["block_is"] == eN.blk_is.quote) {
an_object[an_object_key] = an_object[an_object_key]
.replaceFirst(rgx.variable_doc_title_author_date,
(conf_make_meta.meta.title_full
- ~ mkup.br_nl
+ ~ mkup.br_newline_inline
~ conf_make_meta.meta.creator_author
~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"))
.replaceFirst(rgx.variable_doc_title,
- (conf_make_meta.meta.title_full ~ mkup.br_nl))
+ (conf_make_meta.meta.title_full ~ mkup.br_newline_inline))
.replaceFirst(rgx.variable_doc_author,
conf_make_meta.meta.creator_author)
.replaceFirst(rgx.variable_doc_date,
@@ -5185,10 +5185,10 @@ if (pith["block_is"] == eN.blk_is.quote) {
an_object[an_object_key] = an_object[an_object_key]
.replaceFirst(rgx.variable_doc_title_author_date,
(conf_make_meta.meta.title_full
- ~ mkup.br_nl
+ ~ mkup.br_newline_inline
~ conf_make_meta.meta.creator_author))
.replaceFirst(rgx.variable_doc_title,
- (conf_make_meta.meta.title_full ~ mkup.br_nl))
+ (conf_make_meta.meta.title_full ~ mkup.br_newline_inline))
.replaceFirst(rgx.variable_doc_author,
conf_make_meta.meta.creator_author);
} else if (an_object[an_object_key].match(rgx.variable_doc_title)) {
@@ -5893,6 +5893,7 @@ invariant() {
obj_txt["munge"] = obj_txt_in
.replaceFirst(rgx.headings, "")
.replaceFirst(rgx.object_number_off_all, "")
+ .replaceFirst(rgx.markup_inline_linebreak, mkup.br_newline_inline)
.strip;
TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers);
debug(munge) {
@@ -5923,7 +5924,8 @@ invariant() {
@safe auto munge_para()(string obj_txt_in) {
obj_txt["munge"] = (obj_txt_in)
.replaceFirst(rgx.para_attribs, "")
- .replaceFirst(rgx.object_number_off_all, "");
+ .replaceFirst(rgx.object_number_off_all, "")
+ .replaceFirst(rgx.markup_inline_linebreak, mkup.br_newline_inline);
TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]);
debug(munge) {
writeln(__LINE__);
diff --git a/org/out_xmls.org b/org/out_xmls.org
index 84c15db..0e9bafe 100644
--- a/org/out_xmls.org
+++ b/org/out_xmls.org
@@ -159,8 +159,7 @@ import
.replaceAll(rgx.xhtml_quotation, "&quot;") // "&#34;"
.replaceAll(rgx.xhtml_less_than, "&lt;") // "&#60;"
.replaceAll(rgx.xhtml_greater_than, "&gt;") // "&#62;"
- .replaceAll(rgx.br_line, "<br>")
- .replaceAll(rgx.br_nl, "<br>")
+ .replaceAll(rgx.br_line, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@@ -173,8 +172,7 @@ import
@safe string special_characters_date(string _txt) {
_txt = _txt
.replaceAll(regex(r"(?:-00)+"), "")
- .replaceAll(rgx.br_line, "<br>")
- .replaceAll(rgx.br_nl, "<br>")
+ .replaceAll(rgx.br_line, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@@ -334,7 +332,7 @@ import
.replaceAll(
rgx.br_line, "")
.replaceAll(
- rgx.br_nl, "");
+ rgx.br_newline_inline, "");
} else {
_locations = "<p class=\"tiny_left\"><a href=\"https://www.doc-reform.org\">spine</a></p>\n<p class=\"tiny_left\"><a href=\"https://git.sisudoc.org/software/spine/\">sources / git</a></p>\n<p class=\"tiny_left\"><a href=\"https://www.sisudoc.org\">www.sisudoc.org</a></p>";
}
@@ -999,14 +997,16 @@ import
(doc_matters.opt.action.ocn_off)
? "" : ((obj.metainfo.object_number.empty)
? "" : obj.metainfo.identifier),
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
obj.metainfo.is_a,
obj.metainfo.identifier,
obj.metainfo.identifier,
tags,
heading_lev_anchor_tag,
_txt,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
);
} else {
o = format(q"┃%s
@@ -1016,12 +1016,14 @@ import
</h%s>
</div>┃",
_horizontal_rule,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
obj.metainfo.is_a,
tags,
heading_lev_anchor_tag,
_txt,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
);
}
return o;
@@ -2349,7 +2351,6 @@ template outputEPub3() {
<<output_epub3_fixed_container_xml>>
<<output_epub3_constructs_oebps_content>>
<<output_epub3_constructs_oebps_toc_nav_xhtml>>
- <<output_epub3_constructs_oebps_toc_ncx>>
<<output_epub3_xhtml_seg_output>>
<<output_epub3_xhtml_seg_output_loop>>
<<output_epub3_xhtml_seg_object_is_heading>>
@@ -2440,8 +2441,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<dc:identifier id="bookid">urn:uuid:%s</dc:identifier>
</metadata>
<manifest>
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
- <link rel="stylesheet" href="%s" type="text/css" id="main-css" />
+ <item id="css" href="%s" media-type="text/css"/>
<item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
┃",
_uuid,
@@ -2473,7 +2473,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
);
}
content ~= " " ~ "</manifest>" ~ "\n ";
- content ~= " " ~ "<spine toc=\"ncx\">" ~ "\n ";
+ content ~= " " ~ "<spine>" ~ "\n ";
content ~= parts["spine"];
content ~= " " ~ "</spine>" ~ "\n ";
content ~= " " ~ "<guide>" ~ "\n ";
@@ -2530,7 +2530,6 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<h1>Contents</h1>
</header>
<nav epub:type="toc" id="toc">
- <ol>
<li>┃",
(doc_matters.conf_make_meta.meta.title_full).special_characters_text,
);
@@ -2544,7 +2543,10 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
</li>
┃",
toc_head,
- obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip,
+ obj.text
+ .replaceAll(rgx.inline_notes_al_gen, "")
+ .replaceAll(rgx.br_newline_inline, "<br />")
+ .strip,
);
} else if (sect == "tail") { // skip
} else if ((sect != "tail") && (obj.metainfo.is_a == "heading")) {
@@ -2602,7 +2604,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
break;
}
if (n == 0) {
- _toc_nav_tail ~="</nav>
+ _toc_nav_tail ~=" </nav>
</section>
</body>
</html>\n";
@@ -2617,124 +2619,6 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
}
#+END_SRC
-**** TODO _doc navigation epub2_ (OEBPS/toc.ncx) navigable toc using Dom structure
-
-- toc.ncx (epub2 navigation document)
- - (replaced in epub3 by a declared xhtml nav file, in our case toc_nav.xhtml)
-
-#+NAME: output_epub3_constructs_oebps_toc_ncx
-#+BEGIN_SRC d
-@safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) {
- int counter_play_order = 0;
- string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere
- auto markup = InlineMarkup();
- static auto rgx = RgxO();
- enum DomTags { none, open, close, close_and_open, open_still, }
- string toc;
- string toc_ = format(q"┃<?xml version="1.0" encoding="utf-8"?>
-<ncx xmlns="https://www.daisy.org/z3986/2005/ncx/" version="2005-1">
-<head>
- <!-- four required metadata items (for all NCX documents,
- (including the relaxed constraints of OPS 2.0) -->
- <title>%s%s</title>
- <link rel="stylesheet" href="Styles/epub.css" type="text/css" id="main-css" />
- <meta name="dtb:uid" content="urn:uuid:%s" />
- <meta name="dtb:depth" content="%s" />
- <meta name="dtb:totalPageCount" content="0" />
- <meta name="dtb:maxPageNumber" content="0" />
-</head>
-<docTitle>
- <text>%s</text>
-</docTitle>
-<docAuthor>
- <text>%s</text>
-</docAuthor>
-<navMap>┃",
- (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title
- (doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
- : " by " ~ (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author
- _uuid, // uuid
- "3", // content depth
- (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title
- (doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
- : (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author
- );
- string _toc_ncx_tail = "";
- foreach (sect; doc_matters.has.keys_seq.seg) {
- foreach (obj; doc_abstraction[sect]) {
- if (sect == "head") { toc = toc_;
- }
- if (obj.metainfo.is_a == "heading") {
- string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip.special_characters_text;
- // writeln(_txt, " --- ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG line
- string hashtag = (obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string);
- foreach_reverse (k; 0 .. 7) {
- switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) { // for epub may need to construct for levels 1 to 4 only
- case DomTags.close :
- if (sect != "head") {
- toc ~= "\n </navPoint>"; // issue at start of some documents
- }
- break;
- case DomTags.close_and_open :
- toc ~= "\n </navPoint>";
- goto default;
- case DomTags.open :
- goto default;
- default :
- string _toc;
- if ((obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open
- || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open
- // || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open_still
- )) {
- ++counter_play_order;
- _toc = format(q"┃
- <navPoint class="chapter" id="navpoint" playOrder="%s">
- <navLabel>
- <text>%s</text>
- </navLabel>
- <content src="%s.xhtml%s" />┃",
- counter_play_order,
- _txt,
- obj.tags.segment_anchor_tag_epub,
- hashtag,
- );
- }
- if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open) {
- toc ~= _toc;
- } else if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open) {
- toc ~= _toc;
- }
- break;
- }
- if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) {
- if (k == 6) {_toc_ncx_tail = "";}
- switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) {
- case 0: case 2:
- // case DomTags.none: case DomTags.close:
- break;
- case 1: case 3: case 4:
- // case DomTags.open: case DomTags.close_and_open: case DomTags.open_still:
- if (k != 0) {
- }
- _toc_ncx_tail ~= " " ~ markup.indent_by_spaces_provided(k, " ") ~ "</navPoint>" ~ "\n";
- break;
- default :
- break;
- }
- if (k == 0) {
- _toc_ncx_tail ~= format(q"┃ </navMap>
-</ncx>┃");
- }
- }
- }
- }
- }
- }
- toc ~= _toc_ncx_tail;
- return toc;
-}
-#+END_SRC
-
** the document contents :seg:
*** ↻ loop & switch (sections & objects) format epub3 xhtml output
@@ -2756,7 +2640,6 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
/+ fixed output +/
string mimetypes;
string meta_inf_container_xml;
- string oebps_toc_ncx;
string oebps_toc_nav_xhtml;
/+ variable output +/
string oebps_content_opf;
@@ -3052,25 +2935,25 @@ if (obj.metainfo.is_a == "heading") {
assert(obj.text.length > 0);
if (obj.metainfo.heading_lev_markup <= 4) {
oepbs_content_parts["manifest_documents"] ~=
- format(q"┃ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" />
+ format(q"┃<item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.tags.segment_anchor_tag_epub,
);
oepbs_content_parts["spine"] ~=
- format(q"┃ <itemref idref="%s.xhtml" linear="yes" />
+ format(q"┃<itemref idref="%s.xhtml" linear="yes" />
┃",
obj.tags.segment_anchor_tag_epub,
);
oepbs_content_parts["guide"] ~=
- format(q"┃ <reference type="%s" href="%s" />
+ format(q"┃<reference type="%s" href="%s" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.tags.segment_anchor_tag_epub,
);
} 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" />
+ format(q"┃<item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
@@ -3078,13 +2961,13 @@ if (obj.metainfo.is_a == "heading") {
obj.metainfo.object_number,
);
oepbs_content_parts["spine"] ~=
- format(q"┃ <itemref idref="%s.xhtml#%s" linear="yes" />
+ format(q"┃<itemref idref="%s.xhtml#%s" linear="yes" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
);
oepbs_content_parts["guide"] ~=
- format(q"┃ <reference type="%s#%s" href="%s#%s" />
+ format(q"┃<reference type="%s#%s" href="%s#%s" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
@@ -3102,11 +2985,10 @@ if (obj.metainfo.is_a == "heading") {
}
}
/+ epub specific documents +/
- epubWrite.mimetypes = epub3_mimetypes;
+ epubWrite.mimetypes = epub3_mimetypes;
epubWrite.meta_inf_container_xml = epub3_container_xml;
- epubWrite.oebps_toc_ncx = doc_abstraction.epub2_oebps_toc_ncx(doc_matters);
- epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters);
- epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts);
+ epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters);
+ epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts);
epubWrite.epub3_write_output_files(doc_matters);
}
#+END_SRC
@@ -3127,7 +3009,6 @@ zip -0 file.epub mimetype && zip -r -9 file.epub META-INF OEBPS
static assert(is(typeof(epub_write.mimetypes) == string));
static assert(is(typeof(epub_write.meta_inf_container_xml) == string));
static assert(is(typeof(epub_write.oebps_toc_nav_xhtml) == string));
- static assert(is(typeof(epub_write.oebps_toc_ncx) == string));
static assert(is(typeof(epub_write.oebps_content_opf) == string));
}
static auto rgx = RgxO();
@@ -3234,16 +3115,6 @@ zip -0 file.epub mimetype && zip -r -9 file.epub META-INF OEBPS
fn = pth_epub3.fn_oebps_toc_nav_xhtml;
EPUBzip(epub_write.oebps_toc_nav_xhtml, fn);
}
- { /+ OEBPS/toc.ncx (navigation toc epub2) +/
- { /+ debug +/
- if (doc_matters.opt.action.debug_do) {
- fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename);
- File(fn_dbg, "w").writeln(epub_write.oebps_toc_ncx);
- }
- }
- fn = pth_epub3.fn_oebps_toc_ncx;
- EPUBzip(epub_write.oebps_toc_ncx, fn);
- }
{ /+ OEBPS/content.opf (doc manifest) +/
{ /+ debug +/
if (doc_matters.opt.action.debug_do) {
diff --git a/src/doc_reform/io_out/defaults.d b/src/doc_reform/io_out/defaults.d
index aedbbc1..6839c92 100644
--- a/src/doc_reform/io_out/defaults.d
+++ b/src/doc_reform/io_out/defaults.d
@@ -73,7 +73,7 @@ template InternalMarkup() {
string mark_internal_site_lnk = "¤";
string nbsp = "░";
string br_line = "┘";
- string br_nl = "┙";
+ string br_newline_inline = "┙";
string br_paragraph = "┚";
string br_obj = "break_obj";
string br_page_line = "┼";
diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d
index 6593db5..a49304f 100644
--- a/src/doc_reform/io_out/epub3.d
+++ b/src/doc_reform/io_out/epub3.d
@@ -70,8 +70,7 @@ template outputEPub3() {
.replaceAll(rgx.xhtml_quotation, "&quot;") // "&#34;"
.replaceAll(rgx.xhtml_less_than, "&lt;") // "&#60;"
.replaceAll(rgx.xhtml_greater_than, "&gt;") // "&#62;"
- .replaceAll(rgx.br_line, "<br>")
- .replaceAll(rgx.br_nl, "<br>")
+ .replaceAll(rgx.br_line, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@@ -114,8 +113,7 @@ template outputEPub3() {
<dc:identifier id="bookid">urn:uuid:%s</dc:identifier>
</metadata>
<manifest>
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
- <link rel="stylesheet" href="%s" type="text/css" id="main-css" />
+ <item id="css" href="%s" media-type="text/css"/>
<item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
┃",
_uuid,
@@ -147,7 +145,7 @@ template outputEPub3() {
);
}
content ~= " " ~ "</manifest>" ~ "\n ";
- content ~= " " ~ "<spine toc=\"ncx\">" ~ "\n ";
+ content ~= " " ~ "<spine>" ~ "\n ";
content ~= parts["spine"];
content ~= " " ~ "</spine>" ~ "\n ";
content ~= " " ~ "<guide>" ~ "\n ";
@@ -196,7 +194,6 @@ template outputEPub3() {
<h1>Contents</h1>
</header>
<nav epub:type="toc" id="toc">
- <ol>
<li>┃",
(doc_matters.conf_make_meta.meta.title_full).special_characters_text,
);
@@ -210,7 +207,10 @@ template outputEPub3() {
</li>
┃",
toc_head,
- obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip,
+ obj.text
+ .replaceAll(rgx.inline_notes_al_gen, "")
+ .replaceAll(rgx.br_newline_inline, "<br />")
+ .strip,
);
} else if (sect == "tail") { // skip
} else if ((sect != "tail") && (obj.metainfo.is_a == "heading")) {
@@ -268,7 +268,7 @@ template outputEPub3() {
break;
}
if (n == 0) {
- _toc_nav_tail ~="</nav>
+ _toc_nav_tail ~=" </nav>
</section>
</body>
</html>\n";
@@ -281,115 +281,6 @@ template outputEPub3() {
toc ~= _toc_nav_tail;
return toc;
}
- @safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) {
- int counter_play_order = 0;
- string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere
- auto markup = InlineMarkup();
- static auto rgx = RgxO();
- enum DomTags { none, open, close, close_and_open, open_still, }
- string toc;
- string toc_ = format(q"┃<?xml version="1.0" encoding="utf-8"?>
- <ncx xmlns="https://www.daisy.org/z3986/2005/ncx/" version="2005-1">
- <head>
- <!-- four required metadata items (for all NCX documents,
- (including the relaxed constraints of OPS 2.0) -->
- <title>%s%s</title>
- <link rel="stylesheet" href="Styles/epub.css" type="text/css" id="main-css" />
- <meta name="dtb:uid" content="urn:uuid:%s" />
- <meta name="dtb:depth" content="%s" />
- <meta name="dtb:totalPageCount" content="0" />
- <meta name="dtb:maxPageNumber" content="0" />
- </head>
- <docTitle>
- <text>%s</text>
- </docTitle>
- <docAuthor>
- <text>%s</text>
- </docAuthor>
- <navMap>┃",
- (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title
- (doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
- : " by " ~ (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author
- _uuid, // uuid
- "3", // content depth
- (doc_matters.conf_make_meta.meta.title_full).special_characters_text, // title
- (doc_matters.conf_make_meta.meta.creator_author.empty) ? ""
- : (doc_matters.conf_make_meta.meta.creator_author).special_characters_text, // author
- );
- string _toc_ncx_tail = "";
- foreach (sect; doc_matters.has.keys_seq.seg) {
- foreach (obj; doc_abstraction[sect]) {
- if (sect == "head") { toc = toc_;
- }
- if (obj.metainfo.is_a == "heading") {
- string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip.special_characters_text;
- // writeln(_txt, " --- ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG line
- string hashtag = (obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string);
- foreach_reverse (k; 0 .. 7) {
- switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) { // for epub may need to construct for levels 1 to 4 only
- case DomTags.close :
- if (sect != "head") {
- toc ~= "\n </navPoint>"; // issue at start of some documents
- }
- break;
- case DomTags.close_and_open :
- toc ~= "\n </navPoint>";
- goto default;
- case DomTags.open :
- goto default;
- default :
- string _toc;
- if ((obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open
- || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open
- // || obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open_still
- )) {
- ++counter_play_order;
- _toc = format(q"┃
- <navPoint class="chapter" id="navpoint" playOrder="%s">
- <navLabel>
- <text>%s</text>
- </navLabel>
- <content src="%s.xhtml%s" />┃",
- counter_play_order,
- _txt,
- obj.tags.segment_anchor_tag_epub,
- hashtag,
- );
- }
- if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.close_and_open) {
- toc ~= _toc;
- } else if (obj.metainfo.dom_structure_collapsed_tags_status[k] == DomTags.open) {
- toc ~= _toc;
- }
- break;
- }
- if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) {
- if (k == 6) {_toc_ncx_tail = "";}
- switch (obj.metainfo.dom_structure_collapsed_tags_status[k]) {
- case 0: case 2:
- // case DomTags.none: case DomTags.close:
- break;
- case 1: case 3: case 4:
- // case DomTags.open: case DomTags.close_and_open: case DomTags.open_still:
- if (k != 0) {
- }
- _toc_ncx_tail ~= " " ~ markup.indent_by_spaces_provided(k, " ") ~ "</navPoint>" ~ "\n";
- break;
- default :
- break;
- }
- if (k == 0) {
- _toc_ncx_tail ~= format(q"┃ </navMap>
- </ncx>┃");
- }
- }
- }
- }
- }
- }
- toc ~= _toc_ncx_tail;
- return toc;
- }
@system void outputEPub3(D,I)(
const D doc_abstraction,
I doc_matters,
@@ -406,7 +297,6 @@ template outputEPub3() {
/+ fixed output +/
string mimetypes;
string meta_inf_container_xml;
- string oebps_toc_ncx;
string oebps_toc_nav_xhtml;
/+ variable output +/
string oebps_content_opf;
@@ -654,25 +544,25 @@ template outputEPub3() {
assert(obj.text.length > 0);
if (obj.metainfo.heading_lev_markup <= 4) {
oepbs_content_parts["manifest_documents"] ~=
- format(q"┃ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" />
+ format(q"┃<item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.tags.segment_anchor_tag_epub,
);
oepbs_content_parts["spine"] ~=
- format(q"┃ <itemref idref="%s.xhtml" linear="yes" />
+ format(q"┃<itemref idref="%s.xhtml" linear="yes" />
┃",
obj.tags.segment_anchor_tag_epub,
);
oepbs_content_parts["guide"] ~=
- format(q"┃ <reference type="%s" href="%s" />
+ format(q"┃<reference type="%s" href="%s" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.tags.segment_anchor_tag_epub,
);
} 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" />
+ format(q"┃<item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
@@ -680,13 +570,13 @@ template outputEPub3() {
obj.metainfo.object_number,
);
oepbs_content_parts["spine"] ~=
- format(q"┃ <itemref idref="%s.xhtml#%s" linear="yes" />
+ format(q"┃<itemref idref="%s.xhtml#%s" linear="yes" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
);
oepbs_content_parts["guide"] ~=
- format(q"┃ <reference type="%s#%s" href="%s#%s" />
+ format(q"┃<reference type="%s#%s" href="%s#%s" />
┃",
obj.tags.segment_anchor_tag_epub,
obj.metainfo.object_number,
@@ -698,11 +588,10 @@ template outputEPub3() {
}
}
/+ epub specific documents +/
- epubWrite.mimetypes = epub3_mimetypes;
+ epubWrite.mimetypes = epub3_mimetypes;
epubWrite.meta_inf_container_xml = epub3_container_xml;
- epubWrite.oebps_toc_ncx = doc_abstraction.epub2_oebps_toc_ncx(doc_matters);
- epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters);
- epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts);
+ epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters);
+ epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts);
epubWrite.epub3_write_output_files(doc_matters);
}
@system void epub3_write_output_files(W,M)(
@@ -714,7 +603,6 @@ template outputEPub3() {
static assert(is(typeof(epub_write.mimetypes) == string));
static assert(is(typeof(epub_write.meta_inf_container_xml) == string));
static assert(is(typeof(epub_write.oebps_toc_nav_xhtml) == string));
- static assert(is(typeof(epub_write.oebps_toc_ncx) == string));
static assert(is(typeof(epub_write.oebps_content_opf) == string));
}
static auto rgx = RgxO();
@@ -821,16 +709,6 @@ template outputEPub3() {
fn = pth_epub3.fn_oebps_toc_nav_xhtml;
EPUBzip(epub_write.oebps_toc_nav_xhtml, fn);
}
- { /+ OEBPS/toc.ncx (navigation toc epub2) +/
- { /+ debug +/
- if (doc_matters.opt.action.debug_do) {
- fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename);
- File(fn_dbg, "w").writeln(epub_write.oebps_toc_ncx);
- }
- }
- fn = pth_epub3.fn_oebps_toc_ncx;
- EPUBzip(epub_write.oebps_toc_ncx, fn);
- }
{ /+ OEBPS/content.opf (doc manifest) +/
{ /+ debug +/
if (doc_matters.opt.action.debug_do) {
diff --git a/src/doc_reform/io_out/rgx.d b/src/doc_reform/io_out/rgx.d
index 7f3b9da..3aaf420 100644
--- a/src/doc_reform/io_out/rgx.d
+++ b/src/doc_reform/io_out/rgx.d
@@ -76,7 +76,7 @@ static template spineRgxOut() {
static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg");
static br_newlines_linebreaks = ctRegex!(`[\n┘┙]`, "mg");
static br_line = ctRegex!(`┘`, "mg");
- static br_nl = ctRegex!(`┙`, "mg");
+ static br_newline_inline = ctRegex!(`┙`, "mg");
/+ inline markup footnotes endnotes +/
static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg");
static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented
diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d
index 66661cf..6191fa9 100644
--- a/src/doc_reform/io_out/xmls.d
+++ b/src/doc_reform/io_out/xmls.d
@@ -99,16 +99,14 @@ template outputXHTMLs() {
.replaceAll(rgx.xhtml_quotation, "&quot;") // "&#34;"
.replaceAll(rgx.xhtml_less_than, "&lt;") // "&#60;"
.replaceAll(rgx.xhtml_greater_than, "&gt;") // "&#62;"
- .replaceAll(rgx.br_line, "<br>")
- .replaceAll(rgx.br_nl, "<br>")
+ .replaceAll(rgx.br_line, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@safe string special_characters_date(string _txt) {
_txt = _txt
.replaceAll(regex(r"(?:-00)+"), "")
- .replaceAll(rgx.br_line, "<br>")
- .replaceAll(rgx.br_nl, "<br>")
+ .replaceAll(rgx.br_line, "<br />")
.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
@@ -237,7 +235,7 @@ template outputXHTMLs() {
.replaceAll(
rgx.br_line, "")
.replaceAll(
- rgx.br_nl, "");
+ rgx.br_newline_inline, "");
} else {
_locations = "<p class=\"tiny_left\"><a href=\"https://www.doc-reform.org\">spine</a></p>\n<p class=\"tiny_left\"><a href=\"https://git.sisudoc.org/software/spine/\">sources / git</a></p>\n<p class=\"tiny_left\"><a href=\"https://www.sisudoc.org\">www.sisudoc.org</a></p>";
}
@@ -812,14 +810,16 @@ template outputXHTMLs() {
(doc_matters.opt.action.ocn_off)
? "" : ((obj.metainfo.object_number.empty)
? "" : obj.metainfo.identifier),
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
obj.metainfo.is_a,
obj.metainfo.identifier,
obj.metainfo.identifier,
tags,
heading_lev_anchor_tag,
_txt,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
);
} else {
o = format(q"┃%s
@@ -829,12 +829,14 @@ template outputXHTMLs() {
</h%s>
</div>┃",
_horizontal_rule,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
obj.metainfo.is_a,
tags,
heading_lev_anchor_tag,
_txt,
- obj.metainfo.heading_lev_markup,
+ ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1
+ : obj.metainfo.heading_lev_markup),
);
}
return o;
diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d
index 21c081c..ea969d5 100644
--- a/src/doc_reform/meta/defaults.d
+++ b/src/doc_reform/meta/defaults.d
@@ -184,7 +184,7 @@ template InternalMarkup() {
string mark_internal_site_lnk = "¤";
string nbsp = "░";
string br_line = "┘";
- string br_nl = "┙";
+ string br_newline_inline = "┙";
string br_paragraph = "┚";
string br_obj = "break_obj";
string br_page_line = "┼";
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index 3099d84..6396655 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -4060,11 +4060,11 @@ template docAbstraction() {
an_object[an_object_key] = an_object[an_object_key]
.replaceFirst(rgx.variable_doc_title_author_date,
(conf_make_meta.meta.title_full
- ~ mkup.br_nl
+ ~ mkup.br_newline_inline
~ conf_make_meta.meta.creator_author
~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"))
.replaceFirst(rgx.variable_doc_title,
- (conf_make_meta.meta.title_full ~ mkup.br_nl))
+ (conf_make_meta.meta.title_full ~ mkup.br_newline_inline))
.replaceFirst(rgx.variable_doc_author,
conf_make_meta.meta.creator_author)
.replaceFirst(rgx.variable_doc_date,
@@ -4075,10 +4075,10 @@ template docAbstraction() {
an_object[an_object_key] = an_object[an_object_key]
.replaceFirst(rgx.variable_doc_title_author_date,
(conf_make_meta.meta.title_full
- ~ mkup.br_nl
+ ~ mkup.br_newline_inline
~ conf_make_meta.meta.creator_author))
.replaceFirst(rgx.variable_doc_title,
- (conf_make_meta.meta.title_full ~ mkup.br_nl))
+ (conf_make_meta.meta.title_full ~ mkup.br_newline_inline))
.replaceFirst(rgx.variable_doc_author,
conf_make_meta.meta.creator_author);
} else if (an_object[an_object_key].match(rgx.variable_doc_title)) {
@@ -4694,6 +4694,7 @@ template docAbstraction() {
obj_txt["munge"] = obj_txt_in
.replaceFirst(rgx.headings, "")
.replaceFirst(rgx.object_number_off_all, "")
+ .replaceFirst(rgx.markup_inline_linebreak, mkup.br_newline_inline)
.strip;
TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers);
debug(munge) {
@@ -4709,7 +4710,8 @@ template docAbstraction() {
@safe auto munge_para()(string obj_txt_in) {
obj_txt["munge"] = (obj_txt_in)
.replaceFirst(rgx.para_attribs, "")
- .replaceFirst(rgx.object_number_off_all, "");
+ .replaceFirst(rgx.object_number_off_all, "")
+ .replaceFirst(rgx.markup_inline_linebreak, mkup.br_newline_inline);
TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]);
debug(munge) {
writeln(__LINE__);
diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d
index 0d2912d..8c48eac 100644
--- a/src/doc_reform/meta/rgx.d
+++ b/src/doc_reform/meta/rgx.d
@@ -77,6 +77,7 @@ static template spineRgxIn() {
static newline_eol_delimiter = ctRegex!("\n");
static newline_eol_strip_preceding = ctRegex!("[ ]*\n");
static newline_eol_delimiter_only = ctRegex!("^\n");
+ static markup_inline_linebreak = ctRegex!(`\s*\\\\s*`, "m");
static line_delimiter_ws_strip = ctRegex!("[ ]*\n[ ]*");
static para_delimiter = ctRegex!("\n[ ]*\n+");
static table_col_delimiter = ctRegex!("[ ]*\n+", "mg");
@@ -245,7 +246,7 @@ static template spineRgxIn() {
static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg");
static br_newlines_linebreaks = ctRegex!(`[\n┘┙]`, "mg");
static br_line = ctRegex!(`┘`, "mg");
- static br_nl = ctRegex!(`┙`, "mg");
+ static br_newline_inline = ctRegex!(`┙`, "mg");
/+ inline markup footnotes endnotes +/
static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg");
static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented