From a9a46fca7397aaa357bfdc2b98e181617bb6887b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 May 2017 18:46:11 -0400 Subject: xmls work particularly with epub output --- org/ao_doc_abstraction.org | 151 +++++++++++++++------- org/output_xmls.org | 306 ++++++++++++++++++++++++++------------------- org/output_xmls_css.org | 8 +- org/sdp.org | 9 +- 4 files changed, 294 insertions(+), 180 deletions(-) (limited to 'org') diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org index 93768c1..878f1a0 100644 --- a/org/ao_doc_abstraction.org +++ b/org/ao_doc_abstraction.org @@ -605,6 +605,7 @@ auto note_section = NotesSection(); auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string] lev4_subtoc; string[] html_segnames=["toc"]; +int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; #+END_SRC ** 2. _loop: process document body_ [+6] :loop: @@ -725,6 +726,7 @@ if there is a glossary section you need to: comp_obj_heading_.text = "Glossary"; comp_obj_heading_.ocn = 0; comp_obj_heading_.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = "_part_glossary"; comp_obj_heading_.marked_up_level = "B"; comp_obj_heading_.heading_lev_markup = 1; comp_obj_heading_.heading_lev_collapsed = 1; @@ -806,6 +808,7 @@ if there is a blurb section you need to: comp_obj_heading_.text = "Blurb"; comp_obj_heading_.ocn = 0; comp_obj_heading_.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = "_part_blurb"; comp_obj_heading_.marked_up_level = "B"; comp_obj_heading_.heading_lev_markup = 1; comp_obj_heading_.heading_lev_collapsed = 1; @@ -1143,8 +1146,28 @@ if ((type["heading"] == State.on) segment_anchor_tag_that_object_belongs_to = anchor_tag_; segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_number.to!string; } else if (an_object["lev_markup_number"].to!int < 4) { - segment_anchor_tag_that_object_belongs_to = ""; - segment_anchor_tag_that_object_belongs_to_uri = ""; + string segn; + switch (an_object["lev_markup_number"].to!int) { + case 0: + segn = "_the_title"; + goto default; + case 1: + segn = "_part_" ~ cnt1.to!string; + ++cnt1; + goto default; + case 2: + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; + ++cnt2; + goto default; + case 3: + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; + ++cnt3; + goto default; + default: + segment_anchor_tag_that_object_belongs_to = segn; + segment_anchor_tag_that_object_belongs_to_uri = segn ~ ".fnSuffix"; + break; + } } an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; @@ -1390,6 +1413,7 @@ if (biblio_ordered.length > 0) { comp_obj_heading_.text = "Bibliography"; comp_obj_heading_.ocn = 0; comp_obj_heading_.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = "_part_bibliography"; comp_obj_heading_.marked_up_level = "B"; comp_obj_heading_.heading_lev_markup = 1; comp_obj_heading_.heading_lev_collapsed = 1; @@ -1704,7 +1728,7 @@ the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; #+END_SRC -*** minor loops :post: +*** _minor loops_ :post: **** 1. loop: backmatter loop up to lev4: html_segnames, set backmatter pointers could optimise by @@ -1817,11 +1841,15 @@ auto extract_images(S)(S content_block) { } return images_; } +string[] segnames_0_4; foreach (ref obj; the_document_head_section) { if (obj.is_a == "heading") { debug(dom) { writeln(obj.text); } + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) || (opt_action_bool["html_seg"]) @@ -1839,9 +1867,12 @@ if (the_table_of_contents_section["scroll"].length > 1) { dom_collapsed_buffer = dom_collapsed.dup; foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.is_a == "heading") { - if (obj.heading_lev_markup == 4) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); + } } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -1862,9 +1893,12 @@ if (the_table_of_contents_section["scroll"].length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); + } } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -1886,13 +1920,16 @@ if (the_document_body_section.length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag]; - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag]; + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -1921,12 +1958,15 @@ if (the_endnotes_section.length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -1948,12 +1988,15 @@ if (the_glossary_section.length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -1975,12 +2018,15 @@ if (the_bibliography_section.length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -2003,12 +2049,15 @@ if (the_bookindex_section["scroll"].length > 1) { if (obj.is_a == "heading") { debug(dom) { } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -2029,12 +2078,15 @@ if (the_bookindex_section["scroll"].length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -2056,12 +2108,15 @@ if (the_blurb_section.length > 1) { debug(dom) { writeln(obj.text); } - if (obj.heading_lev_markup == 4) { - obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; - if (html_segnames.length > obj.ptr_html_segnames + 1) { - obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + if (obj.heading_lev_markup <= 4) { + segnames_0_4 ~= obj.segment_anchor_tag; + if (obj.heading_lev_markup == 4) { + obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1]; + if (html_segnames.length > obj.ptr_html_segnames + 1) { + obj.segname_next = html_segnames[obj.ptr_html_segnames + 1]; + } + assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } - assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]); } if ((opt_action_bool["html"]) || (opt_action_bool["html_scroll"]) @@ -2205,6 +2260,7 @@ auto t = tuple( document_the, docSectKeysSeq!()(document_section_keys_sequenced), segnames, + segnames_0_4, images, ); return t; @@ -3436,7 +3492,6 @@ void _block_flag_line_empty_(B)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; comp_obj_block = comp_obj_block.init; comp_obj_block.use = "body"; comp_obj_block.is_of = "block"; @@ -3484,7 +3539,7 @@ void _block_flag_line_empty_(B)( comp_obj_poem_ocn.is_a = "poem"; comp_obj_poem_ocn.ocn = obj_cite_number; comp_obj_poem_ocn.obj_cite_number = (obj_cite_number_poem["start"], obj_cite_number_poem["end"]); - comp_obj_poem_ocn.text = ""; // an_object["substantive"]; + comp_obj_poem_ocn.text = ""; the_document_body_section ~= comp_obj_poem_ocn; type["blocks"] = TriState.off; type["poem"] = TriState.off; @@ -5838,6 +5893,7 @@ struct BookIndexReportSection { comp_obj_heading_.text = "Book Index"; comp_obj_heading_.ocn = 0; comp_obj_heading_.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = "_part_book_index"; comp_obj_heading_.marked_up_level = "B"; comp_obj_heading_.heading_lev_markup = 1; comp_obj_heading_.heading_lev_collapsed = 1; @@ -6088,6 +6144,7 @@ struct NotesSection { comp_obj_heading_.text = "Endnotes"; comp_obj_heading_.ocn = 0; comp_obj_heading_.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = "_part_endnotes"; comp_obj_heading_.marked_up_level = "B"; comp_obj_heading_.heading_lev_markup = 1; comp_obj_heading_.heading_lev_collapsed = 1; diff --git a/org/output_xmls.org b/org/output_xmls.org index 017c346..1757ffa 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -130,12 +130,9 @@ string _xhtml_anchor_tags(const(string[]) anchor_tags) { #+name: xhtml_format_objects #+BEGIN_SRC d -auto html_scroll_head(Me)( - Me dochead_meta, +auto html_scroll_head(Dm)( + Dm doc_matters, ) { - debug(asserts) { - static assert(is(typeof(dochead_meta) == string[string][string])); - } string o; o = format(q"¶ @@ -163,11 +160,12 @@ auto html_scroll_head(Me)( - + ¶", -dochead_meta["title"]["full"], -(dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], -); + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + ); return o; } #+END_SRC @@ -176,12 +174,9 @@ dochead_meta["title"]["full"], #+name: xhtml_format_objects #+BEGIN_SRC d -auto html_seg_head(Me)( - Me dochead_meta, +auto html_seg_head(Dm)( + Dm doc_matters, ) { - debug(asserts) { - static assert(is(typeof(dochead_meta) == string[string][string])); - } string o; o = format(q"¶ @@ -209,11 +204,13 @@ auto html_seg_head(Me)( - + ¶", -dochead_meta["title"]["full"], -(dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], -); + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" + : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + ); return o; } #+END_SRC @@ -222,50 +219,60 @@ dochead_meta["title"]["full"], #+name: xhtml_format_objects #+BEGIN_SRC d -auto epub3_seg_head(Me)( - Me dochead_meta, +auto epub3_seg_head(Dm)( + Dm doc_matters, ) { - debug(asserts) { - static assert(is(typeof(dochead_meta) == string[string][string])); - } - string html_simple = format(q"¶ + string html_base = format(q"¶ ¶", ); + string html_simple = format(q"¶ +¶", + doc_matters.language, + doc_matters.language, + ); string html_strict = format(q"¶ -¶", -); +¶", + doc_matters.language, + doc_matters.language, + ); string o; o = format(q"¶%s - - - %s%s - - - - - - - - - - - - - - - + + %s%s + + + + + + + + + + + + + + - + ¶", -html_strict, -dochead_meta["title"]["full"], -(dochead_meta["creator"]["author"].empty) ? "" : ", " ~ dochead_meta["creator"]["author"], -); + html_simple, + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + ); return o; } #+END_SRC @@ -477,10 +484,12 @@ auto toc_seg(O)( auto heading(O)( auto return ref const O obj, string _txt, + string _type="html", ) { auto tags = _xhtml_anchor_tags(obj.anchor_tags); string _horizontal_rule = "
"; - if (obj.heading_lev_markup == 0) { + if ((_type != "html") + || (obj.heading_lev_markup == 0 || obj.heading_lev_markup > 4)) { _horizontal_rule = ""; } string o; @@ -546,11 +555,12 @@ auto heading_seg(O)( auto return ref const O obj, string _txt, string _suffix = ".html", + string _type = "html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); _txt = t[0]; string[] _endnotes = t[1]; - string o = heading(obj, _txt); + string o = heading(obj, _txt, _type); auto u = tuple( o, _endnotes, @@ -1228,7 +1238,7 @@ void scroll(D,I)( } } } - doc = xhtml_format.html_scroll_head(doc_matters.dochead_meta) ~ doc_html ~ xhtml_format.tail; + doc = xhtml_format.html_scroll_head(doc_matters) ~ doc_html ~ xhtml_format.tail; scroll_write_output(doc_matters, doc); } #+END_SRC @@ -1316,7 +1326,7 @@ void seg(D,I)( break; case 4: segment_filename = obj.segment_anchor_tag; - doc_html[segment_filename] ~= xhtml_format.html_seg_head(doc_matters.dochead_meta); + doc_html[segment_filename] ~= xhtml_format.html_seg_head(doc_matters); foreach (top_level_heading; top_level_headings) { // writeln(top_level_heading); doc_html[segment_filename] ~= top_level_heading; @@ -1707,10 +1717,24 @@ string epub3_oebps_content(D,I,P)(D doc_abstraction, I doc_matters, P parts) { string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); - string toc =" + + +\n"; return toc; } #+END_SRC @@ -1774,70 +1806,75 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { int counter = 0; string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); + auto rgx = Rgx(); enum DomTags { none, open, close, close_and_open, open_still, } string toc = format(q"¶ - - - %s%s - - - - - - - - - %s - - - %s - - ¶", - doc_matters.dochead_meta["title"]["full"], // title - (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : " by " ~ doc_matters.dochead_meta["creator"]["author"], // author - uuid, // uuid - "3", // content depth - doc_matters.dochead_meta["title"]["full"], // title - (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : doc_matters.dochead_meta["creator"]["author"], // author + + + %s%s + + + + + + + + + %s + + + %s + +¶", + doc_matters.dochead_meta["title"]["full"], // title + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" + : " by " ~ doc_matters.dochead_meta["creator"]["author"], // author + uuid, // uuid + "3", // content depth + doc_matters.dochead_meta["title"]["full"], // title + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" + : doc_matters.dochead_meta["creator"]["author"], // author ); foreach (sect; doc_matters.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { if (obj.is_a == "heading") { + string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; + string hashtag =(obj.heading_lev_markup <= 4) ? "" : ("#" ~ obj.ocn.to!string); foreach_reverse (k; 0 .. 7) { switch (obj.dom_markedup[k]) { case DomTags.close : - // writeln(markup.indent_by_spaces_provided(k), ""); // --debug dom tags -toc ~= ""; + toc ~= "\n "; break; case DomTags.close_and_open : - // writeln(markup.indent_by_spaces_provided(k), ""); // --debug dom tags - // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags ++counter; -toc ~= ""; -toc ~= format(q"¶ - - %s - -¶", -counter, -obj.text, -obj.segment_anchor_tag, // lev < 4 [no link]; lev == 4 [filename] markup.xhtml; lev > 4 [filename#ocn] (links done in segment_anchor_tag) -); + toc ~= "\n "; + toc ~= format(q"¶ + + + %s + + ¶", + counter, + _txt, + obj.segment_anchor_tag, + hashtag, + ); break; case DomTags.open : - // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags ++counter; -toc ~= format(q"¶ - - %s - -¶", -counter, -obj.text, -obj.segment_anchor_tag, // lev < 4 [no link]; lev == 4 [filename] markup.xhtml; lev > 4 [filename#ocn] (fix links in segment_anchor_tag) -); + toc ~= format(q"¶ + + + %s + + ¶", + counter, + _txt, + obj.segment_anchor_tag, + hashtag, + ); break; default : break; @@ -1871,6 +1908,7 @@ void outputEPub3(D,I)( string[] top_level_headings = ["","","",""]; string[string] oepbs_content_parts; string suffix = ".xhtml"; + string[] doc_parts_; foreach (part; doc_matters.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { string _txt = xhtml_format.special_characters(obj, obj.text); @@ -1898,23 +1936,23 @@ void outputEPub3(D,I)( top_level_headings[3] = ""; goto default; default: - auto t = xhtml_format.heading_seg(obj, suffix); - top_level_headings[obj.heading_lev_markup] = t[0]; + doc_parts_ ~= obj.segment_anchor_tag; + doc_epub3[obj.segment_anchor_tag] ~= xhtml_format.epub3_seg_head(doc_matters); + auto t = xhtml_format.heading_seg(obj, _txt, suffix, "epub"); + doc_epub3[obj.segment_anchor_tag] ~= t[0]; + doc_epub3_endnotes[obj.segment_anchor_tag] ~= t[1]; break; } break; case 4: segment_filename = obj.segment_anchor_tag; - doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters.dochead_meta); - foreach (top_level_heading; top_level_headings) { - doc_epub3[segment_filename] ~= top_level_heading; - } - auto t = xhtml_format.heading_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters); + auto t = xhtml_format.heading_seg(obj, _txt, suffix, "epub"); doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: - auto t = xhtml_format.heading_seg(obj, _txt, suffix); + auto t = xhtml_format.heading_seg(obj, _txt, suffix, "epub"); doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; break; @@ -1937,7 +1975,9 @@ void outputEPub3(D,I)( case "para": switch (obj.is_a) { case "toc": - doc_epub3[segment_filename] ~= xhtml_format.toc_seg(obj, _txt); + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= t[0]; + doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: if ((doc_matters.opt_action_bool["debug"])) { @@ -2067,35 +2107,41 @@ void outputEPub3(D,I)( } } if (obj.is_a == "heading") { - if (obj.heading_lev_markup == 4) { - oepbs_content_parts["manifest_documents"] ~= format(q"¶ + if (obj.heading_lev_markup <= 4) { + oepbs_content_parts["manifest_documents"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, obj.segment_anchor_tag, ); - oepbs_content_parts["spine"] ~= format(q"¶ + oepbs_content_parts["spine"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, ); - oepbs_content_parts["guide"] ~= format(q"¶ + oepbs_content_parts["guide"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, obj.segment_anchor_tag, ); } else if (obj.heading_lev_markup > 4) { - oepbs_content_parts["manifest_documents"] ~= format(q"¶ + oepbs_content_parts["manifest_documents"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, obj.obj_cite_number, obj.segment_anchor_tag, obj.obj_cite_number, ); - oepbs_content_parts["spine"] ~= format(q"¶ + oepbs_content_parts["spine"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, obj.obj_cite_number, ); - oepbs_content_parts["guide"] ~= format(q"¶ + oepbs_content_parts["guide"] ~= + format(q"¶ ¶", obj.segment_anchor_tag, obj.obj_cite_number, @@ -2121,6 +2167,7 @@ void outputEPub3(D,I)( oebps_toc_nav_xhtml, oebps_toc_ncx, oebps_content_opf, + doc_parts_, ); } #+END_SRC @@ -2138,8 +2185,8 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( Otnx oebps_toc_nav_xhtml, Otn oebps_toc_ncx, Oc oebps_content_opf, + string[] doc_parts_, ) { - auto css = SiSUcss(); debug(asserts) { static assert(is(typeof(doc_epub3) == string[][string])); static assert(is(typeof(mimetypes) == string)); @@ -2173,7 +2220,7 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( } } { /+ OEBPS/[segments].xhtml (the document contents) +/ - foreach (seg_filename; doc_matters.segnames) { + foreach (seg_filename; doc_matters.segnames_lv_0_to_4) { string fn = pth_epub3.fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename); /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); @@ -2323,6 +2370,7 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( } } { /+ OEBPS/epub.css +/ + auto css = SiSUcss(); debug(epub_output) { fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.source_filename); File(fn_dbg, "w").writeln(css.epub_css); @@ -2333,7 +2381,7 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( // add OEBPS/content.opf to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - zip_data.write(oebps_content_opf.dup); // cast as: char[] + zip_data.write(css.epub_css.dup); // cast as: char[] zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); /+ create the zip file +/ diff --git a/org/output_xmls_css.org b/org/output_xmls_css.org index 83b6559..5b34915 100644 --- a/org/output_xmls_css.org +++ b/org/output_xmls_css.org @@ -25,7 +25,7 @@ template SiSUcss() { string css_shared=" <> "; - struct _CSS { + struct _css { auto html_css() { string _css = "/* SiSU css html stylesheet */\n" ~ css_shared; return _css; @@ -35,7 +35,7 @@ template SiSUcss() { return _css; } } - return _CSS(); + return _css(); } } #+END_SRC @@ -888,4 +888,8 @@ template SiSUcss() { color: #000000; background-color: #f9f9aa; } + /* in toc no list numbering */ + nav#toc ol { + list-style-type: none; + } #+END_SRC diff --git a/org/sdp.org b/org/sdp.org index f6c26f2..0817dfd 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -451,7 +451,7 @@ template SiSUabstraction() { <> enum headBody { header, body_content, insert_filelist } enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, images } + enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } auto rgx = Rgx(); auto SiSUabstraction(Fn,O,E)(Fn fn_src, O opts, E env){ <> @@ -540,10 +540,11 @@ auto da = SiSUdocAbstraction!()( opts ); static assert(!isTypeTuple!(da)); -static assert(da.length==4); +static assert(da.length==5); auto doc_abstraction = da[docAbst.doc_abstraction]; // head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~blurb; auto _document_section_keys_sequenced = da[docAbst.section_keys]; string[] _doc_html_segnames = da[docAbst.segnames]; +string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; auto _images = da[docAbst.images]; #+END_SRC @@ -564,6 +565,10 @@ struct DocumentMatters { string[] _k = _doc_html_segnames; return _k; } + string[] segnames_lv_0_to_4() { + string[] _k = _doc_epub_segnames_0_4; + return _k; + } auto dochead_make() { string[string][string] _k = _make_and_meta[makeMeta.make]; return _k; -- cgit v1.2.3