diff options
Diffstat (limited to 'src/sdp/output')
-rw-r--r-- | src/sdp/output/create_zip_file.d | 17 | ||||
-rw-r--r-- | src/sdp/output/defaults.d | 120 | ||||
-rw-r--r-- | src/sdp/output/epub3.d | 756 | ||||
-rw-r--r-- | src/sdp/output/html.d | 447 | ||||
-rw-r--r-- | src/sdp/output/hub.d | 79 | ||||
-rw-r--r-- | src/sdp/output/package.d | 20 | ||||
-rw-r--r-- | src/sdp/output/paths_output.d | 288 | ||||
-rw-r--r-- | src/sdp/output/paths_source.d | 60 | ||||
-rw-r--r-- | src/sdp/output/rgx.d | 73 | ||||
-rw-r--r-- | src/sdp/output/source_sisupod.d | 208 | ||||
-rw-r--r-- | src/sdp/output/xmls.d | 800 | ||||
-rw-r--r-- | src/sdp/output/xmls_css.d | 869 |
12 files changed, 3737 insertions, 0 deletions
diff --git a/src/sdp/output/create_zip_file.d b/src/sdp/output/create_zip_file.d new file mode 100644 index 0000000..5380744 --- /dev/null +++ b/src/sdp/output/create_zip_file.d @@ -0,0 +1,17 @@ +module sdp.output.create_zip_file; +template createZipFile() { + import std.file; + import std.outbuffer; + import std.string; + import std.zip; + void createZipFile( + string zip_file_name, + void[] compressed_zip_data, + ) { + try { + write(zip_file_name, compressed_zip_data); + } catch (ZipException ex) { + // Handle Errors + } + } +} diff --git a/src/sdp/output/defaults.d b/src/sdp/output/defaults.d new file mode 100644 index 0000000..82a8d1a --- /dev/null +++ b/src/sdp/output/defaults.d @@ -0,0 +1,120 @@ +/++ + default settings ++/ +module sdp.output.defaults; + +template InternalMarkup() { + struct InlineMarkup { + auto en_a_o = "【"; auto en_a_c = "】"; + auto en_b_o = "〖"; auto en_b_c = "〗"; + auto lnk_o = "┥"; auto lnk_c = "┝"; + auto url_o = "┤"; auto url_c = "├"; + auto mark_internal_site_lnk = "¤"; + auto nbsp = "░"; + auto br_line = "┘"; + auto br_nl = "┙"; + auto br_paragraph = "┚"; + auto br_obj = "break_obj"; + auto br_page_line = "┼"; + auto br_page = "┿"; + auto br_page_new = "╂"; + auto tc_s = "┊"; + auto tc_o = "┏"; + auto tc_c = "┚"; + auto tc_p = "┆"; + string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { + _indent_spaces = replicate(_indent_spaces, indent); + return _indent_spaces; + } + string repeat_character_by_number_provided(C,N)(C _character ="-", N number=10) { + _character = replicate(_character, number); + return _character; + } + } +} +template SiSUlanguageCodes() { + /+ language codes +/ + struct Lang { + string[string][string] codes() { + auto _lang_codes = [ + "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], + "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], + "bn": [ "c": "bn", "n": "Bengali", "t": "Bengali", "xlp": "bengali" ], + "br": [ "c": "br", "n": "Breton", "t": "Breton", "xlp": "breton" ], + "ca": [ "c": "ca", "n": "Catalan", "t": "catalan", "xlp": "catalan" ], + "cs": [ "c": "cs", "n": "Czech", "t": "česky", "xlp": "czech" ], + "cy": [ "c": "cy", "n": "Welsh", "t": "Welsh", "xlp": "welsh" ], + "da": [ "c": "da", "n": "Danish", "t": "dansk", "xlp": "danish" ], + "de": [ "c": "de", "n": "German", "t": "Deutsch", "xlp": "german" ], + "el": [ "c": "el", "n": "Greek", "t": "Ελληνικά (Ellinika)", "xlp": "greek" ], + "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], + "eo": [ "c": "eo", "n": "Esperanto", "t": "Esperanto", "xlp": "esperanto" ], + "es": [ "c": "es", "n": "Spanish", "t": "español", "xlp": "spanish" ], + "et": [ "c": "et", "n": "Estonian", "t": "Estonian", "xlp": "estonian" ], + "eu": [ "c": "eu", "n": "Basque", "t": "basque", "xlp": "basque" ], + "fi": [ "c": "fi", "n": "Finnish", "t": "suomi", "xlp": "finnish" ], + "fr": [ "c": "fr", "n": "French", "t": "français", "xlp": "french" ], + "ga": [ "c": "ga", "n": "Irish", "t": "Irish", "xlp": "irish" ], + "gl": [ "c": "gl", "n": "Galician", "t": "Galician", "xlp": "galician" ], + "he": [ "c": "he", "n": "Hebrew", "t": "Hebrew", "xlp": "hebrew" ], + "hi": [ "c": "hi", "n": "Hindi", "t": "Hindi", "xlp": "hindi" ], + "hr": [ "c": "hr", "n": "Croatian", "t": "Croatian", "xlp": "croatian" ], + "hy": [ "c": "hy", "n": "Armenian", "t": "Armenian", "xlp": "armenian" ], + "ia": [ "c": "ia", "n": "Interlingua", "t": "Interlingua", "xlp": "interlingua" ], + "is": [ "c": "is", "n": "Icelandic", "t": "Icelandic", "xlp": "icelandic" ], + "it": [ "c": "it", "n": "Italian", "t": "Italiano", "xlp": "italian" ], + "ja": [ "c": "ja", "n": "Japanese", "t": "日本語 (Nihongo)", "xlp": "japanese" ], + "ko": [ "c": "ko", "n": "Korean", "t": "Korean", "xlp": "korean" ], + "la": [ "c": "la", "n": "Latin", "t": "Latin", "xlp": "latin" ], + "lo": [ "c": "lo", "n": "Lao", "t": "Lao", "xlp": "lao" ], + "lt": [ "c": "lt", "n": "Lithuanian", "t": "Lithuanian", "xlp": "lithuanian" ], + "lv": [ "c": "lv", "n": "Latvian", "t": "Latvian", "xlp": "latvian" ], + "ml": [ "c": "ml", "n": "Malayalam", "t": "Malayalam", "xlp": "malayalam" ], + "mr": [ "c": "mr", "n": "Marathi", "t": "Marathi", "xlp": "marathi" ], + "nl": [ "c": "nl", "n": "Dutch", "t": "Nederlands", "xlp": "dutch" ], + "no": [ "c": "no", "n": "Norwegian", "t": "norsk", "xlp": "norsk" ], + "nn": [ "c": "nn", "n": "Norwegian Nynorsk", "t": "nynorsk", "xlp": "nynorsk" ], + "oc": [ "c": "oc", "n": "Occitan", "t": "Occitan", "xlp": "occitan" ], + "pl": [ "c": "pl", "n": "Polish", "t": "polski", "xlp": "polish" ], + "pt": [ "c": "pt", "n": "Portuguese", "t": "Português", "xlp": "portuges" ], + "pt_BR": [ "c": "pt_BR", "n": "Portuguese Brazil", "t": "Brazilian Português", "xlp": "brazilian" ], + "ro": [ "c": "ro", "n": "Romanian", "t": "română", "xlp": "romanian" ], + "ru": [ "c": "ru", "n": "Russian", "t": "Русский (Russkij)", "xlp": "russian" ], + "sa": [ "c": "sa", "n": "Sanskrit", "t": "Sanskrit", "xlp": "sanskrit" ], + "se": [ "c": "se", "n": "Sami", "t": "Samin", "xlp": "samin" ], + "sk": [ "c": "sk", "n": "Slovak", "t": "slovensky", "xlp": "slovak" ], + "sl": [ "c": "sl", "n": "Slovenian", "t": "Slovenian", "xlp": "slovenian" ], + "sq": [ "c": "sq", "n": "Albanian", "t": "Albanian", "xlp": "albanian" ], + "sr": [ "c": "sr", "n": "Serbian", "t": "Serbian", "xlp": "serbian" ], + "sv": [ "c": "sv", "n": "Swedish", "t": "svenska", "xlp": "swedish" ], + "ta": [ "c": "ta", "n": "Tamil", "t": "Tamil", "xlp": "tamil" ], + "te": [ "c": "te", "n": "Telugu", "t": "Telugu", "xlp": "telugu" ], + "th": [ "c": "th", "n": "Thai", "t": "Thai", "xlp": "thai" ], + "tk": [ "c": "tk", "n": "Turkmen", "t": "Turkmen", "xlp": "turkmen" ], + "tr": [ "c": "tr", "n": "Turkish", "t": "Türkçe", "xlp": "turkish" ], + "uk": [ "c": "uk", "n": "Ukranian", "t": "українська (ukrajins\"ka)", "xlp": "ukrainian" ], + "ur": [ "c": "ur", "n": "Urdu", "t": "Urdu", "xlp": "urdu" ], + "us": [ "c": "en", "n": "English (American)","t": "English", "xlp": "english" ], + "vi": [ "c": "vi", "n": "Vietnamese", "t": "Vietnamese", "xlp": "vietnamese" ], + "zh": [ "c": "zh", "n": "Chinese", "t": "中文", "xlp": "chinese" ], + "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], + "xx": [ "c": "xx", "n": "Default", "t": "English", "xlp": "english" ], + ]; + return _lang_codes; + } + string[] code_arr_ptr() { + auto _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; + return _lang_codes; + } + string[] code_arr() { + auto _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; + return _lang_codes; + } + auto codes_() { + return "(" ~ join(code_arr,"|") ~ ")"; + } + auto codes_regex() { + return regex(codes_); + } + } +} diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d new file mode 100644 index 0000000..0f91c86 --- /dev/null +++ b/src/sdp/output/epub3.d @@ -0,0 +1,756 @@ +module sdp.output.epub3; +template outputEPub3() { + import sdp.output; + import + std.digest.sha, + std.file, + std.outbuffer, + std.zip, + std.conv : to; + import + sdp.output.create_zip_file, + sdp.output.xmls, + sdp.output.xmls_css; + mixin InternalMarkup; + mixin outputXHTMLs; + string epub3_mimetypes() { + string o; + o = format(q"¶application/epub+zip¶") ~ "\n"; + return o; + } + string epub3_container_xml() { + string o; + o = format(q"¶<?xml version='1.0' encoding='utf-8'?>¶") ~ "\n"; + o ~= format(q"¶<container version="1.0" + xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> + <rootfiles> + <rootfile full-path="OEBPS/content.opf" + media-type="application/oebps-package+xml" /> + </rootfiles>¶") ~ "\n</container>\n"; + return o; + } + string epub3_oebps_content(D,I,P)(D doc_abstraction, I doc_matters, P parts) { + auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.src_path_info, doc_matters.language); + string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! + string content = format(q"¶ <?xml version='1.0' encoding='utf-8'?> + <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="EPB-UUID"> + <metadata + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + unique-identifier="urn:uuid:%s" version="2.0"> + <!-- <dc:title id="title">%s</dc:title> --> + <dc:title id="title">%s</dc:title> + <meta refines="#title" property="title-type">main</meta> + <dc:title id="subtitle">%s</dc:title> + <meta refines="#subtitle" property="title-type">subtitle</meta> + <dc:creator file-as="%s" id="aut">%s</dc:creator> + <dc:language>%s</dc:language> + <dc:date id="published">%s</dc:date> + <dc:rights>Copyright: %s</dc:rights> + <dc:identifier scheme="URI">%s</dc:identifier> + <dc:identifier id="bookid">urn:uuid:%s</dc:identifier> + <!-- <dc:identifier id="EPB-UUID">urn:uuid:%s</dc:identifier> --> + </metadata> + <manifest> + <!-- NCX epub2 navigation --> + <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" /> + <!-- CSS Style Sheets --> + <link rel="stylesheet" href="%s" type="text/css" id="main-css" /> + <!-- nav epub3 navigation --> + <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> + ¶", + uuid, + doc_matters.dochead_meta["title"]["full"], + doc_matters.dochead_meta["title"]["main"], + (doc_matters.dochead_meta["title"]["sub"].empty) + ? "" : doc_matters.dochead_meta["title"]["sub"], + (doc_matters.dochead_meta["creator"]["author"].empty) + ? "" : doc_matters.dochead_meta["creator"]["author"], + (doc_matters.dochead_meta["creator"]["author"].empty) + ? "" : doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + (doc_matters.dochead_meta["date"]["published"].empty) + ? "" : doc_matters.dochead_meta["date"]["published"], + (doc_matters.dochead_meta["rights"]["copyright"].empty) + ? "" : doc_matters.dochead_meta["rights"]["copyright"], + uuid, + uuid, + uuid, + (pth_epub3.fn_oebps_css(doc_matters.source_filename)).chompPrefix("OEBPS/"), + ); + content ~= " " ~ "<!-- Content Documents -->" ~ "\n "; + content ~= parts["manifest_documents"]; + // TODO sort jpg & png + content ~= " " ~ "<!-- Images -->" ~ "\n "; + foreach (image; doc_matters.image_list) { + content ~= format(q"¶ <item id="%s" href="%s/%s" media-type="image/%s" /> + ¶", + image.baseName.stripExtension, + (pth_epub3.doc_oebps_image(doc_matters.source_filename)).chompPrefix("OEBPS/"), + image, + image.extension.chompPrefix("."), + ); + } + content ~= " " ~ "</manifest>" ~ "\n "; + content ~= " " ~ "<spine toc=\"ncx\">" ~ "\n "; + content ~= parts["spine"]; + content ~= " " ~ "</spine>" ~ "\n "; + content ~= " " ~ "<guide>" ~ "\n "; + content ~= parts["guide"]; + content ~= " " ~ "</guide>" ~ "\n "; + content ~= "" ~ "</package>"; + return content; + } + 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(); + auto rgx = Rgx(); + string toc =format("<html xmlns=\"http://www.w3.org/1999/xhtml\" + xmlns:epub=\"http://www.idpf.org/2007/ops\"> + <head> + <title>%s</title> + </head> + <body> + <section epub:type=\"frontmatter toc\"> + <header> + <h1>Contents</h1> + </header> + <nav epub:type=\"toc\" id=\"toc\">\n", + doc_matters.dochead_meta["title"]["full"], + ); + 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; + foreach_reverse (n; 0 .. 7) { + string k = n.to!string; + switch (obj.dom_collapsed[n]) { + case DomTags.close : + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; + toc ~= markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n"; + break; + case DomTags.close_and_open : + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; + if (obj.heading_lev_markup < 4) { + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" + ~ markup.indent_by_spaces_provided((n + 2), " ") + ~ "<a href=\"" ~ obj.segment_anchor_tag ~ ".xhtml" ~ "\">" + ~ _txt + ~ "</a>" ~ "\n"; + } else { + string hashtag =(obj.heading_lev_markup == 4) + ? "" + : ("#" ~ obj.ocn.to!string); + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" + ~ markup.indent_by_spaces_provided((n + 2), " ") + ~ "<a href=\"" ~ obj.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">" + ~ _txt + ~ "</a>" ~ "\n"; + } + break; + case DomTags.open : + toc ~= markup.indent_by_spaces_provided(n, " ") ~ "<ol>" ~ "\n"; + if (obj.heading_lev_markup < 4) { + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" + ~ markup.indent_by_spaces_provided((n + 2), " ") + ~ "<a href=\"" ~ obj.segment_anchor_tag ~ ".xhtml" ~ "\">" + ~ _txt + ~ "</a>" ~ "\n"; + } else { + string hashtag =(obj.heading_lev_markup == 4) + ? "" + : ("#" ~ obj.ocn.to!string); + toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "<li>" ~ "\n" + ~ markup.indent_by_spaces_provided((n + 2), " ") + ~ "<a href=\"" ~ obj.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">" + ~ _txt + ~ "</a>" ~ "\n"; + } + break; + default : + break; + } + } + } + } + } + toc ~="</nav> + </section> + </body> + </html>\n"; + return toc; + } + 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"¶<?xml version='1.0' encoding='utf-8'?> + <ncx xmlns="http://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="css/epub.css" type="text/css" id="main-css" /> + <meta name="dtb:uid" content="urn:uuid:%s" /> + <!-- <meta name="epub-creator" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> --> + <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.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 : + toc ~= "\n </navPoint>"; + break; + case DomTags.close_and_open : + ++counter; + toc ~= "\n </navPoint>"; + toc ~= format(q"¶ + <navPoint class="chapter" id="navpoint" playOrder="%s"> + <navLabel> + <text>%s</text> + </navLabel> + <content src="%s.xhtml%s" />¶", + counter, + _txt, + obj.segment_anchor_tag, + hashtag, + ); + break; + case DomTags.open : + ++counter; + toc ~= format(q"¶ + <navPoint class="chapter" id="navpoint" playOrder="%s"> + <navLabel> + <text>%s</text> + </navLabel> + <content src="%s.xhtml%s" />¶", + counter, + _txt, + obj.segment_anchor_tag, + hashtag, + ); + break; + default : + break; + } + } + } + } + } + toc ~= format(q"¶ </navMap> + </ncx>¶"); + return toc; + } + + void outputEPub3(D,I)( + auto return ref const D doc_abstraction, + auto return ref I doc_matters, + ) { + mixin SiSUoutputRgxInit; + auto xhtml_format = outputXHTMLs(); + auto rgx = Rgx(); + string[][string] doc_epub3; + string[][string] doc_epub3_endnotes; + string[] doc; + string segment_filename; + 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); + if (obj.is_a == "heading") { + switch (obj.heading_lev_markup) { + case 0: .. case 3: + /+ fill buffer, and replace with new levels from 1 to 3 +/ + switch (obj.heading_lev_markup) { + case 0: + top_level_headings[0] = ""; + top_level_headings[1] = ""; + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 1: + top_level_headings[1] = ""; + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 2: + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 3: + top_level_headings[3] = ""; + goto default; + default: + 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); + 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, "epub"); + doc_epub3[segment_filename] ~= t[0]; + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case 8: .. case 9: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup); + } + break; + } + } else { + switch (obj.use) { + case "frontmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "toc": + 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"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "body": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "para": + 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"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + case "block": + switch (obj.is_a) { + case "quote": + auto t = xhtml_format.quote_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= to!string(t[0]); + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "group": + auto t = xhtml_format.group_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= to!string(t[0]); + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "block": + auto t = xhtml_format.block_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= to!string(t[0]); + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "poem": + break; + case "verse": + auto t = xhtml_format.verse_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= to!string(t[0]); + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "code": + doc_epub3[segment_filename] ~= xhtml_format.code(obj, _txt); + break; + case "table": + 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"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "backmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "endnote": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= t[0]; + break; + case "glossary": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= t[0]; + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "bibliography": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= t[0]; + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "bookindex": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_epub3[segment_filename] ~= t[0]; + doc_epub3_endnotes[segment_filename] ~= t[1]; + break; + case "blurb": + 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"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "comment": + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.use); + } + break; + } + } + if (obj.is_a == "heading") { + if (obj.heading_lev_markup <= 4) { + oepbs_content_parts["manifest_documents"] ~= + format(q"¶ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" /> + ¶", + obj.segment_anchor_tag, + obj.segment_anchor_tag, + ); + oepbs_content_parts["spine"] ~= + format(q"¶ <itemref idref="%s.xhtml" linear="yes" /> + ¶", + obj.segment_anchor_tag, + ); + oepbs_content_parts["guide"] ~= + format(q"¶ <reference type="%s" href="%s" /> + ¶", + obj.segment_anchor_tag, + obj.segment_anchor_tag, + ); + } else if (obj.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" /> + ¶", + obj.segment_anchor_tag, + obj.obj_cite_number, + obj.segment_anchor_tag, + obj.obj_cite_number, + ); + oepbs_content_parts["spine"] ~= + format(q"¶ <itemref idref="%s.xhtml#%s" linear="yes" /> + ¶", + obj.segment_anchor_tag, + obj.obj_cite_number, + ); + oepbs_content_parts["guide"] ~= + format(q"¶ <reference type="%s#%s" href="%s#%s" /> + ¶", + obj.segment_anchor_tag, + obj.obj_cite_number, + obj.segment_anchor_tag, + obj.obj_cite_number, + ); + } + } + } + } + /+ epub specific documents +/ + auto mimetypes = epub3_mimetypes; + auto meta_inf_container_xml = epub3_container_xml; + auto oebps_toc_ncx = epub2_oebps_toc_ncx(doc_abstraction, doc_matters); + auto oebps_toc_nav_xhtml = epub3_oebps_toc_nav_xhtml(doc_abstraction, doc_matters); + auto oebps_content_opf = epub3_oebps_content(doc_abstraction, doc_matters, oepbs_content_parts); + epub3_write_output_files( + doc_matters, + doc_epub3, + doc_epub3_endnotes, + mimetypes, + meta_inf_container_xml, + oebps_toc_nav_xhtml, + oebps_toc_ncx, + oebps_content_opf, + doc_parts_, + ); + } + void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( + M doc_matters, + D doc_epub3, + E doc_epub3_endnotes, + Mt mimetypes, + Mic meta_inf_container_xml, + Otnx oebps_toc_nav_xhtml, + Otn oebps_toc_ncx, + Oc oebps_content_opf, + string[] doc_parts_, + ) { + debug(asserts) { + static assert(is(typeof(doc_epub3) == string[][string])); + static assert(is(typeof(mimetypes) == string)); + static assert(is(typeof(meta_inf_container_xml) == string)); + static assert(is(typeof(oebps_toc_nav_xhtml) == string)); + static assert(is(typeof(oebps_toc_ncx) == string)); + static assert(is(typeof(oebps_content_opf) == string)); + } + auto src_path_info = doc_matters.src_path_info; + string fn_rel_pth = doc_matters.source_filename; + string lng = doc_matters.language; + auto pth_epub3 = SiSUpathsEPUB!()(src_path_info, lng); + auto xhtml_format = outputXHTMLs(); + /+ zip file +/ + auto fn_epub = pth_epub3.epub_file(doc_matters.source_filename); + auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive(); + /+ zip archive member files +/ + try { + if (!exists(pth_epub3.base)) { + pth_epub3.base.mkdirRecurse; + } + debug(epub_output) { + if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename))) { + pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename))) { + pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename))) { + pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename).mkdirRecurse; + } + } + { /+ OEBPS/[segments].xhtml (the document contents) +/ + foreach (seg_filename; doc_matters.segnames_lv_0_to_4) { + string fn = pth_epub3.fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + debug(epub_output) { + string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename); + auto f = File(fn_dbg, "w"); + } + foreach (docseg; doc_epub3[seg_filename]) { + debug(epub_output) { f.writeln(docseg); } + zip_data.write(docseg.dup); + } + foreach (docseg; doc_epub3_endnotes[seg_filename]) { + debug(epub_output) { f.writeln(docseg); } + zip_data.write(docseg.dup); + } + debug(epub_output) { f.writeln(xhtml_format.tail); } + zip_data.write(xhtml_format.tail.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + /+ create the zip file +/ + createZipFile!()(fn_epub, zip.build()); + } + } + string fn; + debug(epub_output) { string fn_dbg; } + File f; + { /+ mimetypes (identify zip file type) +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.source_filename); + File(fn_dbg, "w").writeln(mimetypes); + } + fn = pth_epub3.fn_mimetypes(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(mimetypes.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + { /+ META-INF/container.xml (identify doc root) +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.source_filename); + File(fn_dbg, "w").writeln(meta_inf_container_xml); + } + fn = pth_epub3.fn_dmi_container_xml(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(meta_inf_container_xml.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + { /+ OEBPS/toc_nav.xhtml (navigation toc epub3) +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.source_filename); + File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); + } + fn = pth_epub3.fn_oebps_toc_nav_xhtml(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(oebps_toc_nav_xhtml.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + { /+ OEBPS/toc.ncx (navigation toc epub2) +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.source_filename); + File(fn_dbg, "w").writeln(oebps_toc_ncx); + } + fn = pth_epub3.fn_oebps_toc_ncx(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(oebps_toc_ncx.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + { /+ OEBPS/content.opf (doc manifest) +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.source_filename); + File(fn_dbg, "w").writeln(oebps_content_opf); + } + fn = pth_epub3.fn_oebps_content_opf(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(oebps_content_opf.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + { /+ OEBPS/_sisu/image (images) +/ + foreach (image; doc_matters.image_list) { + debug(epub_output) { + if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { + (doc_matters.src_path_info.image_root ~ "/" ~ image) + .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image); + } + } + } + foreach (image; doc_matters.image_list) { + debug(epub_output) { + debug(epub_images) { + writeln( + doc_matters.src_path_info.image_root, image, " -> ", + pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image + ); + } + } + auto fn_src = doc_matters.src_path_info.image_root ~ image; + auto fn_out = pth_epub3.doc_oebps_image(doc_matters.source_filename).to!string ~ "/" ~ image; + if (exists(fn_src)) { + { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_out; + auto zip_data = new OutBuffer(); + zip_data.write(cast(char[]) ((fn_src).read)); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + } + } + } + { /+ 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); + } + fn = pth_epub3.fn_oebps_css(doc_matters.source_filename); + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(css.epub_css.dup); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_epub, zip.build()); + } + } + catch (ErrnoException ex) { + // Handle error + } + debug(epub_archive) { + if (exists(fn_epub)) { + try { + auto zipped = new ZipArchive((fn_epub).read); + foreach (filename, member; zipped.directory) { + auto data = zipped.expand(member); + writeln(filename, " length ", data.length); + } + } + catch (ZipException ex) { + // Handle errors + } + } + } + } + +} diff --git a/src/sdp/output/html.d b/src/sdp/output/html.d new file mode 100644 index 0000000..6712469 --- /dev/null +++ b/src/sdp/output/html.d @@ -0,0 +1,447 @@ +module sdp.output.html; +template outputHTML() { + import sdp.output; + import + std.digest.sha, + std.file, + std.outbuffer, + std.zip, + std.conv : to; + import + sdp.output.create_zip_file, + sdp.output.xmls, + sdp.output.xmls_css; + mixin outputXHTMLs; + + void scroll(D,I)( + auto return ref const D doc_abstraction, + auto return ref I doc_matters, + ) { + mixin SiSUoutputRgxInit; + auto xhtml_format = outputXHTMLs(); + auto rgx = Rgx(); + string[] doc_html; + string[] doc; + string suffix = ".html"; + foreach (part; doc_matters.keys_seq.scroll) { + foreach (obj; doc_abstraction[part]) { + string _txt = xhtml_format.special_characters(obj, obj.text); + switch (obj.use) { + case "frontmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "heading": + doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix); + break; + case "toc": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "body": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "heading": + doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix); + break; + case "para": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + case "block": + switch (obj.is_a) { + case "quote": + doc_html ~= xhtml_format.quote_scroll(obj, _txt); + break; + case "group": + doc_html ~= xhtml_format.group_scroll(obj, _txt); + break; + case "block": + doc_html ~= xhtml_format.block_scroll(obj, _txt); + break; + case "poem": + break; + case "verse": + doc_html ~= xhtml_format.verse_scroll(obj, _txt, suffix); + break; + case "code": + doc_html ~= xhtml_format.code(obj, _txt); + break; + case "table": + doc_html ~= xhtml_format.table(obj, _txt); + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "backmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "heading": + doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix); + break; + case "endnote": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + case "glossary": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + case "bibliography": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + case "bookindex": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + case "blurb": + doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix); + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "comment": + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.use); + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } + break; + } + } + } + doc = xhtml_format.html_scroll_head(doc_matters) ~ doc_html ~ xhtml_format.tail; + scroll_write_output(doc_matters, doc); + } + void scroll_write_output(M,C)( + M doc_matters, + C doc, + ) { + debug(asserts) { + static assert(is(typeof(doc) == string[])); + } + string fn_src = doc_matters.source_filename; + auto src_path_info = doc_matters.src_path_info; + string fn_rel_pth = doc_matters.source_filename; + string lng = doc_matters.language; + auto pth_html = SiSUpathsHTML!()(src_path_info, lng); + try { + if (!exists(pth_html.base)) { + pth_html.base.mkdirRecurse; + } + auto f = File(pth_html.fn_scroll(fn_src), "w"); + foreach (o; doc) { + f.writeln(o); + } + } + catch (ErrnoException ex) { + // Handle error + } + } + void seg(D,I)( + auto return ref const D doc_abstraction, + auto return ref I doc_matters, + ) { + mixin SiSUoutputRgxInit; + auto rgx = Rgx(); + auto xhtml_format = outputXHTMLs(); + string[][string] doc_html; + string[][string] doc_html_endnotes; + string[] doc; + string segment_filename; + string[] top_level_headings = ["","","",""]; + string suffix = ".html"; + foreach (part; doc_matters.keys_seq.seg) { + foreach (obj; doc_abstraction[part]) { + string _txt = xhtml_format.special_characters(obj, obj.text); + if (obj.is_a == "heading") { + switch (obj.heading_lev_markup) { + case 0: .. case 3: + /+ fill buffer, and replace with new levels from 1 to 3 +/ + switch (obj.heading_lev_markup) { + case 0: + top_level_headings[0] = ""; + top_level_headings[1] = ""; + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 1: + top_level_headings[1] = ""; + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 2: + top_level_headings[2] = ""; + top_level_headings[3] = ""; + goto default; + case 3: + top_level_headings[3] = ""; + goto default; + default: + auto t = xhtml_format.heading_seg(obj, _txt, suffix); + top_level_headings[obj.heading_lev_markup] = t[0]; + break; + } + break; + case 4: + segment_filename = obj.segment_anchor_tag; + 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; + } + auto t = xhtml_format.heading_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case 5: .. case 7: + auto t = xhtml_format.heading_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case 8: .. case 9: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup); + } + break; + } + } else { + switch (obj.use) { + case "frontmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "toc": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + case "body": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "para": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + case "block": + switch (obj.is_a) { + case "quote": + auto t = xhtml_format.quote_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "group": + auto t = xhtml_format.group_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "block": + auto t = xhtml_format.block_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "poem": + break; + case "verse": + auto t = xhtml_format.verse_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= to!string(t[0]); + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "code": + doc_html[segment_filename] ~= xhtml_format.code(obj, _txt); + break; + case "table": + doc_html[segment_filename] ~= xhtml_format.table(obj, _txt); + doc_html_endnotes[segment_filename] ~= ""; + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "backmatter": + switch (obj.is_of) { + case "para": + switch (obj.is_a) { + case "endnote": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= t[0]; + break; + case "glossary": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= t[0]; + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "bibliography": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= t[0]; + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "bookindex": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= t[0]; + doc_html_endnotes[segment_filename] ~= t[1]; + break; + case "blurb": + auto t = xhtml_format.para_seg(obj, _txt, suffix); + doc_html[segment_filename] ~= t[0]; + doc_html_endnotes[segment_filename] ~= t[1]; + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_a); + } + break; + } + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.is_of); + } + break; + } + break; + case "comment": + break; + default: + if ((doc_matters.opt_action_bool["debug"])) { + writeln(__FILE__, ":", __LINE__, ": ", obj.use); + } + break; + } + } + } + } + seg_write_output(doc_matters, doc_html, doc_html_endnotes); + } + void seg_write_output(M,D,E)( + M doc_matters, + D doc_html, + E doc_html_endnotes, + ) { + debug(asserts) { + static assert(is(typeof(doc_html) == string[][string])); + } + mixin SiSUoutputRgxInit; + auto rgx = Rgx(); + auto src_path_info = doc_matters.src_path_info; + string fn_rel_pth = doc_matters.source_filename; + string lng = doc_matters.language; + auto pth_html = SiSUpathsHTML!()(src_path_info, lng); + auto xhtml_format = outputXHTMLs(); + auto m = doc_matters.source_filename.matchFirst(rgx.src_fn); + try { + if (!exists(pth_html.seg(doc_matters.source_filename))) { + pth_html.seg(doc_matters.source_filename).mkdirRecurse; + } + foreach (seg_filename; doc_matters.segnames) { + auto f = File(pth_html.fn_seg(doc_matters.source_filename, seg_filename), "w"); + foreach (docseg; doc_html[seg_filename]) { + f.writeln(docseg); + } + foreach (docseg; doc_html_endnotes[seg_filename]) { + f.writeln(docseg); + } + f.writeln(xhtml_format.tail); + } + } + catch (ErrnoException ex) { + // handle error + } + } + void css(M)( + auto return ref M doc_matters, + ) { + auto css = SiSUcss(); + auto pth_html = SiSUpathsHTML!()(doc_matters.src_path_info, doc_matters.language); + try { + if (!exists(pth_html.css)) { + (pth_html.css).mkdirRecurse; + } + auto f = File(pth_html.fn_css, "w"); + f.writeln(css.html_css); + } + catch (ErrnoException ex) { + // Handle error + } + } +} diff --git a/src/sdp/output/hub.d b/src/sdp/output/hub.d new file mode 100644 index 0000000..79b8996 --- /dev/null +++ b/src/sdp/output/hub.d @@ -0,0 +1,79 @@ +/++ + output hub<BR> + check & generate output types requested ++/ +module sdp.output.hub; +template outputHub() { + import sdp.output, + sdp.output.epub3, + sdp.output.html, + sdp.output.xmls, + sdp.output.source_sisupod, + sdp.output.create_zip_file, + sdp.output.paths_output; + void outputHub(D,I)(D doc_abstraction, I doc_matters) { + mixin SiSUoutputRgxInit; + auto rgx = Rgx(); + if ((doc_matters.opt_action_bool["verbose"])) { + writeln(doc_matters.keys_seq.seg); + } + if ((doc_matters.opt_action_bool["source"]) + || (doc_matters.opt_action_bool["sisupod"])) { + if ((doc_matters.opt_action_bool["verbose"]) + && (doc_matters.opt_action_bool["source"])) + { write("sisu source processing... "); } + if ((doc_matters.opt_action_bool["verbose"]) + && (doc_matters.opt_action_bool["sisupod"])) + { write("sisupod source processing... "); } + SiSUpod!()(doc_matters); + if ((doc_matters.opt_action_bool["verbose"]) + && (doc_matters.opt_action_bool["source"])) + { writeln("sisu source done"); } + if ((doc_matters.opt_action_bool["verbose"]) + && (doc_matters.opt_action_bool["sisupod"])) + { writeln("sisupod done"); } + } + if (doc_matters.opt_action_bool["text"]) { + /+ mixin outputText; +/ + writeln("text processing"); + } + if (doc_matters.opt_action_bool["html"]) { + if ((doc_matters.opt_action_bool["verbose"])) { write("html scroll processing... "); } + outputHTML!().scroll(doc_abstraction, doc_matters); + if ((doc_matters.opt_action_bool["verbose"])) { writeln("html scroll done"); } + if ((doc_matters.opt_action_bool["verbose"])) { write("html seg processing... "); } + outputHTML!().seg(doc_abstraction, doc_matters); + if ((doc_matters.opt_action_bool["verbose"])) { writeln("html seg done"); } + } else if (doc_matters.opt_action_bool["html_seg"]) { + if ((doc_matters.opt_action_bool["verbose"])) { write("html seg processing... "); } + outputHTML!().seg(doc_abstraction, doc_matters); + if ((doc_matters.opt_action_bool["verbose"])) { writeln("html seg done"); } + } else if (doc_matters.opt_action_bool["html_scroll"]) { + if ((doc_matters.opt_action_bool["verbose"])) { write("html scroll processing... "); } + outputHTML!().scroll(doc_abstraction, doc_matters); + if ((doc_matters.opt_action_bool["verbose"])) { writeln("html scroll done"); } + } + if (doc_matters.opt_action_bool["epub"]) { + if ((doc_matters.opt_action_bool["verbose"])) { write("epub3 processing... "); } + outputEPub3!()(doc_abstraction, doc_matters); + // epub.css_write; + if ((doc_matters.opt_action_bool["verbose"])) { writeln("epub3 done"); } + } + if (doc_matters.opt_action_bool["pdf"]) { + /+ mixin outputPDF; +/ + writeln("pdf processing"); + } + if (doc_matters.opt_action_bool["odt"]) { + /+ mixin outputODT; +/ + writeln("odt processing"); + } + if (doc_matters.opt_action_bool["sqlite"]) { + /+ mixin outputSQLite; +/ + writeln("sqlite processing"); + } + if (doc_matters.opt_action_bool["postgresql"]) { + /+ mixin outputPostgreSQL; +/ + writeln("pgsql processing"); + } + } +} diff --git a/src/sdp/output/package.d b/src/sdp/output/package.d new file mode 100644 index 0000000..58a6ae8 --- /dev/null +++ b/src/sdp/output/package.d @@ -0,0 +1,20 @@ +module sdp.output; +public import + std.algorithm, + std.array, + std.container, + std.exception, + std.path, + std.process, + std.range, + std.regex, + std.stdio, + std.string, + std.traits, + std.typecons, + // std.uni, + std.utf; +public import + sdp.output.defaults, + sdp.output.paths_output, + sdp.output.rgx; diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d new file mode 100644 index 0000000..3edcb67 --- /dev/null +++ b/src/sdp/output/paths_output.d @@ -0,0 +1,288 @@ +/++ + default settings ++/ +module sdp.output.paths_output; +import std.array, + std.path, + std.regex, + std.stdio; +import sdp.ao.rgx; +template SiSUpathsSisupod() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + string base_dir = "sisupod"; + string suffix = ".zip"; + auto SiSUpathsSisupod()() { + struct _PathsStruct { + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string sisupod_filename(string fn_src) { + return base_dir.chainPath(base_filename(fn_src) ~ suffix).array; + } + string base(string fn_src) { + return base_dir.chainPath(base_filename(fn_src)).array; + } + } + return _PathsStruct(); + } +} +template SiSUpathsSisupodZipped() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + auto SiSUpathsSisupodZipped(Ps,Lng)( + Ps src_pth_info, + Lng lng, + ) { + struct _PathsStruct { + auto spod_pths = SiSUpathsSisupod!()(); + string base_filename(string fn_src) { + return spod_pths.base_filename(fn_src); + } + string sisupod_filename(string fn_src) { + return spod_pths.sisupod_filename(fn_src); + } + string base(string fn_src) { + return spod_pths.base(fn_src); + } + auto pod_root(string fn_src) { + return "sisudoc"; + } + auto text_root(string fn_src) { + return pod_root(fn_src).chainPath("text").array; + } + auto media_root(string fn_src) { + return pod_root(fn_src).chainPath("docmedia").array; + } + auto conf_root(string fn_src) { + return pod_root(fn_src).chainPath("conf").array; + } + auto doc(string fn_src) { + return text_root(fn_src); + } + auto doc_lng(string fn_src) { + return text_root(fn_src).chainPath(lng).array; + } + auto image_root(string fn_src) { + return media_root(fn_src).chainPath("image").array; + } + auto css(string fn_src) { + return conf_root(fn_src).chainPath("css").array; + } + auto fn_doc(string fn_src) { + return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; + } + auto fn_doc_insert(string fn_src, string fn_insert) { + return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; + } + } + return _PathsStruct(); + } +} +template SiSUpathsSisupodFileSystem() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + auto SiSUpathsSisupodFileSystem(Ps,Lng)( + Ps src_pth_info, + Lng lng, + ) { + struct _PathsStruct { + auto spod_pths = SiSUpathsSisupod!()(); + string base_filename(string fn_src) { + return spod_pths.base_filename(fn_src); + } + string sisupod_filename(string fn_src) { + return spod_pths.sisupod_filename(fn_src); + } + string base(string fn_src) { + return spod_pths.base(fn_src); + } + auto pod_root(string fn_src) { + return base(fn_src).chainPath("sisudoc").array; + } + auto text_root(string fn_src) { + return pod_root(fn_src).chainPath("text").array; + } + auto media_root(string fn_src) { + return pod_root(fn_src).chainPath("docmedia").array; + } + auto conf_root(string fn_src) { + return pod_root(fn_src).chainPath("conf").array; + } + auto doc(string fn_src) { + return pod_root(fn_src); + } + auto doc_lng(string fn_src) { + return text_root(fn_src).chainPath(lng).array; + } + auto image_root(string fn_src) { + return media_root(fn_src).chainPath("image").array; + } + auto css(string fn_src) { + return conf_root(fn_src).chainPath("css").array; + } + auto fn_doc(string fn_src) { + return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; + } + auto fn_doc_insert(string fn_src, string fn_insert) { + return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; + } + } + return _PathsStruct(); + } +} +template SiSUoutPaths() { + auto SiSUoutPaths(Ps,Lng)( + Ps src_pth_info, + Lng lng, + ) { + struct _PathsStruct { + string output_root() { + return "sisugen"; + } + string output_base() { + return output_root.chainPath(lng).array; + } + } + return _PathsStruct(); + } +} +template SiSUpathsHTML() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + auto SiSUpathsHTML(Ps,Lng)( + Ps src_pth_info, + Lng lng, + ) { + auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + string base_dir = "html"; + string suffix = ".html"; + struct _PathsStruct { + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string base() { + return (out_pth.output_base).chainPath(base_dir).array; + } + string image() { + return (out_pth.output_root).chainPath("image").array; + } + string css() { + return (out_pth.output_root).chainPath("css").array; + } + string fn_css() { + return css.chainPath("html.css").array; + } + string seg(string fn_src) { + return base.chainPath(base_filename(fn_src)).array; + } + string fn_scroll(string fn_src) { + return base.chainPath(base_filename(fn_src) ~ suffix).array; + } + string fn_seg(string fn_src, string seg_filename) { + return seg(fn_src).chainPath(seg_filename ~ suffix).array; + } + } + return _PathsStruct(); + } +} +template SiSUpathsEPUB() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + auto SiSUpathsEPUB(Ps,Lng)( + Ps src_pth_info, + Lng lng, + ) { + auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + string base_dir = "epub"; + struct _PathsStruct { + string base() { + return (out_pth.output_base).chainPath(base_dir).array; + } + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string epub_file(string fn_src) { + return base.chainPath(base_filename(fn_src) ~ ".epub").array; + } + string dirtop() { + return "".chainPath("").array; + } + string doc_meta_inf(string fn_src) { + return dirtop.chainPath("META-INF").array; + } + string doc_oebps(string fn_src) { + return dirtop.chainPath("OEBPS").array; + } + string doc_oebps_css(string fn_src) { + return doc_oebps(fn_src).chainPath("css").array; + } + string doc_oebps_image(string fn_src) { + return doc_oebps(fn_src).chainPath("image").array; + } + string fn_mimetypes(string fn_src) { + return dirtop.chainPath("mimetypes").array; + } + string fn_dmi_container_xml(string fn_src) { + return doc_meta_inf(fn_src).chainPath("container.xml").array; + } + string fn_oebps_toc_nav_xhtml(string fn_src) { + return doc_oebps(fn_src).chainPath("toc_nav.xhtml").array; + } + string fn_oebps_toc_ncx(string fn_src) { + return doc_oebps(fn_src).chainPath("toc.ncx").array; + } + string fn_oebps_content_opf(string fn_src) { + return doc_oebps(fn_src).chainPath("content.opf").array; + } + string fn_oebps_content_xhtml(string fn_src, string seg_filename) { + return doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; + } + string fn_oebps_css(string fn_src) { + return doc_oebps_css(fn_src).chainPath("epub.css").array; + } + debug(epub_output) { + string dbg_docdir(string fn_src) { + return base.chainPath(base_filename(fn_src)).array; + } + string dbg_docdir_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_meta_inf(string fn_src) { + return dbg_docdir(fn_src).chainPath("META-INF").array; + } + string dbg_doc_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_oebps_css(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("css").array; + } + string dbg_doc_oebps_image(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("image").array; + } + string dbg_fn_mimetypes(string fn_src) { + return dbg_docdir(fn_src).chainPath("mimetypes").array; + } + string dbg_fn_dmi_container_xml(string fn_src) { + return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; + } + string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; + } + string dbg_fn_oebps_toc_ncx(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; + } + string dbg_fn_oebps_content_opf(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; + } + string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { + return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; + } + string dbg_fn_oebps_css(string fn_src) { + return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; + } + } + } + return _PathsStruct(); + } +} diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d new file mode 100644 index 0000000..7658df5 --- /dev/null +++ b/src/sdp/output/paths_source.d @@ -0,0 +1,60 @@ +/++ + read configuration files<BR> + - read config files<BR> + ao_config_files.d ++/ +module sdp.output.paths_source; +import std.array, + std.path, + std.regex, + std.stdio; +import sdp.ao.rgx; +template SiSUpathsSRC() { + mixin SiSUrgxInit; + auto rgx = Rgx(); + auto SiSUpathsSRC(D,Fn)( + D _pwd, + Fn _fn_src, + ) { + struct SisuSrcPaths { + auto pwd() { + return _pwd; + } + auto language() { + // use command line info as well? + string _k; + if (auto m = _fn_src.match(rgx.language_code_and_filename)) { + _k = m.captures[1]; + } else { + _k = "en"; + } + return _k; + } + auto doc_root() { + return "sisudoc"; + } + auto text_root() { + return doc_root.chainPath("text").array; + } + auto media_root() { + return doc_root.chainPath("docmedia").array; + } + auto conf_root() { + return doc_root.chainPath("conf").array; + } + auto image_root() { + return media_root.chainPath("image").array; + } + auto doc_src_fn_with_path_for_text_root_and_lng() { + return text_root.chainPath(language).array; + } + auto doc_src_with_relative_path() { + return pwd.chainPath(_fn_src).array; + } + auto doc_src_fn() { + return _fn_src.baseName.array; + } + } + return SisuSrcPaths(); + } +} diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d new file mode 100644 index 0000000..6fdc876 --- /dev/null +++ b/src/sdp/output/rgx.d @@ -0,0 +1,73 @@ +/++ + regex: regular expressions used in sisu document parser ++/ +module sdp.output.rgx; +template SiSUoutputRgxInit() { + import sdp.output.defaults; + struct Rgx { + static newline = ctRegex!("\n", "mg"); + static strip_br = ctRegex!("^<br>\n|<br>\n*$"); + static space = ctRegex!(`[ ]`, "mg"); + static spaces_line_start = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg"); + static spaces_multiple = ctRegex!(`(?P<multiple_spaces>[ ]{2,})`, "mg"); + static two_spaces = ctRegex!(`[ ]{2}`, "mg"); + static nbsp_char = ctRegex!(`░`, "mg"); + static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); + static nbsp_and_space = ctRegex!(` [ ]`, "mg"); + static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); + static src_pth = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_fn = + ctRegex!(`^([a-zA-Z0-9._-]+/)*(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); + static src_fn_master = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); + static src_fn_text = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]sst)$`); + static src_fn_insert = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssi)$`); + static src_fn_find_inserts = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); + static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); + /+ inline markup footnotes endnotes +/ + static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); + static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); + static inline_al_delimiter_open_regular = ctRegex!(`【\s`, "m"); + static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); + static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); + static inline_al_delimiter_close_regular = ctRegex!(`】`, "m"); + static inline_al_delimiter_open_and_close_regular = ctRegex!(`【|】`, "m"); + static inline_notes_delimiter_al_regular = ctRegex!(`【(.+?)】`, "mg"); + static inline_notes_delimiter_al_regular_number_note = ctRegex!(`【(\d+)\s+(.+?)】`, "mg"); + static inline_al_delimiter_open_asterisk = ctRegex!(`【\*`, "m"); + static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); + static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg"); + static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); + /+ inline markup footnotes endnotes +/ + static inline_link = ctRegex!(`┥(.+?)┝┤(.+?)├`, "mg"); + static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); + static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); + static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); + static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); + static mark_internal_site_lnk = ctRegex!(`¤`, "mg"); + /+ inline markup font face mod +/ + static inline_faces = ctRegex!(`(?P<markup>(?P<mod>[*!_^,+#-])\{(?P<text>.+?)\}[*!_^,+#-])`, "mg"); + static inline_emphasis = ctRegex!(`\*\{(?P<text>.+?)\}\*`, "mg"); + static inline_bold = ctRegex!(`!\{(?P<text>.+?)\}!`, "mg"); + static inline_underscore = ctRegex!(`_\{(?P<text>.+?)\}_`, "mg"); + static inline_italics = ctRegex!(`/\{(?P<text>.+?)\}/`, "mg"); + static inline_superscript = ctRegex!(`\^\{(?P<text>.+?)\}\^`, "mg"); + static inline_subscript = ctRegex!(`,\{(?P<text>.+?)\},`, "mg"); + static inline_strike = ctRegex!(`-\{(?P<text>.+?)\}-`, "mg"); + static inline_insert = ctRegex!(`\+\{(?P<text>.+?)\}\+`, "mg"); + static inline_mono = ctRegex!(`#\{(?P<text>.+?)\}#`, "mg"); + static inline_cite = ctRegex!(`"\{(?P<text>.+?)\}"`, "mg"); + static inline_faces_line = ctRegex!(`^[*!/_]_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); + static inline_emphasis_line = ctRegex!(`^\*_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); + static inline_bold_line = ctRegex!(`^!_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); + static inline_italics_line = ctRegex!(`^/_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); + static inline_underscore_line = ctRegex!(`^__ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); + /+ table delimiters +/ + static table_delimiter_col = ctRegex!("[ ]*[┊][ ]*", "mg"); + static table_delimiter_row = ctRegex!("[ ]*\n", "mg"); + static xhtml_ampersand = ctRegex!(`[&]`); // & + static xhtml_quotation = ctRegex!(`[&]`); // " + static xhtml_less_than = ctRegex!(`[<]`); // < + static xhtml_greater_than = ctRegex!(`[>]`); // > + static xhtml_line_break = ctRegex!(` [\\]{2}`); // <br /> + } +} diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d new file mode 100644 index 0000000..6c326ac --- /dev/null +++ b/src/sdp/output/source_sisupod.d @@ -0,0 +1,208 @@ +module sdp.output.source_sisupod; +template SiSUpod() { + import sdp.output; + import + std.digest.sha, + std.file, + std.outbuffer, + std.zip, + std.conv : to; + import + sdp.output.create_zip_file, + sdp.output.xmls; + void SiSUpod(T)(T doc_matters) { + debug(asserts) { + // static assert(is(typeof(doc_matters) == tuple)); + } + mixin SiSUoutputRgxInit; + string pwd = doc_matters.environment["pwd"]; + auto src_path_info = doc_matters.src_path_info; + string lng = doc_matters.language; + auto pth_sisudoc_src = doc_matters.src_path_info; + auto pth_sisupod = SiSUpathsSisupodZipped!()(src_path_info, lng); + auto pth_sisupod_filesystem = SiSUpathsSisupodFileSystem!()(src_path_info, lng); + mixin SiSUlanguageCodes; + auto lang = Lang(); + auto rgx = Rgx(); + assert (doc_matters.source_filename.match(rgx.src_fn)); + try { + /+ create directory structure +/ + if (doc_matters.opt_action_bool["source"]) { + if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) { + pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_sisupod_filesystem.conf_root(doc_matters.source_filename))) { + pth_sisupod_filesystem.conf_root(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_sisupod_filesystem.media_root(doc_matters.source_filename))) { + pth_sisupod_filesystem.media_root(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_sisupod_filesystem.css(doc_matters.source_filename))) { + pth_sisupod_filesystem.css(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_sisupod_filesystem.image_root(doc_matters.source_filename))) { + pth_sisupod_filesystem.image_root(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_sisupod_filesystem.doc_lng(doc_matters.source_filename))) { + pth_sisupod_filesystem.doc_lng(doc_matters.source_filename).mkdirRecurse; + } + } + debug(sisupod) { + writeln(__LINE__, ": ", + doc_matters.source_filename, " -> ", + pth_sisupod_filesystem.fn_doc( + doc_matters.source_filename, + )); + } + auto zip = new ZipArchive(); + auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); + { /+ bundle images +/ + foreach (image; doc_matters.image_list) { + debug(sisupodimages) { + writeln( + pth_sisudoc_src.image_root.to!string, "/", image, " -> ", + pth_sisupod.image_root(doc_matters.source_filename), "/", image + ); + } + auto fn_src = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; + auto fn_out = pth_sisupod.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; + auto fn_out_filesystem = pth_sisupod_filesystem.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; + if (exists(fn_src)) { + if (doc_matters.opt_action_bool["source"]) { + fn_src.copy(fn_out_filesystem); + } + if (doc_matters.opt_action_bool["sisupod"]) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_out; + auto zip_data = new OutBuffer(); + zip_data.write(cast(char[]) ((fn_src).read)); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); + } + } + } + } + { /+ bundle sisu_document_make +/ + auto fn_src = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) + auto fn_out = pth_sisupod.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; + auto fn_out_filesystem = pth_sisupod_filesystem.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; + if (exists(fn_src)) { + if (doc_matters.opt_action_bool["source"]) { + fn_src.copy(fn_out_filesystem); + } + if (doc_matters.opt_action_bool["sisupod"]) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_out; + auto zip_data = new OutBuffer(); + zip_data.write((fn_src).readText); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); + } + } + } + { /+ bundle primary file +/ + auto fn_src = doc_matters.source_filename; + auto fn_out = pth_sisupod.fn_doc(doc_matters.source_filename).to!string; + auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc(doc_matters.source_filename).to!string; + if (exists(fn_src)) { + if (doc_matters.opt_action_bool["source"]) { + fn_src.copy(fn_out_filesystem); + } + if (doc_matters.opt_action_bool["sisupod"]) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_out; + auto zip_data = new OutBuffer(); + zip_data.write((fn_src).readText); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); + } + } + } + { /+ bundle insert files +/ + if (doc_matters.file_insert_list.length > 0) { + foreach (insert_file; doc_matters.file_insert_list) { + debug(sisupod) { + writeln( + insert_file, " -> ", + pth_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + )); + } + auto fn_src = insert_file; + auto fn_out = pth_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).to!string; + auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).to!string; + if (exists(fn_src)) { + if (doc_matters.opt_action_bool["source"]) { + fn_src.copy(fn_out_filesystem); + } + if (doc_matters.opt_action_bool["sisupod"]) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = insert_file; + auto zip_data = new OutBuffer(); + zip_data.write((fn_src).readText); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); + } + } + } + } + } + if (exists(fn_sisupod)) { + try { + auto data = (cast(byte[]) (fn_sisupod).read); + writefln("%-(%02x%) %s", data.sha256Of, fn_sisupod); + debug(sisupod) { + try { + auto zipped = new ZipArchive((fn_sisupod).read); + foreach (filename, member; zipped.directory) { + auto data = zipped.expand(member); + writeln("> ", filename, " length ", data.length); + } + } + catch (ZipException ex) { + // Handle errors + } + if (doc_matters.source_filename == "sisudoc/text/en/the_wealth_of_networks.yochai_benkler.sst") { + assert( + ((data).sha256Of).toHexString + == "626F83A31ED82F42CF528E922C1643498A137ABA3F2E5AFF8A379EA79EA22A1E", + "\nsisupod: sha256 value for " + ~ doc_matters.source_filename + ~ " has changed, is now: " + ~ ((data).sha256Of).toHexString + ); + } + if (doc_matters.source_filename == "sisudoc/text/en/sisu_markup_stress_test.sst") { + assert( + ((data).sha256Of).toHexString + == "AAE0C87AB3F6D5F7385AEEA6EE661F56D40475CFE87AD930C78C9FE07FFB0D91", + "\nsisupod: sha256 value for " + ~ doc_matters.source_filename + ~ " has changed, is now: " + ~ ((data).sha256Of).toHexString + ); + } + } + } + catch (ErrnoException ex) { + // Handle errors + } + } + + } + catch (ErrnoException ex) { + // Handle error + } + } +} diff --git a/src/sdp/output/xmls.d b/src/sdp/output/xmls.d new file mode 100644 index 0000000..7a057ad --- /dev/null +++ b/src/sdp/output/xmls.d @@ -0,0 +1,800 @@ +module sdp.output.xmls; +template outputXHTMLs() { + import sdp.output; + import + std.digest.sha, + std.file, + std.outbuffer, + std.zip, + std.conv : to; + import + sdp.output.create_zip_file, + sdp.output.xmls, + sdp.output.xmls_css; + mixin SiSUoutputRgxInit; + struct outputXHTMLs { + auto rgx = Rgx(); + string special_characters(O)( + auto return ref const O obj, + string _txt + ){ + _txt = (_txt) + .replaceAll(rgx.xhtml_ampersand, "&") + .replaceAll(rgx.xhtml_quotation, """) + .replaceAll(rgx.xhtml_less_than, "<") + .replaceAll(rgx.xhtml_greater_than, ">") + .replaceAll(rgx.nbsp_char, " "); + if (!(obj.is_a == "code")) { + _txt = (_txt) + .replaceAll(rgx.xhtml_line_break, "<br />"); + } + return _txt; + } + string font_face(string _txt){ + _txt = (_txt) + .replaceAll(rgx.inline_emphasis, ("<em>$1</em>")) + .replaceAll(rgx.inline_bold, ("<b>$1</b>")) + .replaceAll(rgx.inline_underscore, ("<u>$1</u>")) + .replaceAll(rgx.inline_italics, ("<i>$1</i>")) + .replaceAll(rgx.inline_superscript, ("<sup>$1</sup>")) + .replaceAll(rgx.inline_subscript, ("<sub>$1</sub>")) + .replaceAll(rgx.inline_strike, ("<del>$1</del>")) + .replaceAll(rgx.inline_insert, ("<ins>$1</ins>")) + .replaceAll(rgx.inline_mono, ("<tt>$1</tt>")) + .replaceAll(rgx.inline_cite, ("<cite>$1</cite>")); + return _txt; + } + string _xhtml_anchor_tags(const(string[]) anchor_tags) { + string tags=""; + if (anchor_tags.length > 0) { + foreach (tag; anchor_tags) { + if (!(tag.empty)) { + tags ~= "<a name=\"" ~ tag ~ "\"></a>"; + } + } + } + return tags; + } + auto html_scroll_head(Dm)( + Dm doc_matters, + ) { + string o; + o = format(q"¶<!DOCTYPE html> + <html> + <head> + <meta charset="utf-8"> + <title> + %s%s + </title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <meta name="dc.title" content="Title" /> + <meta name="dc.author" content="Author" /> + <meta name="dc.publisher" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> + <meta name="dc.date" content="year" /> + <meta name="dc.date.created" content="year" /> + <meta name="dc.date.issued" content="year" /> + <meta name="dc.date.available" content="year" /> + <meta name="dc.date.valid" content="year" /> + <meta name="dc.date.modified" content="year" /> + <meta name="dc.language" content="US" /> + <meta name="dc.rights" content="Copyright: Copyright (C) year holder /> + <meta name="generator" content="sdp [SiSU 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)" /> + </meta> + <link rel="generator" href="http://www.sisudoc.org/" /> + <link rel="shortcut icon" href="../../image/rb7.ico" /> + <link href="../../css/html.css" rel="stylesheet" /> + <link href="../../../css/html.css" rel="stylesheet" /> + </head> + <body lang="%s"> + <a name="top" id="top"></a>¶", + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + ); + return o; + } + auto html_seg_head(Dm)( + Dm doc_matters, + ) { + string o; + o = format(q"¶<!DOCTYPE html> + <html> + <head> + <meta charset="utf-8"> + <title> + %s%s + </title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <meta name="dc.title" content="Title" /> + <meta name="dc.author" content="Author" /> + <meta name="dc.publisher" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> + <meta name="dc.date" content="year" /> + <meta name="dc.date.created" content="year" /> + <meta name="dc.date.issued" content="year" /> + <meta name="dc.date.available" content="year" /> + <meta name="dc.date.valid" content="year" /> + <meta name="dc.date.modified" content="year" /> + <meta name="dc.language" content="US" /> + <meta name="dc.rights" content="Copyright: Copyright (C) year holder" /> + <meta name="generator" content="sdp [SiSU 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)" /> + </meta> + <link rel="generator" href="http://www.sisudoc.org/" /> + <link rel="shortcut icon" href="../../image/rb7.ico" /> + <link href="../../css/html.css" rel="stylesheet" /> + <link href="../../../css/html.css" rel="stylesheet" /> + </head> + <body lang="%s"> + <a name="top" id="top"></a>¶", + doc_matters.dochead_meta["title"]["full"], + (doc_matters.dochead_meta["creator"]["author"].empty) ? "" + : ", " ~ doc_matters.dochead_meta["creator"]["author"], + doc_matters.language, + ); + return o; + } + auto epub3_seg_head(Dm)( + Dm doc_matters, + ) { + string html_base = format(q"¶<!DOCTYPE html> + <html>¶", + ); + string html_simple = format(q"¶<!DOCTYPE html> + <html + xmlns="http://www.w3.org/1999/xhtml" + xmlns:epub="http://www.idpf.org/2007/ops" + lang="%s" xml:lang="%s">¶", + doc_matters.language, + doc_matters.language, + ); + string html_strict = format(q"¶<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" + xmlns:epub="http://www.idpf.org/2007/ops" + lang="%s" xml:lang="%s">¶", + doc_matters.language, + doc_matters.language, + ); + string o; + o = format(q"¶%s + <head> + <title> + %s%s + </title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <meta name="dc.title" content="%s" /> + <meta name="dc.author" content="%s" /> + <meta name="dc.publisher" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> + <meta name="dc.date" content="year" /> + <meta name="dc.date.created" content="year" /> + <meta name="dc.date.issued" content="year" /> + <meta name="dc.date.available" content="year" /> + <meta name="dc.date.valid" content="year" /> + <meta name="dc.date.modified" content="year" /> + <meta name="dc.language" content="US" /> + <meta name="dc.rights" content="Copyright: Copyright (C) year holder" /> + <meta name="generator" content="sdp [SiSU 7.1.8 of 2016w08/5 (2016-02-26)] (n*x and D)" /> + <link rel="generator" href="http://www.sisudoc.org/" /> + <link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> + <link rel="stylesheet" href="css/epub.css" type="text/css" id="main-css" /> + </head> + <body lang="%s"> + <a name="top" id="top"></a>¶", + 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; + } + auto tail() { + string o; + o = format(q"¶ <a name="bottom" id="bottom"></a> + <a name="end" id="end"></a> + </body> + </html>¶"); + return o; + } + auto inline_links(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + string seg_scroll = "seg", + ) { + if (obj.inline_links) { + if ((seg_scroll == "scroll") + && _txt.match(rgx.mark_internal_site_lnk)) { + _txt = (_txt).replaceAll( + rgx.inline_seg_link, + "$1"); + } + _txt = (_txt).replaceAll( + rgx.inline_link_fn_suffix, + ("$1" ~ _suffix)); + _txt = (_txt).replaceAll( + rgx.inline_link, + ("<a href=\"$2\">$1</a>")); + _txt = (_txt).replaceAll( + rgx.mark_internal_site_lnk, + "" + ); + } + debug(markup_links) { + if (_txt.match(rgx.inline_link)) { + writeln(__LINE__, + " (missed) markup link identified (", + obj.inline_links, + "): ", obj.is_a, ": ", + obj.text + ); + } + } + debug(markup) { + if (_txt.match(rgx.inline_link)) { + writeln(__LINE__, + " (missed) markup link identified (", + obj.inline_links, + "): ", obj.is_a, ": ", + obj.text + ); + } + } + return _txt; + } + auto inline_notes_scroll(O)( + auto return ref const O obj, + string _txt, + ) { + if (obj.inline_notes_reg) { + _txt = (_txt).replaceAll( + rgx.inline_notes_delimiter_al_regular_number_note, + ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") + ); + } + debug(markup_endnotes) { + if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text); + } + } + debug(markup) { + if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text); + } + } + return _txt; + } + auto inline_notes_seg(O)( + auto return ref const O obj, + string _txt, + ) { + string[] _endnotes; + if (obj.inline_notes_reg) { + /+ need markup for text, and separated footnote +/ + foreach(m; _txt.matchAll(rgx.inline_notes_delimiter_al_regular_number_note)) { + _endnotes ~= format( + "%s%s%s%s\n %s%s%s%s%s\n %s\n%s", + "<p class=\"endnote\">", + "<a href=\"#noteref_", + m.captures[1], + "\">", + "<note id=\"note_", + m.captures[1], + "\"> <sup>", + m.captures[1], + ".</sup></note></a>", + m.captures[2], + "</p>" + ); + } + _txt = (_txt).replaceAll( + rgx.inline_notes_delimiter_al_regular_number_note, + ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") + ); + } else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + debug(markup) { + writeln(__LINE__, " endnote: ", obj.is_a, ": ", obj.text); + } + } + auto t = tuple( + _txt, + _endnotes, + ); + return t; + } + auto inline_markup_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + _txt = inline_links(obj, _txt, _suffix, "scroll"); + _txt = inline_notes_scroll(obj, _txt); + return _txt; + } + auto inline_markup_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + _txt = inline_links(obj, _txt, _suffix, "seg"); + auto t = inline_notes_seg(obj, _txt); + return t; + } + auto toc_seg(O)( + auto return ref const O obj, + string _txt, + ) { + string o; + o = format(q"¶ <div class="substance"> + <p class="%s" indent="h%si%s"> + %s + </p> + </div>¶", + obj.is_a, + obj.indent_hang, + obj.indent_base, + _txt, + ); + return 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 = "<hr />"; + if ((_type != "html") + || (obj.heading_lev_markup == 0 || obj.heading_lev_markup > 4)) { + _horizontal_rule = ""; + } + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶%s + <div class="substance"> + <h%s class="%s">%s + %s + </h%s> + </div>¶", + _horizontal_rule, + obj.heading_lev_markup, + obj.is_a, + tags, + _txt, + obj.heading_lev_markup, + ); + } else { + 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 + %s + </h%s> + </div>¶", + _horizontal_rule, + obj.obj_cite_number, + obj.obj_cite_number, + obj.heading_lev_markup, + obj.is_a, + obj.obj_cite_number, + obj.obj_cite_number, + tags, + _txt, + obj.heading_lev_markup, + ); + } + return o; + } + auto heading_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = heading(obj, _txt); + return o; + } + 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, _type); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto para(O)( + auto return ref const O obj, + string _txt, + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = font_face(_txt); + string o; + _txt = (obj.bullet) ? ("●  " ~ _txt) : _txt; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s" indent="h%si%s">%s + %s + </p> + </div>¶", + obj.is_a, + obj.indent_hang, + obj.indent_base, + tags, + _txt + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" indent="h%si%s" id="%s">%s + %s + </p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.indent_hang, + obj.indent_base, + obj.obj_cite_number, + tags, + _txt + ); + } + return o; + } + auto para_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = para(obj, _txt); + return o; + } + auto para_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto t = inline_markup_seg(obj, _txt, _suffix); + _txt = to!string(t[0]); + string[] _endnotes = t[1]; + string o = para(obj, _txt); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto quote(O)( + auto return ref const O obj, + string _txt, + ) { + _txt = font_face(_txt); + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s"> + %s + </p> + </div>¶", + obj.is_a, + _txt + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s"> + %s + </p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt + ); + } + return o; + } + auto quote_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = quote(obj, _txt); + return o; + } + auto quote_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto t = inline_markup_seg(obj, _txt, _suffix); + _txt = to!string(t[0]); + string[] _endnotes = t[1]; + string o = quote(obj, _txt); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto group(O)( + auto return ref const O obj, + string _txt, + ) { + _txt = font_face(_txt); + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s"> + %s + </p> + </div>¶", + obj.is_a, + _txt + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s"> + %s + </p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt + ); + } + return o; + } + auto group_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = group(obj, _txt); + return o; + } + auto group_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto t = inline_markup_seg(obj, _txt, _suffix); + _txt = to!string(t[0]); + string[] _endnotes = t[1]; + string o = group(obj, _txt); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto block(O)( + auto return ref const O obj, + string _txt, + ) { + _txt = font_face(_txt); + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s">%s</p> + </div>¶", + obj.is_a, + _txt.stripRight + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s">%s</p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt.stripRight + ); + } + return o; + } + auto block_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = block(obj, _txt); + return o; + } + auto block_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto t = inline_markup_seg(obj, _txt, _suffix); + _txt = to!string(t[0]); + string[] _endnotes = t[1]; + string o = block(obj, _txt); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto verse(O)( + auto return ref const O obj, + string _txt, + ) { + _txt = font_face(_txt); + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s">%s</p> + </div>¶", + obj.is_a, + _txt + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s">%s</p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt + ); + } + return o; + } + auto verse_scroll(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = inline_markup_scroll(obj, _txt, _suffix); + string o = verse(obj, _txt); + return o; + } + auto verse_seg(O)( + auto return ref const O obj, + string _txt, + string _suffix = ".html", + ) { + auto t = inline_markup_seg(obj, _txt, _suffix); + _txt = to!string(t[0]); + string[] _endnotes = t[1]; + string o = verse(obj, _txt); + auto u = tuple( + o, + _endnotes, + ); + return u; + } + auto tablarize(O)( + auto return ref const O obj, + string _txt, + ) { + string[] _table_rows = (_txt).split(rgx.table_delimiter_row); + string[] _table_cols; + string _table; + string _tablenote; + foreach(row_idx, row; _table_rows) { + _table_cols = row.split(rgx.table_delimiter_col); + _table ~= "<tr>"; + foreach(col_idx, cell; _table_cols) { + if ((_table_cols.length == 1) + && (_table_rows.length <= row_idx+2)) { + _tablenote ~= cell; + } else { + string _col_is = (row_idx == 0 && obj.table_heading) ? "th" : "td"; + string _align = ("style=\"text-align:" + ~ ((obj.table_column_aligns[col_idx] == "l") + ? "left\"" : "right\"")); + _table ~= "<" ~ _col_is ~ " width=\"" ~ obj.table_column_widths[col_idx].to!string ~ "%\" " ~ _align ~ ">"; + _table ~= cell; + _table ~= "</" ~ _col_is ~ ">"; + } + } + _table ~= "</tr>"; + } + auto t = tuple( + _table, + _tablenote, + ); + return t; + } + auto table(O)( + auto return ref const O obj, + string _txt, + ) { + auto tags = _xhtml_anchor_tags(obj.anchor_tags); + _txt = font_face(_txt); + auto t = tablarize(obj, _txt); + _txt = t[0]; + string _note = t[1]; + string o; + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s">%s + <table summary="normal text css" width="95%%" border="0" bgcolor="white" cellpadding="2" align="center"> + %s + </table> + %s + </p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + tags, + _txt, + _note + ); + return o; + } + auto endnote(O)( + auto return ref const O obj, + string _txt, + ) { + string o; + o = format(q"¶ <p class="%s" indent="h%si%s"> + %s + </p>¶", + obj.is_a, + obj.indent_hang, + obj.indent_base, + _txt + ); + return o; + } + auto code(O)( + auto return ref const O obj, + string _txt, + ) { + string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶ <div class="substance"> + <p class="%s">%s</p> + </div>¶", + obj.is_a, + _txt + ); + } else { + o = format(q"¶ <div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" id="%s">%s</p> + </div>¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.obj_cite_number, + _txt + ); + } + return o; + } + } +} diff --git a/src/sdp/output/xmls_css.d b/src/sdp/output/xmls_css.d new file mode 100644 index 0000000..6bb493a --- /dev/null +++ b/src/sdp/output/xmls_css.d @@ -0,0 +1,869 @@ +/++ + default css settings ++/ +module sdp.output.xmls_css; +template SiSUcss() { + auto SiSUcss() { + string css_shared=" + body { + color: black; + background: #ffffff; + background-color: #ffffff; + } + a:link { + color: #003399; + text-decoration: none; + } + a:visited { + color: #003399; + text-decoration: none; + } + a:hover { + color: #000000; + background-color: #f9f9aa; + } + a.lnkocn:link { + color: #777777; + text-decoration: none; + } + a:hover img { + background-color: #ffffff; + } + a:active { + color: #003399; + text-decoration: underline; + } + div { + margin-left: 0; + margin-right: 0; + } + div.p { + margin-left: 5%; + margin-right: 1%; + } + .norm, .bold, .verse, .group, .block, .alt { + line-height: 133%; + margin-left: 0em; + margin-right: 2em; + margin-top: 12px; + margin-bottom: 0px; + padding-left: 0em; + text-indent: 0em; + } + p, h0, h1, h2, h3, h4, h5, h6, h7 { + display: block; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; + font-size: 100%; + font-weight: normal; + line-height: 133%; + text-align: justify; + margin-left: 0em; + margin-right: 2em; + text-indent: 0mm; + margin-top: 0.8em; + margin-bottom: 0.8em; + } + /* spaced */ + p.spaced { white-space: pre; } + /* indent */ + p.norm { } + p.i1 { padding-left: 1em; } + p.i2 { padding-left: 2em; } + p.i3 { padding-left: 3em; } + p.i4 { padding-left: 4em; } + p.i5 { padding-left: 5em; } + p.i6 { padding-left: 6em; } + p.i7 { padding-left: 7em; } + p.i8 { padding-left: 8em; } + p.i9 { padding-left: 9em; } + /* hanging indent */ + p[indent=\"h0i0\"] { + padding-left: 0em; + text-indent: 0em; + } + p[indent=\"h0i1\"] { + padding-left: 1em; + text-indent: -1em; + } + p[indent=\"h0i2\"] { + padding-left: 2em; + text-indent: -2em; + } + p[indent=\"h0i3\"] { + padding-left: 3em; + text-indent: -3em; + } + p[indent=\"h0i4\"] { + padding-left: 4em; + text-indent: -4em; + } + p[indent=\"h0i5\"] { + padding-left: 5em; + text-indent: -5em; + } + p[indent=\"h0i6\"] { + padding-left: 6em; + text-indent: -6em; + } + p[indent=\"h0i7\"] { + padding-left: 7em; + text-indent: -7em; + } + p[indent=\"h0i8\"] { + padding-left: 8em; + text-indent: -8em; + } + p[indent=\"h0i9\"] { + padding-left: 9em; + text-indent: -9em; + } + p[indent=\"h1i0\"] { + padding-left: 0em; + text-indent: 1em; + } + p[indent=\"h1i1\"] { + padding-left: 1em; + text-indent: 0em; + } + p[indent=\"h1i2\"] { + padding-left: 2em; + text-indent: -1em; + } + p[indent=\"h1i3\"] { + padding-left: 3em; + text-indent: -2em; + } + p[indent=\"h1i4\"] { + padding-left: 4em; + text-indent: -3em; + } + p[indent=\"h1i5\"] { + padding-left: 5em; + text-indent: -4em; + } + p[indent=\"h1i6\"] { + padding-left: 6em; + text-indent: -5em; + } + p[indent=\"h1i7\"] { + padding-left: 7em; + text-indent: -6em; + } + p[indent=\"h1i8\"] { + padding-left: 8em; + text-indent: -7em; + } + p[indent=\"h1i9\"] { + padding-left: 9em; + text-indent: -8em; + } + p[indent=\"h2i0\"] { + padding-left: 0em; + text-indent: 2em; + } + p[indent=\"h2i1\"] { + padding-left: 1em; + text-indent: 1em; + } + p[indent=\"h2i2\"] { + padding-left: 2em; + text-indent: 0em; + } + p[indent=\"h2i3\"] { + padding-left: 3em; + text-indent: -1em; + } + p[indent=\"h2i4\"] { + padding-left: 4em; + text-indent: -2em; + } + p[indent=\"h2i5\"] { + padding-left: 5em; + text-indent: -3em; + } + p[indent=\"h2i6\"] { + padding-left: 6em; + text-indent: -4em; + } + p[indent=\"h2i7\"] { + padding-left: 7em; + text-indent: -5em; + } + p[indent=\"h2i8\"] { + padding-left: 8em; + text-indent: -6em; + } + p[indent=\"h2i9\"] { + padding-left: 9em; + text-indent: -7em; + } + p[indent=\"h3i0\"] { + padding-left: 0em; + text-indent: 3em; + } + p[indent=\"h3i1\"] { + padding-left: 1em; + text-indent: 2em; + } + p[indent=\"h3i2\"] { + padding-left: 2em; + text-indent: 1em; + } + p[indent=\"h3i3\"] { + padding-left: 3em; + text-indent: 0em; + } + p[indent=\"h3i4\"] { + padding-left: 4em; + text-indent: -1em; + } + p[indent=\"h3i5\"] { + padding-left: 5em; + text-indent: -2em; + } + p[indent=\"h3i6\"] { + padding-left: 6em; + text-indent: -3em; + } + p[indent=\"h3i7\"] { + padding-left: 7em; + text-indent: -4em; + } + p[indent=\"h3i8\"] { + padding-left: 8em; + text-indent: -5em; + } + p[indent=\"h3i9\"] { + padding-left: 9em; + text-indent: -6em; + } + p[indent=\"h4i0\"] { + padding-left: 0em; + text-indent: 4em; + } + p[indent=\"h4i1\"] { + padding-left: 1em; + text-indent: 3em; + } + p[indent=\"h4i2\"] { + padding-left: 2em; + text-indent: 2em; + } + p[indent=\"h4i3\"] { + padding-left: 3em; + text-indent: 1em; + } + p[indent=\"h4i4\"] { + padding-left: 4em; + text-indent: 0em; + } + p[indent=\"h4i5\"] { + padding-left: 5em; + text-indent: -1em; + } + p[indent=\"h4i6\"] { + padding-left: 6em; + text-indent: -2em; + } + p[indent=\"h4i7\"] { + padding-left: 7em; + text-indent: -3em; + } + p[indent=\"h4i8\"] { + padding-left: 8em; + text-indent: -4em; + } + p[indent=\"h4i9\"] { + padding-left: 9em; + text-indent: -5em; + } + p[indent=\"h5i0\"] { + padding-left: 0em; + text-indent: 5em; + } + p[indent=\"h5i1\"] { + padding-left: 1em; + text-indent: 4em; + } + p[indent=\"h5i2\"] { + padding-left: 2em; + text-indent: 3em; + } + p[indent=\"h5i3\"] { + padding-left: 3em; + text-indent: 2em; + } + p[indent=\"h5i4\"] { + padding-left: 4em; + text-indent: 1em; + } + p[indent=\"h5i5\"] { + padding-left: 5em; + text-indent: 0em; + } + p[indent=\"h5i6\"] { + padding-left: 6em; + text-indent: -1em; + } + p[indent=\"h5i7\"] { + padding-left: 7em; + text-indent: -2em; + } + p[indent=\"h5i8\"] { + padding-left: 8em; + text-indent: -3em; + } + p[indent=\"h5i9\"] { + padding-left: 9em; + text-indent: -4em; + } + p[indent=\"h6i0\"] { + padding-left: 0em; + text-indent: 6em; + } + p[indent=\"h6i1\"] { + padding-left: 1em; + text-indent: 5em; + } + p[indent=\"h6i2\"] { + padding-left: 2em; + text-indent: 4em; + } + p[indent=\"h6i3\"] { + padding-left: 3em; + text-indent: 3em; + } + p[indent=\"h6i4\"] { + padding-left: 4em; + text-indent: 2em; + } + p[indent=\"h6i5\"] { + padding-left: 5em; + text-indent: 1em; + } + p[indent=\"h6i6\"] { + padding-left: 6em; + text-indent: 0em; + } + p[indent=\"h6i7\"] { + padding-left: 7em; + text-indent: -1em; + } + p[indent=\"h6i8\"] { + padding-left: 8em; + text-indent: -2em; + } + p[indent=\"h6i9\"] { + padding-left: 9em; + text-indent: -3em; + } + p[indent=\"h7i0\"] { + padding-left: 0em; + text-indent: 7em; + } + p[indent=\"h7i1\"] { + padding-left: 1em; + text-indent: 6em; + } + p[indent=\"h7i2\"] { + padding-left: 2em; + text-indent: 5em; + } + p[indent=\"h7i3\"] { + padding-left: 3em; + text-indent: 4em; + } + p[indent=\"h7i4\"] { + padding-left: 4em; + text-indent: 3em; + } + p[indent=\"h7i5\"] { + padding-left: 5em; + text-indent: 2em; + } + p[indent=\"h7i6\"] { + padding-left: 6em; + text-indent: 1em; + } + p[indent=\"h7i7\"] { + padding-left: 7em; + text-indent: 0em; + } + p[indent=\"h7i8\"] { + padding-left: 8em; + text-indent: -1em; + } + p[indent=\"h7i9\"] { + padding-left: 9em; + text-indent: -2em; + } + p[indent=\"h8i0\"] { + padding-left: 0em; + text-indent: 8em; + } + p[indent=\"h8i1\"] { + padding-left: 1em; + text-indent: 7em; + } + p[indent=\"h8i2\"] { + padding-left: 2em; + text-indent: 6em; + } + p[indent=\"h8i3\"] { + padding-left: 3em; + text-indent: 5em; + } + p[indent=\"h8i4\"] { + padding-left: 4em; + text-indent: 4em; + } + p[indent=\"h8i5\"] { + padding-left: 5em; + text-indent: 3em; + } + p[indent=\"h8i6\"] { + padding-left: 6em; + text-indent: 2em; + } + p[indent=\"h8i7\"] { + padding-left: 7em; + text-indent: 1em; + } + p[indent=\"h8i8\"] { + padding-left: 8em; + text-indent: 0em; + } + p[indent=\"h8i9\"] { + padding-left: 9em; + text-indent: -1em; + } + p[indent=\"h9i0\"] { + padding-left: 0em; + text-indent: 9em; + } + p[indent=\"h9i1\"] { + padding-left: 1em; + text-indent: 8em; + } + p[indent=\"h9i2\"] { + padding-left: 2em; + text-indent: 7em; + } + p[indent=\"h9i3\"] { + padding-left: 3em; + text-indent: 6em; + } + p[indent=\"h9i4\"] { + padding-left: 4em; + text-indent: 5em; + } + p[indent=\"h9i5\"] { + padding-left: 5em; + text-indent: 4em; + } + p[indent=\"h9i6\"] { + padding-left: 6em; + text-indent: 3em; + } + p[indent=\"h9i7\"] { + padding-left: 7em; + text-indent: 2em; + } + p[indent=\"h9i8\"] { + padding-left: 8em; + text-indent: 1em; + } + p[indent=\"h9i9\"] { + padding-left: 9em; + text-indent: 0em; + } + p.block { + white-space: pre; + } + p.group { } + p.alt { } + p.verse { + white-space: pre; + margin-bottom: 6px; + } + p.code { + font-family: inconsolata, andale mono, courier new, courier, monospace; + font-size: 90%; + text-align: left; + background-color: #eeeeee; + white-space: pre; + margin-top: 0px; + margin-bottom: 0px; + } + p.caption { + text-align: left; + font-size: 80%; + display: inline; + } + p.endnote { + font-size: 96%; + line-height: 120%; + text-align: left; + margin-right: 15mm; + } + p.endnote_indent { + font-size: 96%; + line-height: 120%; + text-align: left; + margin-left: 2em; + margin-right: 15mm; + } + p.center { + text-align: center; + } + p.bold { + font-weight: bold; + } + p.bold_left { + font-weight: bold; + text-align: left; + } + p.centerbold { + text-align: center; + font-weight: bold; + } + p.em { + font-weight: bold; + font-style: normal; + background: #fff3b6; + } + p.small { + font-size: 80%; + margin-top: 0px; + margin-bottom: 0px; + margin-right: 6px; + text-align: left; + } + .tiny, .tiny_left, .tiny_right, .tiny_center { + font-size: 10px; + margin-top: 0px; + margin-bottom: 0px; + color: #777777; + margin-right: 6px; + text-align: left; + } + p.tiny { } + p.tiny_left { + margin-left: 0px; + margin-right: 0px; + text-align: left; + } + p.tiny_right { + margin-right: 1em; + text-align: right; + } + p.tiny_center { + margin-left: 0px; + margin-right: 0px; + text-align: center; + } + p.concordance_word { + line-height: 150%; + font-weight: bold; + display: inline; + margin-top: 4px; + margin-bottom: 1px; + } + p.concordance_count { + font-size: 80%; + color: #777777; + display: inline; + margin-left: 0em; + } + p.concordance_object { + font-size: 80%; + line-height: 120%; + text-align: left; + margin-left: 3em; + margin-top: 1px; + margin-bottom: 3px; + } + p.book_index_lev1 { + line-height: 100%; + margin-top: 4px; + margin-bottom: 1px; + } + p.book_index_lev2 { + line-height: 100%; + text-align: left; + margin-left: 3em; + margin-top: 1px; + margin-bottom: 3px; + } + tt { + font-family: inconsolata, andale mono, courier new, courier, monospace; + background-color: #eeeeee; + } + note { white-space: pre; } + label.ocn { + width: 2%; + float: right; + top: 0; + font-size: 10px; + margin-top: 0px; + margin-bottom: 5px; + color: #777777; + margin-right: 5px; + text-align: right; + background-color: #ffffff; + } + table { } + tr { } + th,td { + vertical-align: top; + text-align: left; + } + th { + font-weight: bold; + } + em { + font-weight: bold; + font-style: italic; + } + p.left,th.left,td.left { + text-align: left; + } + p.small_left,th.small_left,td.small_left { + text-align: left; + font-size: 80%; + } + p.right,th.right,td.right { + text-align: right; + } + ul, li { + list-style-type: none; + list-style: none; + padding-left: 20px; + display: block; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; + font-weight: normal; + line-height: 150%; + text-align: left; + text-indent: 0mm; + margin-left: 1em; + margin-right: 2em; + margin-top: 3px; + margin-bottom: 3px; + } + li { + background: url(../image_sys/bullet_09.png) no-repeat 0px 6px; + } + ul { + } + h0, h1, h2, h3, h4, h5, h6, h7 { + font-weight: bold; + line-height: 120%; + text-align: left; + margin-top: 20px; + margin-bottom: 10px; + } + h4.norm, h5.norm, h6.norm, h7.norm { + margin-top: 10px; + margin-bottom: 0px; + } + h0 { font-size: 125%; } + h1 { font-size: 120%; } + h2 { font-size: 115%; } + h3 { font-size: 110%; } + h4 { font-size: 105%; } + h5 { font-size: 100%; } + h6 { font-size: 100%; } + h7 { font-size: 100%; } + h0, h1, h2, h3, h4, h5, h6, h7 { text-shadow: .2em .2em .3em gray; } + h1.i { margin-left: 2em; } + h2.i { margin-left: 3em; } + h3.i { margin-left: 4em; } + h4.i { margin-left: 5em; } + h5.i { margin-left: 6em; } + h6.i { margin-left: 7em; } + h7.i { margin-left: 8em; } + h8.i { margin-left: 9em; } + h9.i { margin-left: 10em; } + .toc { + font-weight: normal; + margin-top: 6px; + margin-bottom: 6px; + } + h0.toc { + margin-left: 1em; + font-size: 120%; + line-height: 150%; + } + h1.toc { + margin-left: 1em; + font-size: 115%; + line-height: 150%; + } + h2.toc { + margin-left: 2em; + font-size: 110%; + line-height: 140%; + } + h3.toc { + margin-left: 3em; + font-size: 105%; + line-height: 120%; + } + h4.toc { + margin-left: 4em; + font-size: 100%; + line-height: 120%; + } + h5.toc { + margin-left: 5em; + font-size: 95%; + line-height: 110%; + } + h6.toc { + margin-left: 6em; + font-size: 90%; + line-height: 110%; + } + h7.toc { + margin-left: 7em; + font-size: 85%; + line-height: 100%; + } + .subtoc { + margin-right: 34%; + font-weight: normal; + } + h5.subtoc { + margin-left: 2em; + font-size: 80%; + margin-top: 2px; + margin-bottom: 2px; + } + h6.subtoc { + margin-left: 3em; + font-size: 75%; + margin-top: 0px; + margin-bottom: 0px; + } + h7.subtoc { + margin-left: 4em; + font-size: 70%; + margin-top: 0px; + margin-bottom: 0px; + } + div.substance { + width: 100%; + background-color: #ffffff; + } + div.ocn { + width: 5%; + float: right; + top: 0; + background-color: #ffffff; + } + div.endnote { + width: 95%; + background-color: #fffffff; + } + div.toc { + position: absolute; + float: left; + margin: 0; + padding: 0; + padding-top: 0.5em; + border: 0; + width: 13em; + background-color: #eeeeee; + margin-right:1em; + } + div.summary { + margin: 0; + padding: 0; + border-left: 13em solid #eeeeee; + padding-left: 1em; + background-color: #eeeeee; + } + div.content, div.main_column { + margin: 0; + padding: 0; + border-left: 13em solid #ffffff; + padding-left: 1em; + padding-right: 1em; + } + div.content0, div.main_column0 { + margin: 0; + padding: 0; + border-left: 0% solid #ffffff; + padding-left: 5%; + } + div.scroll { + margin: 0; + padding: 0; + padding-left: 1em; + padding-right: 1em; + } + div.content:after { + content:' '; + clear:both; + display:block; + height:0; + overflow:hidden + } + div.footer { + clear:left; + padding: 0.5em; + font-size: 80%; + margin: 0; + } + div.toc ul { + list-style: none; + padding: 0; + margin: 0; + } + div.toc li ul a, li ul span.currentlink + { + font-weight: normal; + font-size: 90%; + padding-left: 2em; + background-color: #eeeeee; + } + div.toc a, span.currentlink{ + display:block; + text-decoration: none; + padding-left: 0.5em; + color: #0000aa; + } + hr { + width: 90%; + margin-top: 1.8em; + margin-bottom: 1.8em; + } + span.currentlink { + text-decoration: none; + background-color: #aaaaf9; + } + div.toc a:visited { + color: #0000aa; + } + div.toc a:hover { + color: #000000; + background-color: #f9f9aa; + } + /* in toc no list numbering */ + nav#toc ol { + list-style-type: none; + } +"; + struct _css { + auto html_css() { + string _css = "/* SiSU css html stylesheet */\n" ~ css_shared; + return _css; + } + auto epub_css() { + string _css = "/* SiSU css epub stylesheet */\n" ~ css_shared; + return _css; + } + } + return _css(); + } +} |