diff options
Diffstat (limited to 'src/sisudoc')
39 files changed, 2115 insertions, 1125 deletions
diff --git a/src/sisudoc/io_in/paths_source.d b/src/sisudoc/io_in/paths_source.d index d5fafa3..2c0d545 100644 --- a/src/sisudoc/io_in/paths_source.d +++ b/src/sisudoc/io_in/paths_source.d @@ -54,16 +54,14 @@ +/ module sisudoc.io_in.paths_source; @safe: -import - std.array, - std.file, - std.path, - std.regex, - std.stdio, - std.conv : to; -import - sisudoc.meta.defaults, - sisudoc.meta.rgx_files; +import std.array; +import std.file; +import std.path; +import std.regex; +import std.stdio; +import std.conv : to; +import sisudoc.meta.defaults; +import sisudoc.meta.rgx_files; template PodManifest() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); @@ -90,8 +88,10 @@ template PodManifest() { _manifest_path = m.captures["podpath"]; } } else { - if (_opt_action.vox_gt1 || _opt_action.debug_do) { - writeln("WARNING, src is not a pod, issue with manifest_path: ", _pth); // remove? unless can distinguish pod + if (_opt_action.vox_gt_3 || _opt_action.debug_do) { + if (exists(_pth) == 0 && (_pth.isFile)) { + writeln("WARNING, src file is not .sst or .ssm (nor is it a pod directory): ", _pth); // remove? unless can distinguish pod + } } _manifest_path = ""; } @@ -108,7 +108,7 @@ template PodManifest() { _k = pod_manifest_path; } if (exists(_k)==0) { - writeln("ERROR >> Processing Skipped! Manifest not found: ", _k); + // writeln("ERROR >> Processing Skipped! Manifest not found: ", _k); _k = null; } return _k; diff --git a/src/sisudoc/io_in/read_config_files.d b/src/sisudoc/io_in/read_config_files.d index 8da08f5..531dc72 100644 --- a/src/sisudoc/io_in/read_config_files.d +++ b/src/sisudoc/io_in/read_config_files.d @@ -54,14 +54,12 @@ +/ module sisudoc.io_in.read_config_files; @safe: -import - std.file, - std.path; -import - sisudoc.meta, - sisudoc.io_in.paths_source, - sisudoc.meta.rgx_files, - sisudoc.meta.rgx; +import std.file; +import std.path; +import sisudoc.meta; +import sisudoc.io_in.paths_source; +import sisudoc.meta.rgx_files; +import sisudoc.meta.rgx; template readConfigSite() { @system final auto readConfigSite(Cf,O,Cfg)(Cf _conf_file_details, O _opt_action, Cfg _cfg) { mixin spineRgxIn; @@ -140,7 +138,7 @@ webserv: try { if (exists(conf_file)) { if (conf_file.getLinkAttributes.attrIsFile) { - if (_opt_action.vox_gt1 || _opt_action.debug_do) { + if (_opt_action.vox_gt_2 || _opt_action.debug_do) { writeln("config file used: \"", conf_file, "\" (cli flag settings override config file's individual settings)"); } config_file_str = conf_file.readText; @@ -190,14 +188,12 @@ webserv: } } static template readConfigDoc() { - import - std.file, - std.path; - import - sisudoc.meta, - sisudoc.io_in.paths_source, - sisudoc.meta.rgx_files, - sisudoc.meta.rgx; + import std.file; + import std.path; + import sisudoc.meta; + import sisudoc.io_in.paths_source; + import sisudoc.meta.rgx_files; + import sisudoc.meta.rgx; @system final auto readConfigDoc(M,E)(M _manifested, E _env) { mixin spineRgxIn; static auto rgx = RgxI(); @@ -246,14 +242,12 @@ static template readConfigDoc() { } } static template configReadSiteYAML() { - import - std.file, - std.path; - import - sisudoc.meta, - sisudoc.io_in.paths_source, - sisudoc.meta.rgx_files, - sisudoc.meta.rgx; + import std.file; + import std.path; + import sisudoc.meta; + import sisudoc.io_in.paths_source; + import sisudoc.meta.rgx_files; + import sisudoc.meta.rgx; final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = configFilePaths!()(_manifested, _env); @@ -263,12 +257,10 @@ static template configReadSiteYAML() { } } static template configReadDocYAML() { - import - std.file, - std.path; - import - sisudoc.meta, - sisudoc.io_in.paths_source; + import std.file; + import std.path; + import sisudoc.meta; + import sisudoc.io_in.paths_source; final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInDocYAML!()(_manifested, _env); auto _conf_file_details = configFilePaths!()(_manifested, _env); diff --git a/src/sisudoc/io_in/read_source_files.d b/src/sisudoc/io_in/read_source_files.d index 3cbaed0..428c119 100644 --- a/src/sisudoc/io_in/read_source_files.d +++ b/src/sisudoc/io_in/read_source_files.d @@ -55,15 +55,13 @@ module sisudoc.io_in.read_source_files; @safe: template spineRawMarkupContent() { - import - std.digest.sha, - std.file, - std.path; - import - sisudoc.meta, - sisudoc.io_in.paths_source, - sisudoc.meta.rgx_files, - sisudoc.meta.rgx; + import std.digest.sha; + import std.file; + import std.path; + import sisudoc.meta; + import sisudoc.io_in.paths_source; + import sisudoc.meta.rgx_files; + import sisudoc.meta.rgx; mixin spineRgxIn; static auto rgx = RgxI(); mixin spineRgxFiles; @@ -132,7 +130,7 @@ template spineRawMarkupContent() { sourcefile_body_content = _cii.contents; insert_file_list_get = _cii.insert_files.dup; images_list_get = _cii.images.dup; - } else if (_opt_action.source || _opt_action.pod) { + } else if (_opt_action.source_or_pod) { auto ins = Inserts(); ST_contents_inserts_images _cii = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); @@ -157,9 +155,8 @@ template spineRawMarkupContent() { } } struct MarkupRawUnit { - import - std.digest.sha, - std.file; + import std.digest.sha; + import std.file; final private string readInMarkupSource(in char[] fn_src) { enforce( exists(fn_src) != 0, @@ -253,7 +250,7 @@ template spineRawMarkupContent() { ) { char[][] contents_insert; int code_block_status = 0; - enum codeBlock { off, curly, tic, } + enum codeBlock { off, curly, tic, quotemarks } auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; foreach (line; markup_sourcefile_insert_content) { @@ -265,11 +262,19 @@ template spineRawMarkupContent() { } else if (line.matchFirst(rgx.block_curly_code_open)) { code_block_status = codeBlock.curly; contents_insert ~= line; + } else if (code_block_status == codeBlock.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + code_block_status = codeBlock.off; + } + contents_insert ~= line; } else if (code_block_status == codeBlock.tic) { if (line.matchFirst(rgx.block_tic_close)) { code_block_status = codeBlock.off; } contents_insert ~= line; + } else if (line.matchFirst(rgx.block_quotemarks_code_open)) { + code_block_status = codeBlock.quotemarks; + contents_insert ~= line; } else if (line.matchFirst(rgx.block_tic_code_open)) { code_block_status = codeBlock.tic; contents_insert ~= line; @@ -289,7 +294,7 @@ template spineRawMarkupContent() { markup_sourcesubfile_insert_content.length ); } - if (_opt_action.source || _opt_action.pod) { + if (_opt_action.source_or_pod) { _images ~= _extract_images(markup_sourcesubfile_insert_content); } auto ins = Inserts(); @@ -305,7 +310,7 @@ template spineRawMarkupContent() { +/ } else { contents_insert ~= line; // images to extract for image list? - if (_opt_action.source || _opt_action.pod) { + if (_opt_action.source_or_pod) { string[] _image_linelist = _extract_images(line); if (_image_linelist.length > 0) { _images ~= _image_linelist; @@ -328,7 +333,7 @@ template spineRawMarkupContent() { import std.algorithm; char[][] contents; int code_block_status = 0; - enum codeBlock { off, curly, tic, } + enum codeBlock { off, curly, tic, quotemarks } auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; @@ -343,11 +348,19 @@ template spineRawMarkupContent() { } else if (line.matchFirst(rgx.block_curly_code_open)) { code_block_status = codeBlock.curly; contents ~= line; + } else if (code_block_status == codeBlock.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + code_block_status = codeBlock.off; + } + contents ~= line; } else if (code_block_status == codeBlock.tic) { if (line.matchFirst(rgx.block_tic_close)) { code_block_status = codeBlock.off; } contents ~= line; + } else if (line.matchFirst(rgx.block_quotemarks_code_open)) { + code_block_status = codeBlock.quotemarks; + contents ~= line; } else if (line.matchFirst(rgx.block_tic_code_open)) { code_block_status = codeBlock.tic; contents ~= line; @@ -376,7 +389,7 @@ template spineRawMarkupContent() { fn_src_insert.to!string ); contents ~= contents_insert_st.insert_contents; - if (_opt_action.source || _opt_action.pod) { + if (_opt_action.source_or_pod) { string[] _image_linelist = _extract_images(contents_insert_st.images); if (_image_linelist.length > 0) { _images ~= _image_linelist; @@ -394,7 +407,7 @@ template spineRawMarkupContent() { +/ } else { contents ~= line; - if (_opt_action.source || _opt_action.pod) { + if (_opt_action.source_or_pod) { string[] _image_linelist = _extract_images(line); if (_image_linelist.length > 0) { _images ~= _image_linelist; diff --git a/src/sisudoc/io_out/create_zip_file.d b/src/sisudoc/io_out/create_zip_file.d index e468253..7bd58bc 100644 --- a/src/sisudoc/io_out/create_zip_file.d +++ b/src/sisudoc/io_out/create_zip_file.d @@ -50,11 +50,10 @@ module sisudoc.io_out.create_zip_file; @safe: template createZipFile() { - import - std.file, - std.outbuffer, - std.string, - std.zip; + import std.file; + import std.outbuffer; + import std.string; + import std.zip; void createZipFile( string zip_file_name, void[] compressed_zip_data, diff --git a/src/sisudoc/io_out/epub3.d b/src/sisudoc/io_out/epub3.d index 8fd1cb5..c8ca757 100644 --- a/src/sisudoc/io_out/epub3.d +++ b/src/sisudoc/io_out/epub3.d @@ -50,19 +50,17 @@ module sisudoc.io_out.epub3; @safe: template outputEPub3() { - import - std.file, - std.outbuffer, - std.uri, - std.zip, - std.conv : to; - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.io_out.rgx_xhtml, - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls, - sisudoc.io_out.xmls_css; + import std.file; + import std.outbuffer; + import std.uri; + import std.zip; + import std.conv : to; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.io_out.rgx_xhtml; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; + import sisudoc.io_out.xmls_css; mixin InternalMarkup; mixin outputXHTMLs; static auto rgx = RgxO(); @@ -95,10 +93,10 @@ template outputEPub3() { </rootfiles>┃") ~ "\n</container>\n"; return o; } - string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { + string epub3_oebps_content(D,P)(D doc, P parts) { auto xhtml_format = outputXHTMLs(); - auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); - string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! + auto pth_epub3 = spinePathsEPUB!()(doc.matters.output_path, doc.matters.src.language); + string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc.matters! string content = format(q"┃<?xml version="1.0" encoding="utf-8"?> <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" prefix="rendition: http://www.idpf.org/vocab/rendition/#"> <metadata @@ -122,25 +120,25 @@ template outputEPub3() { <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> ┃", _uuid, - xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_main), - (doc_matters.conf_make_meta.meta.title_sub.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_sub), - (doc_matters.conf_make_meta.meta.creator_author.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), - (doc_matters.conf_make_meta.meta.creator_author.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), - doc_matters.src.language, // language, fix (needed in dochead metadata) - (doc_matters.conf_make_meta.meta.date_published.empty) - ? "" : xhtml_format.special_characters_date(doc_matters.conf_make_meta.meta.date_published), - (doc_matters.conf_make_meta.meta.rights_copyright.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.title_main), + (doc.matters.conf_make_meta.meta.title_sub.empty) + ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.title_sub), + (doc.matters.conf_make_meta.meta.creator_author.empty) + ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.creator_author), + (doc.matters.conf_make_meta.meta.creator_author.empty) + ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.creator_author), + doc.matters.src.language, // language, fix (needed in dochead metadata) + (doc.matters.conf_make_meta.meta.date_published.empty) + ? "" : xhtml_format.special_characters_date(doc.matters.conf_make_meta.meta.date_published), + (doc.matters.conf_make_meta.meta.rights_copyright.empty) + ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.rights_copyright), _uuid, _uuid, (pth_epub3.fn_oebps_css).chompPrefix("OEBPS/"), ); content ~= parts["manifest_documents"]; // TODO sort jpg & png - foreach (image; doc_matters.srcs.image_list) { + foreach (image; doc.matters.srcs.image_list) { content ~= format(q"┃ <item id="%s" href="%s/%s" media-type="image/%s" /> ┃", image.baseName.stripExtension, @@ -158,8 +156,8 @@ template outputEPub3() { content ~= " " ~ "</guide>" ~ "\n "; content ~= "" ~ "</package>"; debug(epubmanifest) { - foreach (section; doc_matters.has.keys_seq.seg) { // TODO - foreach (obj; doc_abstraction[section]) { + foreach (section; doc.matters.has.keys_seq.seg) { // TODO + foreach (obj; doc.abstraction[section]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup == 4) { writefln( @@ -183,7 +181,7 @@ template outputEPub3() { } return content; } - string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { + string epub3_oebps_toc_nav_xhtml(D)(D doc) { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = RgxO(); @@ -202,12 +200,12 @@ template outputEPub3() { </header> <nav epub:type="toc" id="toc"> ┃", - (doc_matters.conf_make_meta.meta.title_full).special_characters_text, + (doc.matters.conf_make_meta.meta.title_full).special_characters_text, ); string _toc_nav_tail = ""; - // writeln(doc_matters.has.keys_seq.seg); // DEBUG line - foreach (sect; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[sect]) { + // writeln(doc.matters.has.keys_seq.seg); // DEBUG line + foreach (sect; doc.matters.has.keys_seq.seg) { + foreach (obj; doc.abstraction[sect]) { if ((sect == "head") && (obj.metainfo.is_a == "heading")) { toc = toc_head; } @@ -263,7 +261,7 @@ template outputEPub3() { } break; } - if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) { + if (doc.matters.has.keys_seq.seg[doc.matters.has.keys_seq.seg.length - 2] == sect) { // writeln(n, ": ", sect, ": ", _txt, " - ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG // read last heading (heading prior to closing) and determine what those instructions imply still need to be done // CLOSE // DomTags { 0 none, 1 open, 2 close, 3 close_and_open, 4 open_still, } @@ -296,16 +294,12 @@ template outputEPub3() { toc ~= _toc_nav_tail; return toc; } - @system void outputEPub3(D,I)( - const D doc_abstraction, - I doc_matters, - ) { + @system void outputEPub3(D)(D doc) { mixin spineRgxOut; mixin spineRgxXHTML; auto xhtml_format = outputXHTMLs(); static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); - string[] doc; string segment_filename; string[] top_level_headings = ["","","",""]; string[string] oepbs_content_parts; @@ -322,8 +316,8 @@ template outputEPub3() { string[] doc_parts; } auto epubWrite = writeOut(); - foreach (section; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[section]) { + foreach (section; doc.matters.has.keys_seq.seg) { + foreach (obj; doc.abstraction[section]) { string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); if (obj.metainfo.is_a == "heading") { assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); @@ -351,8 +345,8 @@ template outputEPub3() { goto default; default: epubWrite.doc_parts ~= obj.tags.segment_anchor_tag_epub; - epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc_matters); - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc.matters); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= t[0]; epubWrite.doc_epub3_endnotes[obj.tags.segment_anchor_tag_epub] ~= t[1]; break; @@ -360,19 +354,19 @@ template outputEPub3() { break; case 4: segment_filename = obj.tags.segment_anchor_tag_epub; - epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters); - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc.matters); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); writeln(__FILE__, ":", __LINE__, ": ", obj.text); } @@ -380,7 +374,7 @@ template outputEPub3() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); } } @@ -395,13 +389,13 @@ template outputEPub3() { case "para": switch (obj.metainfo.is_a) { case "toc": - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -410,7 +404,7 @@ template outputEPub3() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -422,13 +416,13 @@ template outputEPub3() { case "para": switch (obj.metainfo.is_a) { case "para": - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -438,37 +432,37 @@ template outputEPub3() { case "block": switch (obj.metainfo.is_a) { case "quote": - t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.quote_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "group": - t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.group_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "block": - t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.block_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "poem": break; case "verse": - t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.verse_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "code": - epubWrite.doc_epub3[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters); + epubWrite.doc_epub3[segment_filename] ~= xhtml_format.code(_txt, obj, doc.matters); break; case "table": - epubWrite.doc_epub3[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters); + epubWrite.doc_epub3[segment_filename] ~= xhtml_format.table(_txt, obj, doc.matters); epubWrite.doc_epub3_endnotes[segment_filename] ~= ""; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -477,7 +471,7 @@ template outputEPub3() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -490,37 +484,37 @@ template outputEPub3() { case "para": switch (obj.metainfo.is_a) { case "endnote": assert(section == "endnotes"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; break; case "glossary": assert(section == "glossary"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "bibliography": assert(section == "bibliography"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "bookindex": assert(section == "bookindex"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "blurb": assert(section == "blurb"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; case "tail": assert(section == "tail"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub"); epubWrite.doc_epub3[segment_filename] ~= t[0]; epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -529,7 +523,7 @@ template outputEPub3() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -540,7 +534,7 @@ template outputEPub3() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_epub) { + if (doc.matters.opt.action.debug_do_epub) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); } } @@ -597,9 +591,9 @@ template outputEPub3() { /+ epub specific documents +/ epubWrite.mimetypes = epub3_mimetypes; epubWrite.meta_inf_container_xml = epub3_container_xml; - epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters); - epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts); - epubWrite.epub3_write_output_files(doc_matters); + epubWrite.oebps_toc_nav_xhtml = doc.epub3_oebps_toc_nav_xhtml; + epubWrite.oebps_content_opf = doc.epub3_oebps_content(oepbs_content_parts); + epubWrite.epub3_write_output_files(doc.matters); } @system void epub3_write_output_files(W,M)( W epub_write, @@ -743,7 +737,7 @@ template outputEPub3() { foreach (image; doc_matters.srcs.image_list) { { /+ debug +/ if (doc_matters.opt.action.debug_do_epub) { - if (doc_matters.opt.action.vox_gt2) { + if (doc_matters.opt.action.vox_gt_3) { writeln( doc_matters.src.image_dir_path, "/", image, " -> ", pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image @@ -790,7 +784,7 @@ template outputEPub3() { } catch (ErrnoException ex) { // Handle error } - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", fn_epub); } debug(epub_archive) { diff --git a/src/sisudoc/io_out/html.d b/src/sisudoc/io_out/html.d index c1f0aa5..fc9ef54 100644 --- a/src/sisudoc/io_out/html.d +++ b/src/sisudoc/io_out/html.d @@ -50,36 +50,31 @@ module sisudoc.io_out.html; @safe: template outputHTML() { - import - std.file, - std.outbuffer, - std.uri, - std.conv : to; - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.meta.rgx_files, - sisudoc.io_out.rgx_xhtml, - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls, - sisudoc.io_out.xmls_css; + import std.file; + import std.outbuffer; + import std.uri; + import std.conv : to; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.meta.rgx_files; + import sisudoc.io_out.rgx_xhtml; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; + import sisudoc.io_out.xmls_css; mixin outputXHTMLs; - void scroll(D,M)( - const D doc_abstraction, - M doc_matters, - ) { + void scroll(D)(D doc) { mixin spineRgxOut; mixin spineRgxXHTML; auto xhtml_format = outputXHTMLs(); static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); string[] doc_html; - string[] doc; + string[] doc_out; string suffix = ".html"; string previous_section = ""; string delimit = ""; - foreach (section; doc_matters.has.keys_seq.scroll) { - foreach (obj; doc_abstraction[section]) { + foreach (section; doc.matters.has.keys_seq.scroll) { + foreach (obj; doc.abstraction[section]) { delimit = xhtml_format.div_delimit(section, previous_section); string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); switch (obj.metainfo.is_of_part) { @@ -88,14 +83,14 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "heading": - doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix); break; case "toc": - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -104,7 +99,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -116,14 +111,14 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "heading": - doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix); break; case "para": - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -133,28 +128,28 @@ template outputHTML() { case "block": switch (obj.metainfo.is_a) { case "quote": - doc_html ~= xhtml_format.quote_scroll(_txt, obj, doc_matters); + doc_html ~= xhtml_format.quote_scroll(_txt, obj, doc.matters); break; case "group": - doc_html ~= xhtml_format.group_scroll(_txt, obj, doc_matters); + doc_html ~= xhtml_format.group_scroll(_txt, obj, doc.matters); break; case "block": - doc_html ~= xhtml_format.block_scroll(_txt, obj, doc_matters); + doc_html ~= xhtml_format.block_scroll(_txt, obj, doc.matters); break; case "poem": break; case "verse": - doc_html ~= xhtml_format.verse_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.verse_scroll(_txt, obj, doc.matters, suffix); break; case "code": - doc_html ~= xhtml_format.code(_txt, obj, doc_matters); + doc_html ~= xhtml_format.code(_txt, obj, doc.matters); break; case "table": - doc_html ~= xhtml_format.table(_txt, obj, doc_matters); + doc_html ~= xhtml_format.table(_txt, obj, doc.matters); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -163,7 +158,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -176,29 +171,29 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "heading": - doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix); break; case "endnote": assert(section == "endnotes"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; case "glossary": assert(section == "glossary"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; case "bibliography": assert(section == "bibliography"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; case "bookindex": assert(section == "bookindex"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; case "blurb": assert(section == "blurb"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; case "tail": assert(section == "tail"); - doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); + doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -207,7 +202,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -218,7 +213,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); writeln(__FILE__, ":", __LINE__, ": ", obj.text); @@ -228,18 +223,18 @@ template outputHTML() { } } } - doc = xhtml_format.html_head(doc_matters, "scroll") + doc_out = xhtml_format.html_head(doc.matters, "scroll") ~ doc_html ~ xhtml_format.dom_close - ~ xhtml_format.tail(doc_matters); - scroll_write_output(doc, doc_matters); + ~ xhtml_format.tail(doc.matters); + scroll_write_output(doc_out, doc.matters); } - @trusted void scroll_write_output(D,M)( - D doc, + @trusted void scroll_write_output(O,M)( + O doc_out, M doc_matters, ) { debug(asserts) { - static assert(is(typeof(doc) == string[])); + static assert(is(typeof(doc_out) == string[])); } auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { @@ -248,7 +243,7 @@ template outputHTML() { } { auto f = File(pth_html.fn_scroll(doc_matters.src.filename), "w"); - foreach (o; doc) { + foreach (o; doc_out) { f.writeln(o); } } @@ -267,14 +262,11 @@ template outputHTML() { } catch (ErrnoException ex) { // Handle error } - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pth_html.fn_scroll(doc_matters.src.filename)); } } - void seg(D,M)( - const D doc_abstraction, - M doc_matters, - ) { + void seg(D)(D doc) { mixin spineRgxOut; mixin spineRgxXHTML; static auto rgx = RgxO(); @@ -282,15 +274,14 @@ template outputHTML() { auto xhtml_format = outputXHTMLs(); string[][string] doc_html; string[][string] doc_html_endnotes; - string[] doc; string segment_filename; string[] top_level_headings = ["","","",""]; string previous_seg_filename = ""; string suffix = ".html"; string previous_section = ""; string delimit = ""; - foreach (section; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[section]) { + foreach (section; doc.matters.has.keys_seq.seg) { + foreach (obj; doc.abstraction[section]) { delimit = xhtml_format.div_delimit(section, previous_section); string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); if (obj.metainfo.is_a == "heading") { @@ -318,33 +309,33 @@ template outputHTML() { top_level_headings[3] = ""; goto default; default: - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg"); top_level_headings[obj.metainfo.heading_lev_markup] = t[0]; break; } break; case 4: segment_filename = obj.tags.segment_anchor_tag_epub; - doc_html[segment_filename] ~= xhtml_format.html_head(doc_matters, "seg"); - auto navigation_bar = xhtml_format.nav_pre_next_svg(obj, doc_matters); + doc_html[segment_filename] ~= xhtml_format.html_head(doc.matters, "seg"); + auto navigation_bar = xhtml_format.nav_pre_next_svg(obj, doc.matters); doc_html[segment_filename] ~= navigation_bar.toc_pre_next; previous_seg_filename = segment_filename; foreach (top_level_heading; top_level_headings) { doc_html[segment_filename] ~= top_level_heading; } - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; - doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc_matters); + doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc.matters); doc_html_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: - Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); + Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; doc_html_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); writeln(__FILE__, ":", __LINE__, ": ", obj.text); } @@ -352,7 +343,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); } } @@ -367,12 +358,12 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "toc": - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -381,7 +372,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -393,13 +384,13 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "para": - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0].to!string; doc_html_endnotes[segment_filename] ~= t[1]; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -409,24 +400,24 @@ template outputHTML() { case "block": switch (obj.metainfo.is_a) { case "quote": - t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.quote_seg(_txt, obj, doc.matters, suffix, "seg"); goto default; case "group": - t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.group_seg(_txt, obj, doc.matters, suffix, "seg"); goto default; case "block": - t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.block_seg(_txt, obj, doc.matters, suffix, "seg"); goto default; case "poem": break; case "verse": - t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.verse_seg(_txt, obj, doc.matters, suffix, "seg"); goto default; case "code": - doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters); + doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc.matters); break; case "table": - doc_html[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters); + doc_html[segment_filename] ~= xhtml_format.table(_txt, obj, doc.matters); doc_html_endnotes[segment_filename] ~= ""; break; default: @@ -438,7 +429,7 @@ template outputHTML() { doc_html[segment_filename] ~= t[0].to!string; doc_html_endnotes[segment_filename] ~= t[1]; } else { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -447,7 +438,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -460,37 +451,37 @@ template outputHTML() { case "para": switch (obj.metainfo.is_a) { case "endnote": assert(section == "endnotes"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; break; case "glossary": assert(section == "glossary"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "bibliography": assert(section == "bibliography"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "bookindex": assert(section == "bookindex"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "blurb": assert(section == "blurb"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; case "tail": assert(section == "tail"); - t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); + t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -499,7 +490,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -510,7 +501,7 @@ template outputHTML() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_html) { + if (doc.matters.opt.action.debug_do_html) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); } } @@ -519,7 +510,7 @@ template outputHTML() { } } } - seg_write_output(doc_html, doc_html_endnotes, doc_matters); + seg_write_output(doc_html, doc_html_endnotes, doc.matters); } @trusted void seg_write_output(D,E,M)( // @system? D doc_html, @@ -554,7 +545,7 @@ template outputHTML() { } catch (ErrnoException ex) { // handle error } - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pth_html.fn_seg(doc_matters.src.filename, "toc")); } } @@ -587,9 +578,7 @@ template outputHTML() { // Handle error } } - @trusted void images_cp(M)( // @system - M doc_matters, - ) { + @trusted void images_cp(M)(M doc_matters) { // @system { /+ (copy html images) +/ auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (!exists(pth_html.image)) { @@ -604,7 +593,7 @@ template outputHTML() { if (exists(fn_src_in)) { fn_src_in.copy(fn_src_out); } else { - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln("WARNING image not found: ", fn_src_in); } } diff --git a/src/sisudoc/io_out/html_snippet.d b/src/sisudoc/io_out/html_snippet.d index 9cc9259..7f1edea 100644 --- a/src/sisudoc/io_out/html_snippet.d +++ b/src/sisudoc/io_out/html_snippet.d @@ -50,16 +50,14 @@ module sisudoc.io_out.html_snippet; @safe: template htmlSnippet() { - import - std.file, - std.outbuffer, - std.format, - std.uri, - std.conv : to; - import - sisudoc.io_out.rgx, - sisudoc.meta.rgx_files, - sisudoc.io_out.rgx_xhtml; + import std.file; + import std.outbuffer; + import std.format; + import std.uri; + import std.conv : to; + import sisudoc.io_out.rgx; + import sisudoc.meta.rgx_files; + import sisudoc.io_out.rgx_xhtml; auto format_html_blank_page_guide_home()( string css_style, string home_url, diff --git a/src/sisudoc/io_out/hub.d b/src/sisudoc/io_out/hub.d index 498fa5c..f98be01 100644 --- a/src/sisudoc/io_out/hub.d +++ b/src/sisudoc/io_out/hub.d @@ -59,101 +59,110 @@ template outputHub() { sisudoc.io_out.xmls, sisudoc.io_out.create_zip_file, sisudoc.io_out.paths_output; - @system void outputHub(D,I)( - const D doc_abstraction, - I doc_matters - ) { + @system void outputHub(D)(D doc) { mixin Msg; - auto msg = Msg!()(doc_matters); - enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } - void Scheduled(D,I)(int sched, D doc_abstraction, I doc_matters) { - auto msg = Msg!()(doc_matters); + auto msg = Msg!()(doc.matters); + enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff, text, skel } + void Scheduled(D)(int sched, D doc) { + auto msg = Msg!()(doc.matters); if (sched == outTask.source_or_pod) { msg.v("spine (doc reform) source processing... "); - if (doc_matters.opt.action.pod) { msg.v("spine (doc reform) source pod processing... "); } + if (doc.matters.opt.action.pod) { msg.v("spine (doc reform) source pod processing... "); } import sisudoc.io_out.source_pod; - spinePod!()(doc_matters); - if (doc_matters.opt.action.source) { msg.vv("spine (doc reform) source done"); } - if (doc_matters.opt.action.pod) { msg.vv("spine (doc reform) source pod done"); } + spinePod!()(doc.matters); + if (doc.matters.opt.action.source) { msg.vv("spine (doc reform) source done"); } + if (doc.matters.opt.action.pod) { msg.vv("spine (doc reform) source pod done"); } } if (sched == outTask.epub) { msg.v("epub3 processing... "); import sisudoc.io_out.epub3; - doc_abstraction.outputEPub3!()(doc_matters); + doc.outputEPub3!(); msg.vv("epub3 done"); } if (sched == outTask.html_stuff) { - outputMetadata!()(doc_matters); + outputMetadata!()(doc.matters); msg.vv("html metadata done"); } if (sched == outTask.html_scroll) { msg.v("html scroll processing... "); import sisudoc.io_out.html; - outputHTML!().scroll(doc_abstraction, doc_matters); + outputHTML!().scroll(doc); msg.vv("html scroll done"); } if (sched == outTask.html_seg) { msg.v("html seg processing... "); import sisudoc.io_out.html; - outputHTML!().seg(doc_abstraction, doc_matters); + outputHTML!().seg(doc); msg.vv("html seg done"); } if (sched == outTask.html_stuff) { import sisudoc.io_out.html; - outputHTML!().css(doc_matters); - outputHTML!().images_cp(doc_matters); + outputHTML!().css(doc.matters); + outputHTML!().images_cp(doc.matters); msg.vv("html css & images done"); } if (sched == outTask.latex) { msg.v("latex processing... (available for downstream processing & pdf output"); import sisudoc.io_out.latex; import std.file; - if ((isValidPath(doc_matters.output_path ~ "/latex/sty")) - && (!(exists(doc_matters.output_path ~ "/latex/sty"))) + if ((isValidPath(doc.matters.output_path ~ "/latex/sty")) + && (!(exists(doc.matters.output_path ~ "/latex/sty"))) ) { outputLaTeXstyInit!()( - doc_matters.output_path, - doc_matters.opt.action.generated_by, - doc_matters.generator_program.name_version_and_compiler, - doc_matters.generator_program.time_output_generated, + doc.matters.output_path, + doc.matters.opt.action.generated_by, + doc.matters.generator_program.name_version_and_compiler, + doc.matters.generator_program.time_output_generated, ); } - outputLaTeX!()(doc_abstraction, doc_matters); + outputLaTeX!()(doc.abstraction, doc.matters); msg.vv("latex done"); } + if (sched == outTask.text) { + msg.v("text processing... "); + import sisudoc.io_out.text; + outputText!()(doc.abstraction, doc.matters); + msg.vv("text done"); + } if (sched == outTask.odt) { msg.v("odf:odt processing... "); import sisudoc.io_out.odt; - outputODT!()(doc_abstraction, doc_matters); + outputODT!()(doc.abstraction, doc.matters); msg.vv("odf:odt done"); } if (sched == outTask.sqlite) { msg.v("sqlite processing... "); import sisudoc.io_out.sqlite; - doc_abstraction.SQLiteHubDiscreteBuildTablesAndPopulate!()(doc_matters); + doc.SQLiteHubDiscreteBuildTablesAndPopulate!(); msg.vv("sqlite done"); } + if (sched == outTask.skel) { + msg.v("skel processing... "); + import sisudoc.io_out.skel; + outputSkel!()(doc.abstraction, doc.matters); + msg.vv("skel done"); + } } - if (doc_matters.opt.action.vox_gt0) { writeln(doc_matters.src.filename_base); } - if (!(doc_matters.opt.action.parallelise_subprocesses)) { - foreach(schedule; doc_matters.opt.action.output_task_scheduler) { - Scheduled!()(schedule, doc_abstraction, doc_matters); + if (doc.matters.opt.action.vox_gt_1) { writeln(doc.matters.src.filename_base); } + if (!(doc.matters.opt.action.parallelise_subprocesses)) { + foreach(schedule; doc.matters.opt.action.output_task_scheduler) { + Scheduled!()(schedule, doc); } } else { import std.parallelism; - foreach(schedule; parallel(doc_matters.opt.action.output_task_scheduler)) { - Scheduled!()(schedule, doc_abstraction, doc_matters); + foreach(schedule; parallel(doc.matters.opt.action.output_task_scheduler)) { + Scheduled!()(schedule, doc); } } - if (doc_matters.opt.action.sqlite_update) { + if (doc.matters.opt.action.sqlite_update) { msg.v("sqlite update processing..."); import sisudoc.io_out.sqlite; - doc_abstraction.SQLiteHubBuildTablesAndPopulate!()(doc_matters); + doc.SQLiteHubBuildTablesAndPopulate!(); msg.vv("sqlite update done"); - } else if (doc_matters.opt.action.sqlite_delete) { + } else if (doc.matters.opt.action.sqlite_delete) { msg.v("sqlite delete processing..."); import sisudoc.io_out.sqlite; - doc_abstraction.SQLiteHubBuildTablesAndPopulate!()(doc_matters); + doc.SQLiteHubBuildTablesAndPopulate!(); msg.vv("sqlite delete done"); } } @@ -206,23 +215,23 @@ template outputHubOp() { sisudoc.io_out.paths_output; @system void outputHubOp(E,O,C)(E env, O opt_action, C config) { if ((opt_action.sqlite_db_drop)) { - if ((opt_action.vox_gt1)) { + if ((opt_action.vox_gt_2)) { writeln("sqlite drop db..."); } import sisudoc.io_out.sqlite; SQLiteDbDrop!()(opt_action, config); - if ((opt_action.vox_gt2)) { + if ((opt_action.vox_gt_3)) { writeln("sqlite drop db done"); } } if ((opt_action.sqlite_db_create)) { - if ((opt_action.vox_gt1)) { + if ((opt_action.vox_gt_2)) { auto pth_sqlite_db = spinePathsSQLite!()(opt_action.cgi_sqlite_search_filename, opt_action.output_dir_set); writeln("sqlite create table..."); } import sisudoc.io_out.sqlite; SQLiteTablesCreate!()(env, opt_action, config); - if ((opt_action.vox_gt2)) { + if ((opt_action.vox_gt_3)) { writeln("sqlite create table done"); } } diff --git a/src/sisudoc/io_out/latex.d b/src/sisudoc/io_out/latex.d index d26d502..96511c4 100644 --- a/src/sisudoc/io_out/latex.d +++ b/src/sisudoc/io_out/latex.d @@ -50,9 +50,8 @@ module sisudoc.io_out.latex; @safe: template paperLaTeX() { - import - std.format, - std.conv : to; + import std.format; + import std.conv : to; auto paperLaTeX() { string mm(uint mmi) { string _mm = format(q"┃%smm┃", mmi.to!string); @@ -319,15 +318,13 @@ template paperLaTeX() { } } template outputLaTeX() { - import - std.file, - std.outbuffer, - std.uri, - std.conv : to; - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.io_out.rgx_latex; + import std.file; + import std.outbuffer; + import std.uri; + import std.conv : to; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.io_out.rgx_latex; mixin spineRgxOut; static auto rgx = RgxO(); mixin spineRgxLSC; @@ -780,6 +777,24 @@ template outputLaTeX() { } return _txt.strip; } + string quote(O,M)( + string _txt, + O obj, + M doc_matters, + ) { + if (obj.metainfo.is_a == "quote") { + string _tex_para; + _tex_para = q"┃\ocn{%s}\objBlockOpen +"%s" +\objBlockClose +┃"; + _txt = format(_tex_para, + obj.metainfo.object_number, + _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip + ).strip; + } + return _txt; + } string group(O,M)( string _txt, O obj, @@ -793,7 +808,7 @@ template outputLaTeX() { ┃"; _txt = format(_tex_para, obj.metainfo.object_number, - _txt.footnotes.split(rgx.br_line_spaced).join("\\brl{1}").strip // provides more control (more noise, not as tidy) + _txt.footnotes.split(rgx.br_line_spaced).join(" \\brl{1} ").strip // provides more control (more noise, not as tidy) // _txt.footnotes.split(rgx.br_line_spaced).join("") // this works using a line-space, looks tidy, keep ref. ).strip; } @@ -1210,7 +1225,9 @@ template outputLaTeX() { case "block": switch (obj.metainfo.is_a) { case "quote": - goto default; // TODO + _txt = _txt.quote(obj, doc_matters) + .links_and_images(obj, doc_matters); + goto default; case "group": /+ (hardspaces not honored) [remove any hardspace marker] +/ _txt = _txt.group(obj, doc_matters) .links_and_images(obj, doc_matters); @@ -1297,7 +1314,7 @@ template outputLaTeX() { default: { /+ debug +/ if (doc_matters.opt.action.debug_do_latex - && doc_matters.opt.action.vox_gt1) { + && doc_matters.opt.action.vox_gt_2) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); writeln(__FILE__, ":", __LINE__, ": ", obj.text); @@ -1335,7 +1352,7 @@ template outputLaTeX() { try { { /+ debug +/ if (doc_matters.opt.action.debug_do_latex - && doc_matters.opt.action.vox_gt1) { + && doc_matters.opt.action.vox_gt_2) { writeln(latex_content.head); writeln(latex_content.content); writeln(latex_content.tail); @@ -1344,7 +1361,7 @@ template outputLaTeX() { if (!exists(pth_latex.latex_path_stuff)) { (pth_latex.latex_path_stuff).mkdirRecurse; } - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pth_latex.latex_file_with_path(paper_size_orientation)); } { @@ -1411,7 +1428,7 @@ template outputLaTeX() { string content; string tail; } - auto latex = LaTeX(); + LaTeX latex = LaTeX(); foreach (paper_size_orientation; doc_matters.conf_make_meta.conf.set_papersize) { latex.head = latex_head(doc_matters, paper_size_orientation); latex.content = latex_body(doc_abstraction, doc_matters, paper_size_orientation); @@ -1487,9 +1504,8 @@ template outputLaTeXstyInit() { } } template outputLaTeXstyStatic() { - import - std.format, - std.conv : to; + import std.format; + import std.conv : to; string outputLaTeXstyStatic( bool generated_by, string name_version_and_compiler, @@ -1730,9 +1746,8 @@ template outputLaTeXstyStatic() { } } template outputLaTeXstyPaperSizeAndOrientation() { - import - std.format, - std.conv : to; + import std.format; + import std.conv : to; auto outputLaTeXstyPaperSizeAndOrientation(P)( P doc_sty_info, bool generated_by, diff --git a/src/sisudoc/io_out/metadata.d b/src/sisudoc/io_out/metadata.d index 4d540af..a89b31a 100644 --- a/src/sisudoc/io_out/metadata.d +++ b/src/sisudoc/io_out/metadata.d @@ -109,11 +109,10 @@ template outputMetadata() { } return o; } - import - std.digest.crc, - std.digest.sha, - std.file, - std.format; + import std.digest.crc; + import std.digest.sha; + import std.file; + import std.format; import sisudoc.io_out; mixin InternalMarkup; char[] metadata_; @@ -393,7 +392,7 @@ string theme_light_1 = format(q"┃ } catch (ErrnoException ex) { // Handle error } - if (doc_matters.opt.action.vox_gt0) { writeln(" ", pth_html.fn_scroll("metadata." ~ doc_matters.src.filename)); } + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pth_html.fn_scroll("metadata." ~ doc_matters.src.filename)); } } static auto mkup = InlineMarkup(); import sisudoc.io_out.html_snippet; @@ -418,6 +417,7 @@ string theme_light_1 = format(q"┃ } auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); auto pth_epub = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); + auto pth_text = spinePathsText!()(doc_matters); auto pth_pdf = spinePathsPDF!()(doc_matters); auto pth_pod = spinePathsPods!()(doc_matters); metadata_ ~= format(q"┃<body lang="en" xml:lang="en"> @@ -443,7 +443,7 @@ string theme_light_1 = format(q"┃ metadata_ ~= "</div>" ~ inline_search_form(doc_matters) ~ "</div><hr />"; if (!(doc_matters.conf_make_meta.meta.title_full.empty)) { metadata_ ~= "<p class=\"lev0\">Title: <b><a href=\"" ~ doc_matters.src.filename_base ~ "/toc.html\">" ~ doc_matters.conf_make_meta.meta.title_full ~ "</a></b></p>"; - } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { writeln("ERROR no Title information provided in document header ", doc_matters.src.filename_base); } if (!(doc_matters.conf_make_meta.meta.creator_author.empty)) { @@ -454,18 +454,18 @@ string theme_light_1 = format(q"┃ metadata_ ~= "<p class=\"lev1\">Author: <b>" ~ doc_matters.conf_make_meta.meta.creator_author ~ "</b></p>"; } - } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { writeln("ERROR no Author information provided in document header ", doc_matters.src.filename_base); } metadata_ ~= "<p class=\"lev1\">Published: " ~ doc_matters.conf_make_meta.meta.date_published ~ "</p>"; if (!(doc_matters.conf_make_meta.meta.rights_copyright.empty)) { metadata_ ~= "<p class=\"lev1\">Copyright: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright) ~ "</p>"; - } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { writeln("WARNING no Copyright information provided in document header ", doc_matters.src.filename_base); } if (!(doc_matters.conf_make_meta.meta.rights_license.empty)) { metadata_ ~= "<p class=\"lev1\">License: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_license) ~ "</p>"; - } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { writeln("WARNING no License information provided in document header ", doc_matters.src.filename_base); } if (!(doc_matters.conf_make_meta.meta.notes_summary.empty)) { @@ -499,6 +499,10 @@ string theme_light_1 = format(q"┃ ~ "." ~ doc_matters.src.language ~ ".letter.portrait.pdf\" class=\"lnkicon\">" ~ " □ pdf (U.S. letter) </a>] "; } + if (doc_matters.opt.action.html_link_text) { + metadata_ ~= " [<a href=\"../" ~ "text/" ~ doc_matters.src.filename_base ~ "." ~ doc_matters.src.language ~ ".txt\" class=\"lnkicon\">" + ~ " □ txt </a>] "; + } metadata_ ~= "</p>"; if (doc_matters.opt.action.html_link_markup_source) { metadata_ ~= "<hr /><p class=\"lev1\">source: " ~ doc_matters.src.filename_base ~ "</p>"; diff --git a/src/sisudoc/io_out/odt.d b/src/sisudoc/io_out/odt.d index 8740d44..c8f5fe9 100644 --- a/src/sisudoc/io_out/odt.d +++ b/src/sisudoc/io_out/odt.d @@ -50,20 +50,17 @@ module sisudoc.io_out.odt; @safe: template formatODT() { - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.io_out.rgx_xhtml; - import - std.file, - std.outbuffer, - std.uri, - std.zip, - std.conv : to; - import - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls, - sisudoc.io_out.xmls_css; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.io_out.rgx_xhtml; + import std.file; + import std.outbuffer; + import std.uri; + import std.zip; + import std.conv : to; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; + import sisudoc.io_out.xmls_css; mixin spineRgxOut; mixin spineRgxXHTML; struct formatODT { @@ -645,20 +642,17 @@ template formatODT() { } } template outputODT() { - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.io_out.rgx_xhtml; - import - std.file, - std.outbuffer, - std.uri, - std.zip, - std.conv : to; - import - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls, - sisudoc.io_out.xmls_css; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.io_out.rgx_xhtml; + import std.file; + import std.outbuffer; + import std.uri; + import std.zip; + import std.conv : to; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; + import sisudoc.io_out.xmls_css; mixin InternalMarkup; mixin spineRgxOut; mixin spineRgxXHTML; @@ -886,7 +880,7 @@ template outputODT() { default: { /+ debug +/ if (doc_matters.opt.action.debug_do - && doc_matters.opt.action.vox_gt1) { + && doc_matters.opt.action.vox_gt_2) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); writeln(__FILE__, ":", __LINE__, ": ", obj.text); @@ -2099,7 +2093,7 @@ template outputODT() { } } } - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pth_odt.odt_file); } } diff --git a/src/sisudoc/io_out/package.d b/src/sisudoc/io_out/package.d index 1ab72b0..7cc69ff 100644 --- a/src/sisudoc/io_out/package.d +++ b/src/sisudoc/io_out/package.d @@ -48,22 +48,20 @@ +/ module sisudoc.io_out; -public import - std.algorithm, - std.array, - std.container, - std.exception, - std.path, - std.process, - std.range, - std.regex, - std.stdio, - std.string, - std.typecons, - // std.uni, - std.utf; -public import - sisudoc.share.defaults, - sisudoc.io_in.paths_source, - sisudoc.io_out.defaults, - sisudoc.io_out.paths_output; +public import std.algorithm; +public import std.array; +public import std.container; +public import std.exception; +public import std.path; +public import std.process; +public import std.range; +public import std.regex; +public import std.stdio; +public import std.string; +public import std.typecons; +// public import std.uni; +public import std.utf; +public import sisudoc.share.defaults; +public import sisudoc.io_in.paths_source; +public import sisudoc.io_out.defaults; +public import sisudoc.io_out.paths_output; diff --git a/src/sisudoc/io_out/paths_output.d b/src/sisudoc/io_out/paths_output.d index 72508fc..c3e677d 100644 --- a/src/sisudoc/io_out/paths_output.d +++ b/src/sisudoc/io_out/paths_output.d @@ -52,13 +52,11 @@ +/ module sisudoc.io_out.paths_output; @safe: -import - std.array, - std.path, - std.regex, - std.stdio; -import - sisudoc.meta.rgx_files; +import std.array; +import std.path; +import std.regex; +import std.stdio; +import sisudoc.meta.rgx_files; template spineOutPaths() { auto spineOutPaths()( string output_pth_root, @@ -473,7 +471,7 @@ template spinePathsODT() { auto spinePathsODT(M)( M doc_matters, ) { - auto out_pth = spineOutPaths!()( doc_matters.output_path, doc_matters.src.language); + auto out_pth = spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); string base_dir = "odf"; struct _PathsStruct { string base_pth() { // dir will contain odt document file (also debug file tree) @@ -670,3 +668,52 @@ template spinePathsSQLite() { return _PathsStruct(); } } + +template spinePathsText() { + import std.conv; + auto spinePathsText(M)( + M doc_matters, + ) { + auto out_pth = spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); + string base_dir = "text"; + struct _PathsStruct { + string base_pth() { + return (((out_pth.output_base).chainPath(base_dir)).asNormalizedPath).array; + } + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string text_file() { + return ((base_pth.chainPath(doc_matters.src.doc_uid_out ~ ".txt")).asNormalizedPath).array; + } + string dirtop() { + return "".chainPath("").array; + } + } + return _PathsStruct(); + } +} +template spinePathsSkel() { + import std.conv; + auto spinePathsSkel(M)( + M doc_matters, + ) { + auto out_pth = spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); + string base_dir = "skel"; + struct _PathsStruct { + string base_pth() { + return (((out_pth.output_base).chainPath(base_dir)).asNormalizedPath).array; + } + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string skel_file() { + return ((base_pth.chainPath(doc_matters.src.doc_uid_out ~ ".skel")).asNormalizedPath).array; + } + string dirtop() { + return "".chainPath("").array; + } + } + return _PathsStruct(); + } +} diff --git a/src/sisudoc/io_out/rgx.d b/src/sisudoc/io_out/rgx.d index 9c70c1e..f54deda 100644 --- a/src/sisudoc/io_out/rgx.d +++ b/src/sisudoc/io_out/rgx.d @@ -78,9 +78,9 @@ static template spineRgxOut() { static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg"); static br_linebreaks_newlines = ctRegex!(`[\n┘┙]`, "mg"); static br_linebreaks = ctRegex!(`[┘┙]`, "mg"); - static br_line = ctRegex!(`┘`, "mg"); - static br_line_inline = ctRegex!(`┙`, "mg"); - static br_line_spaced = ctRegex!(`┚`, "mg"); + static br_line = ctRegex!(`\s*┘\s*`, "mg"); + static br_line_inline = ctRegex!(`\s*┙\s*`, "mg"); + static br_line_spaced = ctRegex!(`\s*┚\s*`, "mg"); /+ quotation marks +/ static quotes_open_and_close = ctRegex!(`[“”]`, "mg"); /+ inline markup footnotes endnotes +/ @@ -95,6 +95,7 @@ static template spineRgxOut() { static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|.+))`, "mg"); + static endnote_section_note = ctRegex!(`┥\s*⑆\^┨(?P<notenumber>\d+)\.┣\^┝┤(?P<link>¤?.+?)├.+`, "mg"); /+ inline markup links +/ static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); @@ -109,6 +110,7 @@ static template spineRgxOut() { static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static find_bookindex_ocn_link_and_comma = ctRegex!(`[, ]*┥.+?┝┤#?\S+?├`, "mg"); static url = ctRegex!(`https?://`, "mg"); static uri = ctRegex!(`(?:https?|git)://`, "mg"); static uri_identify_components = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); diff --git a/src/sisudoc/io_out/skel.d b/src/sisudoc/io_out/skel.d new file mode 100644 index 0000000..b616695 --- /dev/null +++ b/src/sisudoc/io_out/skel.d @@ -0,0 +1,268 @@ +/+ +- Name: SisuDoc Spine, Doc Reform [a part of] + - Description: documents, structuring, processing, publishing, search + - static content generator + + - Author: Ralph Amissah + [ralph.amissah@gmail.com] + + - Copyright: (C) 2015 - 2025 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.skel; +@safe: +template outputSkel() { + template munge() { + import std.stdio; + import std.conv; + void puts(string _obj_is) { + writeln(__FILE__, ":", __LINE__, ": ", _obj_is); + } + string newline = "\n"; + string newlines = "\n\n"; + string toc(O)(O obj) { + // puts(obj.metainfo.is_a); + // return "toc\n"; + return obj.text ~ newline; + } + string heading(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string para(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string group(O)(O obj) { + /+ + The "group" is different from the "block" mark in that "group" does not + preserve whitespace, the "block" mark does. The text falling within the + block is a single object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string block(O)(O obj) { + /+ + The "block" is different from the "group" mark in that the "block" mark + (like the "poem" mark) preserves whitespace, the "group" mark does not. + The text falling within the "block" is a single object, which is different + from the "poem" mark where each identified verse is an object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string poem(O)(O obj) { + /+ + The "poem" mark like the "block" preserves whitespace. Text followed by + two newlines are identified as verse and each verse is an object i.e. a + poem may consist of multiple verse each of which is identified as an + object, unlike a text "block" which is identified as a single object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + // return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + return obj.text ~ newlines; + } + string verse(O)(O obj) { + /+ + See description of poem, the poem is demarkated but the verse is the + object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string code(O)(O obj) { + /+ + "Code" blocks are a single text object, in which the original text is + preserved. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string quote(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string table(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string endnote(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string bookindex(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string bibliography(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string glossary(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string blurb(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string comment(O)(O obj) { + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + } + template theDocument() { + import std.stdio; + import sisudoc.io_out; + // static auto rgx = RgxO(); + string skel_head(M)( + M doc_matters, + ) { + return "head"; + } + string skel_body(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + string doc_object = ""; + foreach (section; doc_matters.has.keys_seq.scroll) { + foreach (obj; doc_abstraction[section]) { + if (obj.metainfo.is_a == "toc") { doc_object ~= munge!().toc(obj); } + if (obj.metainfo.is_a == "heading") { doc_object ~= munge!().heading(obj); } + if (obj.metainfo.is_a == "para") { doc_object ~= munge!().para(obj); } + if (obj.metainfo.is_a == "group") { doc_object ~= munge!().group(obj); } + if (obj.metainfo.is_a == "block") { doc_object ~= munge!().block(obj); } + if (obj.metainfo.is_a == "poem") { doc_object ~= munge!().poem(obj); } + if (obj.metainfo.is_a == "verse") { doc_object ~= munge!().verse(obj); } + if (obj.metainfo.is_a == "code") { doc_object ~= munge!().code(obj); } + if (obj.metainfo.is_a == "quote") { doc_object ~= munge!().quote(obj); } + if (obj.metainfo.is_a == "table") { doc_object ~= munge!().table(obj); } + if (obj.metainfo.is_a == "endnote") { doc_object ~= munge!().endnote(obj); } + if (obj.metainfo.is_a == "bookindex") { doc_object ~= munge!().bookindex(obj); } + if (obj.metainfo.is_a == "bibliography") { doc_object ~= munge!().bibliography(obj); } + if (obj.metainfo.is_a == "glossary") { doc_object ~= munge!().glossary(obj); } + if (obj.metainfo.is_a == "blurb") { doc_object ~= munge!().blurb(obj); } + if (obj.metainfo.is_a == "comment") { doc_object ~= munge!().comment(obj); } + } + } + return doc_object; + } + string skel_tail(M)( + M doc_matters, + ) { + return "tail"; + } + } + void outputSkel(D,M) ( + const D doc_abstraction, + M doc_matters, + ) { + import std.stdio; + import sisudoc.io_out; + void skel_out(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + struct Skel { + string head; + string content; + string tail; + } + auto skel = Skel(); + skel.head = theDocument!().skel_head(doc_matters); + skel.content = theDocument!().skel_body(doc_abstraction, doc_matters); + skel.tail = theDocument!().skel_tail(doc_matters); + auto pth_skel = spinePathsSkel(doc_matters); + try { + import std.file; + if (!exists(pth_skel.base_pth)) { + (pth_skel.base_pth).mkdirRecurse; + } + } catch (ErrnoException ex) { + } + if (doc_matters.opt.action.vox_gt_1) { + writeln(" ", pth_skel.skel_file); + } + // writeln(pth_skel.base_pth); + auto f = File(pth_skel.skel_file, "w"); + f.writeln(skel.head); + f.writeln(skel.content); + f.writeln(skel.tail); + } + skel_out(doc_abstraction, doc_matters); + } +} diff --git a/src/sisudoc/io_out/source_pod.d b/src/sisudoc/io_out/source_pod.d index a6253ab..bfc2fac 100644 --- a/src/sisudoc/io_out/source_pod.d +++ b/src/sisudoc/io_out/source_pod.d @@ -50,18 +50,15 @@ module sisudoc.io_out.source_pod; @system: // is not @safe: use: @system: or @trusted: template spinePod() { - import - sisudoc.meta.rgx_files, - sisudoc.io_out; - import - std.digest.sha, - std.file, - std.outbuffer, - std.zip, - std.conv : to; - import - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls; + import std.digest.sha; + import std.file; + import std.outbuffer; + import std.zip; + import std.conv : to; + import sisudoc.meta.rgx_files; + import sisudoc.io_out; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; void spinePod(T)(T doc_matters) { debug(asserts) { // static assert(is(typeof(doc_matters) == tuple)); @@ -73,7 +70,7 @@ template spinePod() { auto lang = Lang(); static auto rgx_files = RgxFiles(); assert (doc_matters.src.filename.match(rgx_files.src_fn)); - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { try { { podArchive_directory_tree(doc_matters, pths_pod); @@ -104,7 +101,7 @@ template spinePod() { pths_pod.pod_dir_().mkdirRecurse; } if (doc_matters.opt.action.source_or_pod) { - // if (doc_matters.opt.action.vox_gt0) { writeln(" ", pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod); } + // if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod); } if (!exists(pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod)) { pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; } @@ -139,8 +136,8 @@ template spinePod() { } auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) { auto pth_dr_doc_src = doc_matters.src_path_info; - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { - writeln(__LINE__, ": ", + if (doc_matters.opt.action.vox_gt_3) { // correct + writeln(__LINE__, ":", __FILE__, ":\n", doc_matters.src.filename, " -> ", pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod ); @@ -150,7 +147,7 @@ template spinePod() { string[string][string] _digests; { // bundle images - get digest foreach (image; doc_matters.srcs.image_list) { - debug(podimages) { + if (doc_matters.opt.action.vox_gt_3) { writeln( pth_dr_doc_src.image_root.to!string, "/", image, " -> ", pths_pod.image_root(doc_matters.src.filename).zpod, "/", image @@ -173,11 +170,11 @@ template spinePod() { if (doc_matters.opt.action.source_or_pod) { fn_src_in.copy(fn_src_out_filesystem); } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { zip = podArchive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip); } } else { - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { writeln("WARNING (io) src out NOT found (image): ", fn_src_in); } } @@ -197,11 +194,11 @@ template spinePod() { if (doc_matters.opt.action.source_or_pod) { fn_src_in.copy(fn_src_out_filesystem); } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); } } else { - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); } } @@ -225,7 +222,7 @@ template spinePod() { = File(pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod, "w"); Node _pmy; string _pm = "doc:\n filename: " ~ doc_matters.src.filename ~ "\n language: " ~ doc_matters.pod.manifest_list_of_languages.to!string ~ "\n"; - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { try { _pmy = Loader.fromString(_pm).load(); } catch (ErrnoException ex) { @@ -242,7 +239,7 @@ template spinePod() { if (doc_matters.opt.action.source_or_pod) { pod_filelist_yaml_string.writeln(_pm); } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { zip = podArchive("string", _pm, fn_src_out_pod_zip_base, zip); } } @@ -262,11 +259,14 @@ template spinePod() { string fn_src_out_filesystem_lng = pths_pod.fn_doc(doc_matters.src.filename, _lang).filesystem_open_zpod.to!string; string _sstm = (doc_matters.pod.manifest_path ~ "/media/text/" ~ _lang ~ "/" ~ doc_matters.src.filename); - // writeln(_sstm); - if (exists(_sstm)) { // what of language? - debug(io) { writeln("(io debug) src in found: ", _sstm); } + string _pth_file_sstm; + if (exists(_sstm)) { _pth_file_sstm = _sstm; + } else if (exists(fn_src_in)) { _pth_file_sstm = fn_src_in; + } + if (exists(_pth_file_sstm)) { // what of language? + debug(io) { writeln("(io debug) src in found: ", _pth_file_sstm); } { // take DIGEST write to pod file digests.txt - auto data = (cast(byte[]) (_sstm).read); + auto data = (cast(byte[]) (_pth_file_sstm).read); _digests[_lang]["sstm"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename ~ " - [" ~ _lang ~ "]"; // writeln(data.sha256Of.toHexString, "::", data.length, " - ", doc_matters.src.filename); } @@ -274,11 +274,11 @@ template spinePod() { filelist_src_zpod_arr ~= fn_src_out_inside_pod; string _pod_to_markup_file = doc_matters.src.pod_name ~ "/" ~ "media/text/" ~ _lang ~ "/" ~ doc_matters.src.filename; if (doc_matters.opt.action.source_or_pod) { - _sstm.copy(fn_src_out_filesystem_lng); + _pth_file_sstm.copy(fn_src_out_filesystem_lng); } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { auto _rgx_sstm = regex(r"(?P<path_to_pod>\S+?)(?P<podname>[a-z_-]+)/(?P<from_root>media/text/)(?P<language>\S+?)/(?P<filename>\S+?\.ss[mt])"); - if (auto _x = _sstm.match(_rgx_sstm)){ + if (auto _x = _pth_file_sstm.match(_rgx_sstm)){ if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) { // again wait until all language versions of .ssm parsed string _path_to_pod = _x.captures["path_to_pod"]; string _podname = _x.captures["podname"]; @@ -293,12 +293,12 @@ template spinePod() { } } } else { - zip = podArchive("file_path_text", _sstm, fn_src_out_pod_zip_base, zip); + zip = podArchive("file_path_text", _pth_file_sstm, fn_src_out_pod_zip_base, zip); } } } else { - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src in NOT found (markup source): ", _sstm); + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { + writeln("WARNING (io) src in NOT found (markup source): \n", _sstm, "or in", fn_src_in); } } } @@ -342,11 +342,11 @@ template spinePod() { ).filesystem_open_zpod.to!string; _pth_mkup_src_in.copy(fn_src_out_filesystem); // check why here, thought dealt with elsewhere } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { zip = podArchive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip); } } else { - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { writeln("WARNING (io) src out NOT found (insert file): ", _pth_mkup_src_in); } } @@ -376,11 +376,11 @@ template spinePod() { if (doc_matters.opt.action.source_or_pod) { fn_src_in.copy(fn_src_out_filesystem); } - if (doc_matters.opt.action.pod) { + if (doc_matters.opt.action.source_or_pod) { zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); } } else { - if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) { writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); } } @@ -446,19 +446,19 @@ template spinePod() { // Handle error } try { - // if (doc_matters.opt.action.vox_gt1) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, ".digests.txt"); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, ".digests.txt"); } string _digest_fn = pths_pod.pod_dir_() ~ "/" ~ doc_matters.src.filename_base ~ ".digests.txt"; - // if (doc_matters.opt.action.vox_gt1) { writeln(_digest_fn); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(_digest_fn); } auto f = File(_digest_fn, "w"); if (exists(fn_pod)) { try { auto data = (cast(byte[]) (fn_pod).read); - // if (doc_matters.opt.action.vox_gt1) { writeln(" ", doc_matters.src.filename, " > ", doc_matters.src.filename_base, ".zip"); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(" ", doc_matters.src.filename, " > ", doc_matters.src.filename_base, ".zip"); } if (doc_matters.opt.action.pod) { _zip_digest = (data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename_base ~ ".zip"); - if (doc_matters.opt.action.vox_gt0) { writeln(" ", _zip_digest); } - if (doc_matters.opt.action.vox_gt0) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, "/"); } - if (doc_matters.opt.action.vox_gt0) { writeln(" ", _digest_fn); } + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", _zip_digest); } + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, "/"); } + if (doc_matters.opt.action.vox_gt_1) { writeln(" ", _digest_fn); } f.writeln(_zip_digest); } } catch (ErrnoException ex) { @@ -468,18 +468,18 @@ template spinePod() { foreach (_lang; doc_matters.pod.manifest_list_of_languages) { if (_lang in _digests) { if (("sstm" in _digests[_lang]) && (_digests[_lang]["sstm"].length > 0)) { - // if (doc_matters.opt.action.vox_gt1) { writeln(_digests[_lang]["sstm"]); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(_digests[_lang]["sstm"]); } f.writeln(_digests[_lang]["sstm"]); } if (("ssi" in _digests[_lang]) && (_digests[_lang]["ssi"].length > 0)) { - // if (doc_matters.opt.action.vox_gt1) { writeln(_digests[_lang]["ssi"]); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(_digests[_lang]["ssi"]); } f.writeln(_digests[_lang]["ssi"]); } } } if ("shared" in _digests) { if (("images" in _digests["shared"]) && (_digests["shared"]["images"].length > 0)) { - // if (doc_matters.opt.action.vox_gt1) { writeln(_digests["shared"]["images"]); } + // if (doc_matters.opt.action.vox_gt_2) { writeln(_digests["shared"]["images"]); } f.writeln(_digests["shared"]["images"]); } } diff --git a/src/sisudoc/io_out/sqlite.d b/src/sisudoc/io_out/sqlite.d index 4075bba..a62e658 100644 --- a/src/sisudoc/io_out/sqlite.d +++ b/src/sisudoc/io_out/sqlite.d @@ -48,13 +48,12 @@ +/ module sisudoc.io_out.sqlite; -import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.io_out.rgx_xhtml; -import - std.file, - std.uri; +import sisudoc.io_out; +import sisudoc.io_out.rgx; +import sisudoc.io_out.rgx_xhtml; +import std.file; +import std.uri; +// import std.digest.sha; import std.conv : to; import std.typecons : Nullable; import d2sqlite3; @@ -66,11 +65,8 @@ static auto rgx_xhtml = RgxXHTML(); static auto mkup = InlineMarkup(); long _metadata_tid_lastrowid; template SQLiteHubBuildTablesAndPopulate() { - void SQLiteHubBuildTablesAndPopulate(D,M)( - const D doc_abstraction, - M doc_matters, - ) { - auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path); + void SQLiteHubBuildTablesAndPopulate(D)(D doc) { + auto pth_sqlite = spinePathsSQLite!()(doc.matters.sqlite.filename, doc.matters.sqlite.path); if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { } else { try { @@ -78,14 +74,13 @@ template SQLiteHubBuildTablesAndPopulate() { } catch (FileException ex) { } } template SQLiteDbStatementComposite() { - void SQLiteDbStatementComposite(Db,D,M)( - Db db, - const D doc_abstraction, - M doc_matters, + void SQLiteDbStatementComposite(Db,D)( + Db db, + D doc ) { string _db_statement; - if ((doc_matters.opt.action.sqlite_db_create)) { - auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path); + if ((doc.matters.opt.action.sqlite_db_create)) { + auto pth_sqlite = spinePathsSQLite!()(doc.matters.sqlite.filename, doc.matters.sqlite.path); if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { } else { try { @@ -93,38 +88,38 @@ template SQLiteHubBuildTablesAndPopulate() { } catch (FileException ex) { } } _db_statement ~= SQLiteTablesReCreate!()(); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "TABLE RE-CREATE"); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "TABLE RE-CREATE"); _db_statement = []; } - if (doc_matters.opt.action.sqlite_delete) { - _db_statement ~= SQLiteDeleteDocument!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "DELETE Document"); + if (doc.matters.opt.action.sqlite_delete) { + _db_statement ~= SQLiteDeleteDocument!()(doc.matters); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "DELETE Document"); _db_statement = []; } - if (doc_matters.opt.action.sqlite_update) { - _db_statement ~= SQLiteDeleteDocument!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "DELETE Document"); + if (doc.matters.opt.action.sqlite_update) { + _db_statement ~= SQLiteDeleteDocument!()(doc.matters); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "DELETE Document"); _db_statement = []; - _db_statement ~= SQLiteInsertMetadata!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT MetaData"); + _db_statement ~= SQLiteInsertMetadata!()(doc.matters); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "INSERT MetaData"); _db_statement = []; - /+ get tid (lastrowid or max) for use in doc_objects table +/ - _db_statement ~= doc_abstraction.SQLiteInsertDocObjectsLoop!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT DocObjects"); + /+ get tid (lastrowid or max) for use in doc.objects table +/ + _db_statement ~= doc.SQLiteInsertDocObjectsLoop!(); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "INSERT DocObjects"); _db_statement = []; - _db_statement ~= SQLiteInsertMetadataTopics!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT MetaDataTopics"); + _db_statement ~= SQLiteInsertMetadataTopics!()(doc.matters); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "INSERT MetaDataTopics"); _db_statement = []; } db.close; - if (doc_matters.opt.action.vox_gt0) { + if (doc.matters.opt.action.vox_gt_1) { writeln(" ", pth_sqlite.sqlite_file); } } } try { auto db = Database(pth_sqlite.sqlite_file); - SQLiteDbStatementComposite!()(db, doc_abstraction, doc_matters); + SQLiteDbStatementComposite!()(db, doc); } catch (FileException e) { writeln("Failed (FileException): ", e.msg, " ", pth_sqlite.sqlite_file); @@ -152,33 +147,29 @@ template SQLiteHubBuildTablesAndPopulate() { } } template SQLiteHubDiscreteBuildTablesAndPopulate() { - void SQLiteHubDiscreteBuildTablesAndPopulate(D,M)( - const D doc_abstraction, - M doc_matters, - ) { - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); - auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); // doc_matters.db_path + void SQLiteHubDiscreteBuildTablesAndPopulate(D)(D doc) { + auto url_html = spineUrlsHTML!()(doc.matters.conf_make_meta.conf.w_srv_data_root_url_html, doc.matters.src.language); + auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc.matters.output_path, doc.matters.src.language); // doc.matters.db_path if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { } else { try { pth_sqlite.base.mkdirRecurse; } catch (FileException ex) { } } - auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); + auto db = Database(pth_sqlite.sqlite_file(doc.matters.src.filename)); template SQLiteDiscreteDbStatementComposite() { - void SQLiteDiscreteDbStatementComposite(Db,D,M)( - Db db, - const D doc_abstraction, - M doc_matters, + void SQLiteDiscreteDbStatementComposite(Db,D)( + Db db, + D doc ) { try { { string _db_statement; _db_statement ~= SQLiteTablesReCreate!()(); - _db_statement ~= SQLiteInsertMetadata!()(doc_matters); - _db_statement ~= SQLiteInsertMetadataTopics!()(doc_matters); - _db_statement ~= doc_abstraction.SQLiteInsertDocObjectsLoop!()(doc_matters); - SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "table CREATE Tables, INSERT DocObjects"); + _db_statement ~= SQLiteInsertMetadata!()(doc.matters); + _db_statement ~= SQLiteInsertMetadataTopics!()(doc.matters); + _db_statement ~= doc.SQLiteInsertDocObjectsLoop!(); + SQLiteDbRun!()(db, _db_statement, doc.matters.opt.action, "table CREATE Tables, INSERT DocObjects"); } db.close; } @@ -204,12 +195,12 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() { import core.runtime; core.runtime.Runtime.terminate(); } - if (doc_matters.opt.action.vox_gt0) { - writeln(" ", pth_sqlite.sqlite_file(doc_matters.src.filename)); + if (doc.matters.opt.action.vox_gt_1) { + writeln(" ", pth_sqlite.sqlite_file(doc.matters.src.filename)); } } } - SQLiteDiscreteDbStatementComposite!()(db, doc_abstraction, doc_matters); + SQLiteDiscreteDbStatementComposite!()(db, doc); } } template SQLiteDbRun() { @@ -236,7 +227,7 @@ template SQLiteDbRun() { { /+ debug +/ if (opt_action.debug_do_sqlite) { writeln(note); - if (opt_action.vox_gt2) { + if (opt_action.vox_gt_3) { writeln(db_statement); } } @@ -251,9 +242,7 @@ template SQLinsertDelimiter() { } } template SQLiteFormatAndLoadObject() { - auto SQLiteFormatAndLoadObject(M)( - M doc_matters, - ) { + auto SQLiteFormatAndLoadObject(M)(M doc_matters) { mixin spineRgxOut; mixin spineRgxXHTML; struct sqlite_format_and_load_objects { @@ -491,7 +480,7 @@ template SQLiteFormatAndLoadObject() { ); } } else { - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln( "WARNING on internal document links, anchor to link <<" ~ m.captures["hash"] @@ -1143,9 +1132,7 @@ template SQLiteTablesReCreate() { } } template SQLiteDeleteDocument() { - string SQLiteDeleteDocument(M)( - M doc_matters, - ) { + string SQLiteDeleteDocument(M)(M doc_matters) { string _uid = doc_matters.src.doc_uid; string _delete_uid = format(q"┃ DELETE FROM metadata_and_text @@ -1160,9 +1147,7 @@ template SQLiteDeleteDocument() { } } template SQLiteInsertMetadata() { - string SQLiteInsertMetadata(M)( - M doc_matters, - ) { + string SQLiteInsertMetadata(M)(M doc_matters) { string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); string _insert_metadata = format(q"┃ INSERT INTO metadata_and_text ( @@ -1276,9 +1261,7 @@ template SQLiteInsertMetadata() { } } template SQLiteInsertMetadataTopics() { - string SQLiteInsertMetadataTopics(M)( - M doc_matters, - ) { + string SQLiteInsertMetadataTopics(M)(M doc_matters) { string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); string[] _insert_topics; foreach (topic_line; doc_matters.conf_make_meta.meta.classify_topic_register_expanded_arr) { @@ -1301,12 +1284,9 @@ template SQLiteInsertMetadataTopics() { } } template SQLiteInsertDocObjectsLoop() { - string SQLiteInsertDocObjectsLoop(D,M)( - const D doc_abstraction, - M doc_matters, - ) { - string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); + string SQLiteInsertDocObjectsLoop(D)(D doc) { + string _uid = SQLinsertDelimiter!()(doc.matters.src.doc_uid); + auto url_html = spineUrlsHTML!()(doc.matters.conf_make_meta.conf.w_srv_data_root_url_html, doc.matters.src.language); string insertDocObjectsRow(O)(O obj) { string _insert_doc_objects_row = format(q"┃ INSERT INTO doc_objects ( @@ -1336,23 +1316,23 @@ template SQLiteInsertDocObjectsLoop() { ); return _insert_doc_objects_row; } - auto format_and_sqlite_load = SQLiteFormatAndLoadObject!()(doc_matters); + auto format_and_sqlite_load = SQLiteFormatAndLoadObject!()(doc.matters); string[string] obj_txt; string doc_text; string[] _insert_doc_objects; - foreach (part; doc_matters.has.keys_seq.sql) { - foreach (obj; doc_abstraction[part]) { + foreach (part; doc.matters.has.keys_seq.sql) { + foreach (obj; doc.abstraction[part]) { switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head", part); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { case "heading": - obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + obj_txt = format_and_sqlite_load.heading(doc.matters, obj); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -1361,7 +1341,7 @@ template SQLiteInsertDocObjectsLoop() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -1378,14 +1358,14 @@ template SQLiteInsertDocObjectsLoop() { writeln(__LINE__, ": ", obj.text); } } - obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + obj_txt = format_and_sqlite_load.heading(doc.matters, obj); break; case "para": - obj_txt = format_and_sqlite_load.para(doc_matters, obj); + obj_txt = format_and_sqlite_load.para(doc.matters, obj); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -1395,28 +1375,28 @@ template SQLiteInsertDocObjectsLoop() { case "block": switch (obj.metainfo.is_a) { case "quote": - obj_txt = format_and_sqlite_load.quote(doc_matters, obj); + obj_txt = format_and_sqlite_load.quote(doc.matters, obj); break; case "group": - obj_txt = format_and_sqlite_load.group(doc_matters, obj); + obj_txt = format_and_sqlite_load.group(doc.matters, obj); break; case "block": - obj_txt = format_and_sqlite_load.block(doc_matters, obj); + obj_txt = format_and_sqlite_load.block(doc.matters, obj); break; case "poem": // double check on keeping both poem & verse break; case "verse": - obj_txt = format_and_sqlite_load.verse(doc_matters, obj); + obj_txt = format_and_sqlite_load.verse(doc.matters, obj); break; case "code": - obj_txt = format_and_sqlite_load.code(doc_matters, obj); + obj_txt = format_and_sqlite_load.code(doc.matters, obj); break; case "table": - obj_txt = format_and_sqlite_load.table(doc_matters, obj); + obj_txt = format_and_sqlite_load.table(doc.matters, obj); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -1425,7 +1405,7 @@ template SQLiteInsertDocObjectsLoop() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -1438,23 +1418,23 @@ template SQLiteInsertDocObjectsLoop() { case "para": switch (obj.metainfo.is_a) { case "heading": - obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + obj_txt = format_and_sqlite_load.heading(doc.matters, obj); break; case "glossary": assert(part == "glossary", part); - obj_txt = format_and_sqlite_load.para(doc_matters, obj); + obj_txt = format_and_sqlite_load.para(doc.matters, obj); break; case "bibliography": assert(part == "bibliography", part); - obj_txt = format_and_sqlite_load.para(doc_matters, obj); + obj_txt = format_and_sqlite_load.para(doc.matters, obj); break; case "bookindex": assert(part == "bookindex", part); - obj_txt = format_and_sqlite_load.para(doc_matters, obj); + obj_txt = format_and_sqlite_load.para(doc.matters, obj); break; case "blurb": assert(part == "blurb", part); - obj_txt = format_and_sqlite_load.para(doc_matters, obj); + obj_txt = format_and_sqlite_load.para(doc.matters, obj); break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); } } @@ -1463,7 +1443,7 @@ template SQLiteInsertDocObjectsLoop() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); } } @@ -1474,7 +1454,7 @@ template SQLiteInsertDocObjectsLoop() { break; default: { /+ debug +/ - if (doc_matters.opt.action.debug_do_sqlite) { + if (doc.matters.opt.action.debug_do_sqlite) { writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from @@ -1483,9 +1463,9 @@ template SQLiteInsertDocObjectsLoop() { break; } if (obj.metainfo.is_a == "heading") { - if (doc_matters.opt.action.show_sqlite) { + if (doc.matters.opt.action.show_sqlite) { if (obj.metainfo.heading_lev_markup == 0) { - writeln(doc_matters.src.filename); + writeln(doc.matters.src.filename); } writeln( "markup: ", obj.metainfo.heading_lev_markup, @@ -1678,12 +1658,12 @@ template SQLiteTablesCreate() { ? config.conf.w_srv_db_sqlite_path : ""; if (db_filename.length > 0 && db_path.length > 0) { - if (opt_action.vox_gt2) { + if (opt_action.vox_gt_3) { writeln("db name: ", db_filename); writeln("db path: ", db_path); writeln("db name & path: ", db_path, "/", db_filename); } - if (opt_action.vox_gt1) { + if (opt_action.vox_gt_2) { writeln("attempting to create db: ", db_path, "/", db_filename); } auto pth_sqlite = spinePathsSQLite!()(db_filename, db_path); diff --git a/src/sisudoc/io_out/text.d b/src/sisudoc/io_out/text.d new file mode 100644 index 0000000..9401bae --- /dev/null +++ b/src/sisudoc/io_out/text.d @@ -0,0 +1,470 @@ +/+ +- Name: SisuDoc Spine, Doc Reform [a part of] + - Description: documents, structuring, processing, publishing, search + - static content generator + + - Author: Ralph Amissah + [ralph.amissah@gmail.com] + + - Copyright: (C) 2015 - 2025 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.text; +@safe: +template outputText() { + template munge() { + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import std.stdio; + import std.conv; + import std.conv : to; + import std.typecons : Nullable; + mixin spineRgxOut; + static auto rgx = RgxO(); + void puts(string _obj_is) { + writeln(__FILE__, ":", __LINE__, ": ", _obj_is); + } + string newline = "\n"; + string newlines = "\n\n"; + template special_characters_and_font_face() { + string code(string _txt){ + _txt = _txt.replaceAll(rgx.nbsp_char, " "); + return _txt; + } + string general(string _txt) { + _txt = _txt + .replaceAll(rgx.nbsp_char, " ") + .replaceAll(rgx.br_line, "\n") + .replaceAll(rgx.br_line_inline, "\n") + .replaceAll(rgx.br_line_spaced, "\n\n") + .replaceAll(rgx.inline_strike, "-{$1}-") + .replaceAll(rgx.inline_insert, "+{$1}+") + .replaceAll(rgx.inline_cite, "\"{$1}\"") + .replaceAll(rgx.inline_emphasis, "!{$1}!") + .replaceAll(rgx.inline_bold, "*{$1}*") + .replaceAll(rgx.inline_italics, "/{$1}/") + .replaceAll(rgx.inline_underscore, "_{$1}_") + .replaceAll(rgx.inline_superscript, "^{$1}^") + .replaceAll(rgx.inline_subscript, ",{$1},") + .replaceAll(rgx.inline_mono, "#{$1}#"); + return _txt; + } + string links_and_images(string _txt){ + if (_txt.match(rgx.inline_link)) { + foreach (m; _txt.matchAll(rgx.inline_link)) { + _txt = (m.captures[3] == "0") + ? _txt.replaceFirst(rgx.inline_link, (m.captures[1])) + : _txt.replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3])); + } + } + if (_txt.matchFirst(rgx.inline_image)) { + foreach (m; _txt.matchAll(rgx.inline_image)) { + _txt = _txt.replaceFirst(rgx.inline_image, (m.captures[3])); + } + } + return _txt; + } + } + string generalMunge(O,M)(O obj, M doc_matters) { + string _txt = obj.text; + string _notes; + string _ocn; + string general_munge; + _ocn = (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline; + if (_txt.matchFirst(rgx.inline_notes_al_gen)) { + foreach (m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { + _notes ~= newlines ~ m["num"] ~ ". " + ~ special_characters_and_font_face!().general(m["note"].replaceAll(rgx.inline_link, ("$1"))); + } + } + _txt = _txt.replaceAll(rgx.inline_notes_al_regular_number_note, "[$1]"); + _txt = (obj.metainfo.is_a == "code") + ? special_characters_and_font_face!().code(_txt) + : special_characters_and_font_face!().general(_txt); + _txt = special_characters_and_font_face!().links_and_images(_txt); + general_munge = (obj.metainfo.is_a == "heading") + ? newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline + : _txt ~ _notes ~ newline ~ _ocn ~ newline; + return general_munge; + } + string toc(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return "toc\n"; + // _txt = _special_characters_and_font_face(obj.text); + string _txt = special_characters_and_font_face!().general(obj.text); + string _spaces; + switch (obj.attrib.indent_hang) { + case 1: _spaces = ""; + break; + case 2: _spaces = ":"; + break; + case 3: _spaces = "∴"; + break; + case 4: _spaces = " "; + break; + case 5: _spaces = " "; + break; + case 6: _spaces = " "; + break; + case 7: _spaces = " "; + break; + case 8: _spaces = " "; + break; + default: + break; + } + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1")) + : _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3")); + return _txt ~ newline; + } + string heading(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string para(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string group(O,M)(O obj, M doc_matters) { + /+ + The "group" is different from the "block" mark in that "group" does not + preserve whitespace, the "block" mark does. The text falling within the + block is a single object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string block(O,M)(O obj, M doc_matters) { + /+ + The "block" is different from the "group" mark in that the "block" mark + (like the "poem" mark) preserves whitespace, the "group" mark does not. + The text falling within the "block" is a single object, which is different + from the "poem" mark where each identified verse is an object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string poem(O,M)(O obj, M doc_matters) { // LATER + /+ + The "poem" mark like the "block" preserves whitespace. Text followed by + two newlines are identified as verse and each verse is an object i.e. a + poem may consist of multiple verse each of which is identified as an + object, unlike a text "block" which is identified as a single object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + string verse(O,M)(O obj, M doc_matters) { + /+ + See description of poem, the poem is demarkated but the verse is the + object. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string code(O,M)(O obj, M doc_matters) { + /+ + "Code" blocks are a single text object, in which the original text is + preserved. + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string quote(O,M)(O obj, M doc_matters) { // LATER + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string table(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + auto tablarize(O)( + string _txt, + const O obj, + ) { + string[] _table_rows = (_txt).split(rgx.table_delimiter_row); + string[] _table_cols; + string _table = ""; + string _tablenote = ""; + int[] _col_width; + _col_width.length = obj.table.number_of_columns.to!ulong; + foreach(row_idx, row; _table_rows) { + _table_cols = row.split(rgx.table_delimiter_col); + _table ~= ""; + foreach(col_idx, cell; _table_cols) { + if (!((_table_cols.length == 1) + && (_table_rows.length <= row_idx+2))) { + if (_col_width[col_idx] < (cell.length.to!int)) { + _col_width[col_idx] = cell.length.to!int; + } + } + } + } + foreach(row_idx, row; _table_rows) { + _table_cols = row.split(rgx.table_delimiter_col); + foreach(col_idx, cell; _table_cols) { + if ((_table_cols.length == 1) + && (_table_rows.length <= row_idx+2)) { // check row_idx+2 (rather than == ++row_idx) + _tablenote ~= cell ~ newline; + } else { + if (obj.table.column_aligns[col_idx] == "l") { + _table ~= format(q"┃%-*s%s┃", + _col_width[col_idx], + cell, + (_table_cols.length > (col_idx + 1)) ? " ┊ " : "" + ); + } else { + _table ~= format(q"┃%*s%s┃", + _col_width[col_idx], + cell, + (_table_cols.length > (col_idx + 1)) ? " ┊ " : "" + ); + } + _table = _table + .replaceAll(regex("\\s*$"), ""); + } + } + _table ~= newline; + } + Tuple!(string, string) t = tuple( + _table, + _tablenote, + ); + return t; + } + // string _txt = obj.text; + // writeln(obj.table.column_widths); + auto _t = tablarize(obj.text, obj); + string _txt = _t[0]; + string _tablenote = _t[1]; + return _txt ~ _tablenote ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines; + } + string endnote(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _ocn; + _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」"; + string _txt = obj.text; + string _parent_ocn; + _txt = _txt + .replaceAll(rgx.inline_link, ("$1")) // consider + .replaceFirst(rgx.inline_superscript, ("$1")); + _parent_ocn = (obj.metainfo.parent_ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : " ≫" ~ obj.metainfo.parent_ocn.to!string; + _txt = special_characters_and_font_face!().general(_txt) ~ _parent_ocn; + return _txt ~ newlines; + } + string bookindex(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _txt = obj.text; + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.find_bookindex_ocn_link_and_comma, "") + .replaceAll(regex("\\s*\\\\"), "") + : _txt.replaceAll(rgx.inline_link, ("≫$1")) + .replaceAll(regex("\\s*\\\\"), ""); + _txt = special_characters_and_font_face!().general(_txt); + return _txt ~ newlines; + } + string bibliography(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _txt = obj.text; + _txt = special_characters_and_font_face!().general(_txt); + return _txt ~ newlines; + // ALT: + // string _general_munge = generalMunge(obj,doc_matters); + // return _general_munge; + } + string glossary(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _txt = obj.text; + _txt = special_characters_and_font_face!().general(_txt); + return _txt; + } + string blurb(O,M)(O obj, M doc_matters) { + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + string _general_munge = generalMunge(obj,doc_matters); + return _general_munge; + } + string comment(O,M)(O obj, M doc_matters) { // LATER + /+ + +/ + // puts(obj.metainfo.is_a); + // return obj.metainfo.is_a; + return obj.text ~ newlines; + } + } + template theDocument() { + import std.stdio; + import sisudoc.io_out; + string text_head(M)( + M doc_matters, + ) { + return "head"; + } + string text_body(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + string doc_object = ""; + foreach (section; doc_matters.has.keys_seq.scroll) { + foreach (obj; doc_abstraction[section]) { + if (obj.metainfo.is_a == "toc") { doc_object ~= munge!().toc(obj, doc_matters); } + if (obj.metainfo.is_a == "heading") { doc_object ~= munge!().heading(obj, doc_matters); } + if (obj.metainfo.is_a == "para") { doc_object ~= munge!().para(obj, doc_matters); } + if (obj.metainfo.is_a == "group") { doc_object ~= munge!().group(obj, doc_matters); } + if (obj.metainfo.is_a == "block") { doc_object ~= munge!().block(obj, doc_matters); } + if (obj.metainfo.is_a == "poem") { doc_object ~= munge!().poem(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "verse") { doc_object ~= munge!().verse(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "code") { doc_object ~= munge!().code(obj, doc_matters); } + if (obj.metainfo.is_a == "quote") { doc_object ~= munge!().quote(obj, doc_matters); } // LATER + if (obj.metainfo.is_a == "table") { doc_object ~= munge!().table(obj, doc_matters); } + if (obj.metainfo.is_a == "endnote") { doc_object ~= munge!().endnote(obj, doc_matters); } + if (obj.metainfo.is_a == "bookindex") { doc_object ~= munge!().bookindex(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "bibliography") { doc_object ~= munge!().bibliography(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "glossary") { doc_object ~= munge!().glossary(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "blurb") { doc_object ~= munge!().blurb(obj, doc_matters); } // CHECK + if (obj.metainfo.is_a == "comment") { doc_object ~= munge!().comment(obj, doc_matters); } // LATER + } + } + return doc_object; + } + string text_tail(M)( + M doc_matters, + ) { + string metadata_; + if (doc_matters.opt.action.debug_do) { + writeln(doc_matters.src.filename_base); + writeln("Title: ", doc_matters.conf_make_meta.meta.title_full); + writeln(" Author: ", doc_matters.conf_make_meta.meta.creator_author); + writeln(" Published: ", doc_matters.conf_make_meta.meta.date_published); + writeln(" Copyright: ", doc_matters.conf_make_meta.meta.rights_copyright); + writeln(" License: ", doc_matters.conf_make_meta.meta.rights_license); + } + if (!(doc_matters.conf_make_meta.meta.title_full.empty)) { + metadata_ ~= "Title: " ~ doc_matters.conf_make_meta.meta.title_full ~ "\n\n"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { + writeln("ERROR no Title information provided in document header ", doc_matters.src.filename_base); + } + if (!(doc_matters.conf_make_meta.meta.creator_author.empty)) { + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= "Author: " ~ doc_matters.conf_make_meta.meta.creator_author_surname.translate([' ' : "_"]) + ~ doc_matters.conf_make_meta.meta.creator_author ~ "\n\n"; + } else { + metadata_ ~= "Author: " + ~ doc_matters.conf_make_meta.meta.creator_author ~ "\n\n"; + } + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { + writeln("ERROR no Author information provided in document header ", doc_matters.src.filename_base); + } + metadata_ ~= "Published: " ~ doc_matters.conf_make_meta.meta.date_published ~ "\n\n"; + if (!(doc_matters.conf_make_meta.meta.rights_copyright.empty)) { + metadata_ ~= "Copyright: " ~ doc_matters.conf_make_meta.meta.rights_copyright ~ "\n\n"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { + writeln("WARNING no Copyright information provided in document header ", doc_matters.src.filename_base); + } + if (!(doc_matters.conf_make_meta.meta.rights_license.empty)) { + metadata_ ~= "License: " ~ doc_matters.conf_make_meta.meta.rights_license ~ "\n\n"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt_3) { + writeln("WARNING no License information provided in document header ", doc_matters.src.filename_base); + } + metadata_ ~= doc_matters.generator_program.project_name.strip ~ "\n"; + metadata_ ~= doc_matters.generator_program.url_home.strip; + return metadata_; + } + } + void outputText(D,M) ( + const D doc_abstraction, + M doc_matters, + ) { + import std.stdio; + import sisudoc.io_out; + void text_out(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + struct Text { + string head; + string content; + string tail; + } + auto text = Text(); + // text.head = theDocument!().text_head(doc_matters); + text.content = theDocument!().text_body(doc_abstraction, doc_matters); + text.tail = theDocument!().text_tail(doc_matters); + auto pth_text = spinePathsText(doc_matters); + try { + import std.file; + if (!exists(pth_text.base_pth)) { + (pth_text.base_pth).mkdirRecurse; + } + } catch (ErrnoException ex) { + } + if (doc_matters.opt.action.vox_gt_1) { + writeln(" ", pth_text.text_file); + } + // writeln(pth_text.base_pth); + auto f = File(pth_text.text_file, "w"); + // f.writeln(text.head); + f.writeln(text.content); + f.writeln(text.tail); + } + text_out(doc_abstraction, doc_matters); + } +} diff --git a/src/sisudoc/io_out/xmls.d b/src/sisudoc/io_out/xmls.d index 7fc5e51..bf52524 100644 --- a/src/sisudoc/io_out/xmls.d +++ b/src/sisudoc/io_out/xmls.d @@ -50,19 +50,17 @@ module sisudoc.io_out.xmls; @safe: template outputXHTMLs() { - import - std.file, - std.outbuffer, - std.uri, - std.conv : to; - import - sisudoc.io_out, - sisudoc.io_out.rgx, - sisudoc.meta.rgx_files, - sisudoc.io_out.rgx_xhtml, - sisudoc.io_out.create_zip_file, - sisudoc.io_out.xmls, - sisudoc.io_out.xmls_css; + import std.file; + import std.outbuffer; + import std.uri; + import std.conv : to; + import sisudoc.io_out; + import sisudoc.io_out.rgx; + import sisudoc.meta.rgx_files; + import sisudoc.io_out.rgx_xhtml; + import sisudoc.io_out.create_zip_file; + import sisudoc.io_out.xmls; + import sisudoc.io_out.xmls_css; mixin spineRgxOut; mixin spineRgxXHTML; struct outputXHTMLs { @@ -577,7 +575,7 @@ string tail(M)(M doc_matters) { ); } } else { - if (doc_matters.opt.action.vox_gt0) { + if (doc_matters.opt.action.vox_gt_1) { writeln( "WARNING on internal document links, anchor to link <<" ~ m.captures["hash"] diff --git a/src/sisudoc/meta/conf_make_meta_json.d b/src/sisudoc/meta/conf_make_meta_json.d index 44f2c5e..4e9e5cd 100644 --- a/src/sisudoc/meta/conf_make_meta_json.d +++ b/src/sisudoc/meta/conf_make_meta_json.d @@ -54,21 +54,19 @@ module sisudoc.meta.conf_make_meta_json; @safe: static template contentJSONtoSpineStruct() { - import - std.algorithm, - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.utf, - std.conv : to; - import - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.conf_make_meta_json, - sisudoc.meta.defaults, - sisudoc.meta.rgx; + import std.algorithm; + import std.array; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.utf; + import std.conv : to; + import sisudoc.meta.conf_make_meta_structs; + import sisudoc.meta.conf_make_meta_json; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; ConfComposite _struct_composite; auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) { mixin spineRgxIn; diff --git a/src/sisudoc/meta/conf_make_meta_structs.d b/src/sisudoc/meta/conf_make_meta_structs.d index 4738a57..9503c83 100644 --- a/src/sisudoc/meta/conf_make_meta_structs.d +++ b/src/sisudoc/meta/conf_make_meta_structs.d @@ -49,20 +49,18 @@ +/ module sisudoc.meta.conf_make_meta_structs; @safe: -import - std.exception, - std.json, - std.path, - std.regex, - std.stdio, - std.string, - std.typecons, - std.utf, - std.conv : to; -import - sisudoc.meta.defaults, - sisudoc.meta.rgx_yaml, - sisudoc.meta.rgx; +import std.exception; +import std.json; +import std.path; +import std.regex; +import std.stdio; +import std.string; +import std.typecons; +import std.utf; +import std.conv : to; +import sisudoc.meta.defaults; +import sisudoc.meta.rgx_yaml; +import sisudoc.meta.rgx; mixin spineRgxIn; static auto rgx = RgxI(); mixin spineRgxYamlTags; diff --git a/src/sisudoc/meta/conf_make_meta_yaml.d b/src/sisudoc/meta/conf_make_meta_yaml.d index 98a92f9..4b56b51 100644 --- a/src/sisudoc/meta/conf_make_meta_yaml.d +++ b/src/sisudoc/meta/conf_make_meta_yaml.d @@ -54,22 +54,20 @@ module sisudoc.meta.conf_make_meta_yaml; @safe: template contentYAMLtoSpineStruct() { - import - std.algorithm, - std.array, - std.exception, - std.path, - std.regex, - std.stdio, - std.string, - std.typecons, - std.utf, - std.conv : to; - import - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.defaults, - sisudoc.meta.rgx_yaml, - sisudoc.meta.rgx; + import std.algorithm; + import std.array; + import std.exception; + import std.path; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.utf; + import std.conv : to; + import sisudoc.meta.conf_make_meta_structs; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx_yaml; + import sisudoc.meta.rgx; ConfComposite _struct_composite; @system ConfComposite contentYAMLtoSpineStruct(C,Y,M,O,Cfg)( C _struct_composite, @@ -896,9 +894,8 @@ template contentYAMLtoSpineStruct() { } template configParseYAMLreturnSpineStruct() { import dyaml; - import - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.conf_make_meta_json; + import sisudoc.meta.conf_make_meta_structs; + import sisudoc.meta.conf_make_meta_json; mixin contentYAMLtoSpineStruct; @system ConfComposite configParseYAMLreturnSpineStruct(T,M,O,Cfg)( T _document_struct, @@ -928,21 +925,18 @@ template configParseYAMLreturnSpineStruct() { } } template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { - import - std.exception, - std.regex, - std.stdio, - // std.traits, - std.typecons, - std.utf, - std.conv : to; - import - dyaml; - import - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.conf_make_meta_json, - sisudoc.meta.rgx_yaml, - sisudoc.meta.rgx; + import std.exception; + import std.regex; + import std.stdio; + // import std.traits; + import std.typecons; + import std.utf; + import std.conv : to; + import dyaml; + import sisudoc.meta.conf_make_meta_structs; + import sisudoc.meta.conf_make_meta_json; + import sisudoc.meta.rgx_yaml; + import sisudoc.meta.rgx; mixin spineRgxIn; mixin contentJSONtoSpineStruct; static auto rgx = RgxI(); diff --git a/src/sisudoc/meta/doc_debugs.d b/src/sisudoc/meta/doc_debugs.d index 35fd3de..b28ba2e 100644 --- a/src/sisudoc/meta/doc_debugs.d +++ b/src/sisudoc/meta/doc_debugs.d @@ -52,24 +52,22 @@ +/ module sisudoc.meta.doc_debugs; template spineDebugs() { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx_files; - import - std.algorithm, - std.array, - std.container, - std.exception, - std.json, - std.stdio, - std.file, - std.path, - std.range, - std.regex, - std.string, - std.typecons, - std.utf, - std.conv : to; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx_files; + import std.algorithm; + import std.array; + import std.container; + import std.exception; + import std.json; + import std.stdio; + import std.file; + import std.path; + import std.range; + import std.regex; + import std.string; + import std.typecons; + import std.utf; + import std.conv : to; auto spineDebugs(S,T)( const S contents, T doc_matters, diff --git a/src/sisudoc/meta/metadoc.d b/src/sisudoc/meta/metadoc.d index 0d58c2e..ffe297e 100644 --- a/src/sisudoc/meta/metadoc.d +++ b/src/sisudoc/meta/metadoc.d @@ -50,20 +50,18 @@ module sisudoc.meta.metadoc; @safe: template spineAbstraction() { - import - std.datetime, - std.digest.crc, - std.digest.sha; - import - sisudoc.meta, - sisudoc.meta.metadoc_from_src, - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.conf_make_meta_json, - sisudoc.meta.defaults, - sisudoc.io_in.paths_source, - sisudoc.io_in.read_config_files, - sisudoc.io_in.read_source_files, - sisudoc.io_out.hub; + import std.datetime; + import std.digest.crc; + import std.digest.sha; + import sisudoc.meta; + import sisudoc.meta.metadoc_from_src; + import sisudoc.meta.conf_make_meta_structs; + import sisudoc.meta.conf_make_meta_json; + import sisudoc.meta.defaults; + import sisudoc.io_in.paths_source; + import sisudoc.io_in.read_config_files; + import sisudoc.io_in.read_source_files; + import sisudoc.io_out.hub; mixin spineBiblio; mixin outputHub; enum makeMeta { make, meta } @@ -144,7 +142,7 @@ template spineAbstraction() { if ((_opt_action.debug_do) || (_opt_action.debug_do_stages) ) { - writeln("step4 commence → (doc_matters) [", _manifest.src.filename, "]"); + writeln("step4 commence → (doc.matters) [", _manifest.src.filename, "]"); } struct ST_DocumentMatters { auto generator_program() { @@ -294,7 +292,18 @@ template spineAbstraction() { ) { writeln("- step4 complete for [", _manifest.src.filename, "]"); } - auto t = tuple(doc_abstraction, doc_matters); - return t; + auto theDOC() { + struct ST_DOC { + const auto abstraction() { + return doc_abstraction; + } + auto matters() { + return doc_matters; + } + } + return ST_DOC(); + } + auto the_doc = theDOC(); + return the_doc; } } diff --git a/src/sisudoc/meta/metadoc_curate.d b/src/sisudoc/meta/metadoc_curate.d index bb7452a..da20b3e 100644 --- a/src/sisudoc/meta/metadoc_curate.d +++ b/src/sisudoc/meta/metadoc_curate.d @@ -54,19 +54,17 @@ template spineMetaDocCurate() { T doc_matters, H hvst, ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; static auto mkup = InlineMarkup(); import sisudoc.io_out.paths_output; diff --git a/src/sisudoc/meta/metadoc_curate_authors.d b/src/sisudoc/meta/metadoc_curate_authors.d index c86d3e1..d8b5261 100644 --- a/src/sisudoc/meta/metadoc_curate_authors.d +++ b/src/sisudoc/meta/metadoc_curate_authors.d @@ -49,17 +49,15 @@ +/ module sisudoc.meta.metadoc_curate_authors; @safe: - import - std.algorithm, - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.conv : to; - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; + import std.algorithm; + import std.array; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.conv : to; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; mixin spineCurateMetadata; mixin InternalMarkup; template spineMetaDocCuratesAuthors() { diff --git a/src/sisudoc/meta/metadoc_curate_topics.d b/src/sisudoc/meta/metadoc_curate_topics.d index fca3ff2..3045dcb 100644 --- a/src/sisudoc/meta/metadoc_curate_topics.d +++ b/src/sisudoc/meta/metadoc_curate_topics.d @@ -49,17 +49,15 @@ +/ module sisudoc.meta.metadoc_curate_topics; @safe: - import - std.algorithm, - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.conv : to; - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; + import std.algorithm; + import std.array; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.conv : to; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; mixin spineCurateMetadata; mixin InternalMarkup; template spineMetaDocCuratesTopics() { diff --git a/src/sisudoc/meta/metadoc_from_src.d b/src/sisudoc/meta/metadoc_from_src.d index 012dd36..4240a3f 100644 --- a/src/sisudoc/meta/metadoc_from_src.d +++ b/src/sisudoc/meta/metadoc_from_src.d @@ -54,19 +54,17 @@ module sisudoc.meta.metadoc_from_src; @safe: template docAbstraction() { // ↓ abstraction imports - import - std.algorithm, - std.container, - std.digest.sha, - std.file, - std.json, - std.path; - import - sisudoc.meta, - sisudoc.meta.defaults, - sisudoc.meta.rgx, - sisudoc.meta.metadoc_object_setter, - sisudoc.meta.rgx; + import std.algorithm; + import std.container; + import std.digest.sha; + import std.file; + import std.json; + import std.path; + import sisudoc.meta; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import sisudoc.meta.metadoc_object_setter; + import sisudoc.meta.rgx; public import sisudoc.meta.metadoc_from_src_functions; mixin docAbstractionFunctions; @system auto docAbstraction(CMM,Opt,Mf) ( @@ -99,8 +97,8 @@ template docAbstraction() { anchor_tag = ""; } mixin spineNode; - auto node_para_int_ = node_metadata_para_int; - auto node_para_str_ = node_metadata_para_str; + int[string] node_para_int_ = node_metadata_para_int; + string[string] node_para_str_ = node_metadata_para_str; ObjGenericComposite comp_obj_; line_occur = [ "heading" : 0, @@ -214,8 +212,8 @@ template docAbstraction() { } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { - writeln("regex to match: ", substitution_pair[Substitute.match]); - writeln("substitution to make: ", substitution_pair[Substitute.markup]); + writeln("regex to match: ", substitution_pair[Substitute.match]); + writeln("substitution to make: ", substitution_pair[Substitute.markup]); } } if (conf_make_meta.make.bold) { @@ -231,7 +229,7 @@ template docAbstraction() { writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]); } } - auto loopMarkupSrcByLine( + _loopMarkupSrcByLineStruct loopMarkupSrcByLine( char[][] markup_sourcefile_content, string[string] an_object, uint[string] pith, @@ -340,7 +338,7 @@ template docAbstraction() { ._doc_header_and_make_substitutions_(conf_make_meta) ._doc_header_and_make_substitutions_fontface_(conf_make_meta); { - auto _get = line.txt_by_line_block_quote(an_object, pith); + ST_txt_by_line_block_generic _get = line.txt_by_line_block_quote(an_object, pith); { an_object = _get.this_object; pith = _get.pith; @@ -353,7 +351,7 @@ template docAbstraction() { ._doc_header_and_make_substitutions_fontface_(conf_make_meta) .replaceAll(rgx.para_delimiter, mkup.br_line_spaced ~ "$1"); { - auto _get = line.txt_by_line_block_group(an_object, pith); + ST_txt_by_line_block_generic _get = line.txt_by_line_block_group(an_object, pith); { an_object = _get.this_object; pith = _get.pith; @@ -369,7 +367,7 @@ template docAbstraction() { .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); } { - auto _get = line.txt_by_line_block_block(an_object, pith); + ST_txt_by_line_block_generic _get = line.txt_by_line_block_block(an_object, pith); { an_object = _get.this_object; pith = _get.pith; @@ -378,7 +376,7 @@ template docAbstraction() { continue; } else if (pith["block_is"] == eN.blk_is.poem) { { - auto _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); + ST_txt_by_line_block_poem _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); { an_object = _get.this_object; pith = _get.pith; @@ -412,7 +410,7 @@ template docAbstraction() { object_number_poem["start"] = obj_cite_digits.object_number.to!string; } { - auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem); + ST_txt_by_line_block_start _get = line.txt_by_line_block_start(pith, dochas, object_number_poem); { pith = _get.pith; dochas = _get.dochas; @@ -442,7 +440,7 @@ template docAbstraction() { || line.matchFirst(rgx.book_index_item_open) || pith["section"] == eN.sect.book_index) { { // book_index - auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action); + ST_flow_book_index _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action); { an_object = _get.this_object; pith = _get.pith; @@ -464,7 +462,7 @@ template docAbstraction() { comp_obj_comment.text = an_object[an_object_key].strip; the_document_body_section ~= comp_obj_comment; { - auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith); { line_occur = _get.line_occur; an_object = _get.this_object; @@ -481,7 +479,7 @@ template docAbstraction() { && (pith["make_headings"] == eN.bi.off)) { // heading found { - auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); + ST_flow_heading_found _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); { heading_match_str = _get.heading_match_str; heading_match_rgx = _get.heading_match_rgx; @@ -496,7 +494,7 @@ template docAbstraction() { ) { // heading make set { - auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); + ST_flow_heading_make_set _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); { line = _get.line; an_object = _get.this_object; @@ -534,7 +532,7 @@ template docAbstraction() { ._doc_header_and_make_substitutions_(conf_make_meta) ._doc_header_and_make_substitutions_fontface_(conf_make_meta); { - auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); { an_object = _get.this_object; an_object_key = _get.this_object_key; @@ -563,7 +561,7 @@ template docAbstraction() { } else if (pith["block_state"] == eN.blk_state.closing) { // line empty, with blocks flag { - auto _get = line.flow_block_flag_line_empty_( + ST_flow_block_flag_line_empty _get = line.flow_block_flag_line_empty_( an_object, bookindex_extract_hash, the_document_body_section, @@ -679,7 +677,7 @@ template docAbstraction() { _anchor_tag = obj_cite_digits.identifier; // (incrementally build toc) table of contents here! { - auto _get = obj_im.flow_table_of_contents_gather_headings( + ST_flow_table_of_contents_gather_headings _get = obj_im.flow_table_of_contents_gather_headings( an_object, conf_make_meta, tag_in_seg, @@ -700,7 +698,7 @@ template docAbstraction() { if (an_object["lev_markup_number"].to!int <= 4) { segnames["epub"] ~= tag_in_seg["seg_lv1to4"]; } - auto comp_obj_ = node_construct.node_emitter_heading( + ObjGenericComposite comp_obj_ = node_construct.node_emitter_heading( an_object, tag_in_seg, lev_anchor_tag, @@ -721,7 +719,7 @@ template docAbstraction() { the_document_body_section ~= comp_obj_; debug(objectrelated1) { writeln(line); } // check { - auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith); { line_occur = _get.line_occur; an_object = _get.this_object; @@ -742,7 +740,7 @@ template docAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); an_object["is"] = "para"; - auto comp_obj_ = node_construct.node_location_emitter( + ObjGenericComposite comp_obj_ = node_construct.node_location_emitter( content_non_header, tag_in_seg, lev_anchor_tag, @@ -772,9 +770,9 @@ template docAbstraction() { comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; comp_obj_.has.image_without_dimensions = substantive_obj_misc_struct.has_images_without_dimensions; the_document_body_section ~= comp_obj_; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); { - auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith); { line_occur = _get.line_occur; an_object = _get.this_object; @@ -848,7 +846,7 @@ template docAbstraction() { return ret; } { // loopMarkupSrcByLine - auto _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith); + _loopMarkupSrcByLineStruct _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith); the_document_toc_section = _doc_by_line.toc; the_document_body_section = _doc_by_line.body; the_document_glossary_section = _doc_by_line.glossary; @@ -941,7 +939,7 @@ template docAbstraction() { } { // document segnames ST_segnames get_segnames; - get_segnames = the_document_body_section.after_doc_determine_segnames(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section, segnames, html_segnames_ptr_cntr, html_segnames_ptr); // + get_segnames = the_document_body_section.after_doc_determine_segnames(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section, segnames, html_segnames_ptr_cntr, html_segnames_ptr); segnames = get_segnames.segnames; html_segnames_ptr_cntr = get_segnames.html_segnames_ptr_cntr; html_segnames_ptr = get_segnames.html_segnames_ptr; @@ -1378,36 +1376,42 @@ template docAbstraction() { "scroll": ["head", "toc", "body",], "seg": ["head", "toc", "body",], "sql": ["head", "body",], - "latex": ["head", "toc", "body",] + "latex": ["head", "toc", "body",], + "text": ["head", "toc", "body",], ]; if (document_the["endnotes"].length > 1) { document_section_keys_sequenced["scroll"] ~= "endnotes"; document_section_keys_sequenced["seg"] ~= "endnotes"; document_section_keys_sequenced["latex"] ~= "endnotes"; + document_section_keys_sequenced["text"] ~= "endnotes"; } if (document_the["glossary"].length > 1) { document_section_keys_sequenced["scroll"] ~= "glossary"; document_section_keys_sequenced["seg"] ~= "glossary"; document_section_keys_sequenced["sql"] ~= "glossary"; document_section_keys_sequenced["latex"] ~= "glossary"; + document_section_keys_sequenced["text"] ~= "glossary"; } if (document_the["bibliography"].length > 1) { document_section_keys_sequenced["scroll"] ~= "bibliography"; document_section_keys_sequenced["seg"] ~= "bibliography"; document_section_keys_sequenced["sql"] ~= "bibliography"; document_section_keys_sequenced["latex"] ~= "bibliography"; + document_section_keys_sequenced["text"] ~= "bibliography"; } if (document_the["bookindex"].length > 1) { document_section_keys_sequenced["scroll"] ~= "bookindex"; document_section_keys_sequenced["seg"] ~= "bookindex"; document_section_keys_sequenced["sql"] ~= "bookindex"; document_section_keys_sequenced["latex"] ~= "bookindex"; + document_section_keys_sequenced["text"] ~= "bookindex"; } if (document_the["blurb"].length > 1) { document_section_keys_sequenced["scroll"] ~= "blurb"; document_section_keys_sequenced["seg"] ~= "blurb"; document_section_keys_sequenced["sql"] ~= "blurb"; document_section_keys_sequenced["latex"] ~= "blurb"; + document_section_keys_sequenced["text"] ~= "blurb"; } if ((opt_action.html) || (opt_action.html_scroll) @@ -1496,7 +1500,7 @@ template docAbstraction() { return tag_assoc; } } - auto doc_has() { + DocHas_ doc_has() { return DocHas_(); } // the doc to be returned diff --git a/src/sisudoc/meta/metadoc_from_src_functions.d b/src/sisudoc/meta/metadoc_from_src_functions.d index 8ccf21b..63143e9 100644 --- a/src/sisudoc/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/meta/metadoc_from_src_functions.d @@ -453,6 +453,62 @@ template docAbstractionFunctions() { pith["block_is"] = eN.blk_is.table; pith["block_state"] = eN.blk_state.on; pith["block_delim"] = eN.blk_delim.curly_special; + } else if (auto m = line.matchFirst(rgx.block_quotemarks_code_open)) { + dochas["codeblock"]++; + an_object["lang"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; + debug(codequotemarks) { writefln( "* [code quotemarks] %s", line); } + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; // + } else if (auto m = line.matchFirst(rgx.block_quotemarks_poem_open)) { + dochas["poem"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(poem) { writefln( "* [poem quotemarks] %s", line); } + object_number_poem["start"] = obj_cite_digits.object_number.to!string; + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; // + pith["verse_new"] = eN.bi.on; + } else if (auto m = line.matchFirst(rgx.block_quotemarks_group_open)) { + dochas["group"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(group) { writefln( "* [group quotemarks] %s", line); } + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; + } else if (auto m = line.matchFirst(rgx.block_quotemarks_block_open)) { + dochas["block"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(block) { writefln( "* [block quotemarks] %s", line); } + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; + } else if (auto m = line.matchFirst(rgx.block_quotemarks_quote_open)) { + dochas["quote"]++; + an_object["syntax"] = ""; + an_object["attrib"] = m["attrib"].to!string; + an_object["lang"] = m["lang"].to!string; + debug(quote) { writefln( "* [quote quotemarks] %s", line); // quote (quotemarks) open + } + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; + } else if (auto m = line.matchFirst(rgx.block_quotemarks_table_open)) { // quotemarks table open + debug(table) { writefln( "* [table quotemarks] %s", line); } + dochas["table"] ++; + an_object["table_head"] = m["attrib"].to!string; + an_object["block_type"] = "quotemarks"; + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.quotemarks; } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { dochas["codeblock"]++; an_object["lang"] = ""; @@ -536,6 +592,17 @@ template docAbstractionFunctions() { debug(group) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + debug(group) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(group) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (line.matchFirst(rgx.block_tic_close)) { debug(group) { writeln(line); } @@ -574,6 +641,17 @@ template docAbstractionFunctions() { debug(block) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + debug(block) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(block) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (line.matchFirst(rgx.block_tic_close)) { debug(block) { writeln(line); } @@ -698,6 +776,94 @@ template docAbstractionFunctions() { ++cntr; } } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (auto m = line.matchFirst(rgx.block_quotemarks_close)) { + an_object[an_object_key] = "verse"; + debug(poem) { writefln( "* [poem quotemarks] %s", line); } + if (processing.length > 0) { + an_object[an_object_key] = processing["verse"]; + } + if (an_object.length > 0) { + debug(poem) { writeln(__LINE__); writeln(obj_cite_digits.object_number, line); } + processing.remove("verse"); + an_object["is"] = "verse"; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + object_number_poem["end"] = obj_cite_digits.object_number.to!string; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + processing["verse"] ~= line ~= "\n"; + if (pith["verse_new"] == eN.bi.on) { + obj_cite_digits = ocn_emit(pith["ocn"]); + pith["verse_new"] = eN.bi.off; + } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { + processing["verse"] = processing["verse"].stripRight; + pith["verse_new"] = eN.bi.on; + verse_line = eN.bi.off; + } + if (pith["verse_new"] == eN.bi.on) { + verse_line = 1; + an_object[an_object_key] = processing["verse"]; + debug(poem) { writefln( + "* %s tic\n%s", + obj_cite_digits.object_number, + an_object[an_object_key] + ); + } + processing.remove("verse"); + an_object["is"] = "verse"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (auto m = line.matchFirst(rgx.block_tic_close)) { an_object[an_object_key] = "verse"; @@ -816,6 +982,19 @@ template docAbstractionFunctions() { debug(codecurly) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + debug(codequotemarks) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.newline_eol_delimiter_only, "") + .stripRight; + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(codequotemarks) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (line.matchFirst(rgx.block_tic_close)) { debug(codetic) { writeln(line); } @@ -884,6 +1063,16 @@ template docAbstractionFunctions() { debug(table) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + debug(table) { writeln(line); } + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(table) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (line.matchFirst(rgx.block_tic_close)) { debug(table) { writeln(line); } @@ -927,6 +1116,17 @@ template docAbstractionFunctions() { debug(quote) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; } + } else if (pith["block_delim"] == eN.blk_delim.quotemarks) { + if (line.matchFirst(rgx.block_quotemarks_close)) { + debug(quote) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(quote) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (pith["block_delim"] == eN.blk_delim.tic) { if (line.matchFirst(rgx.block_tic_close)) { debug(quote) { writeln(line); } @@ -2357,10 +2557,8 @@ template docAbstractionFunctions() { CMM conf_make_meta, Flag!"_new_doc" _new_doc ) { - obj_txt["munge"] = obj_[obj_key_].dup; - obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) - ? obj_txt["munge"] - : obj_txt["munge"].strip; + obj_txt["munge"] = obj_[obj_key_].dup; + obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) ? obj_txt["munge"] : obj_txt["munge"].strip; if (_new_doc) { anchor_tag = ""; } @@ -2379,8 +2577,8 @@ template docAbstractionFunctions() { || (obj_["is"] == "group") || (obj_["is"] == "block") || (obj_["is"] == "verse")) { - obj_txt["munge"] = (obj_txt["munge"]).inline_markup_faces; - obj_txt["munge"] = (obj_txt["munge"]).links_and_images; + obj_txt["munge"] = (obj_txt["munge"]).inline_markup_faces; + obj_txt["munge"] = (obj_txt["munge"]).links_and_images; } switch (obj_["is"]) { case "heading": @@ -3099,8 +3297,8 @@ template docAbstractionFunctions() { // ↓ - endnotes struct NotesSection { string[string] object_notes; - int previous_count; - int mkn; + int previous_count; + int mkn; static auto rgx = RgxI(); private auto gather_notes_for_endnote_section( ObjGenericComposite[] contents_am, @@ -3631,7 +3829,7 @@ template docAbstractionFunctions() { } } else { // para { - auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); { an_object = _get.this_object; an_object_key = _get.this_object_key; @@ -3924,7 +4122,7 @@ template docAbstractionFunctions() { tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; } else if (!(line.empty)) { { - auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); { an_object = _get.this_object; an_object_key = _get.this_object_key; @@ -4035,11 +4233,31 @@ template docAbstractionFunctions() { int html_segnames_ptr_cntr, int html_segnames_ptr, ) { + string[string][string] notes_; + if (the_document_body_section.length > 1) { + string _notes; + foreach (ref obj; the_document_body_section) { + if (obj.has.inline_notes_reg) { + if ((obj.text).matchFirst(rgx.inline_notes_al_gen)) { + foreach (m; (obj.text).matchAll(rgx.inline_notes_al_regular_number_note)) { + _notes ~= "\n\n" ~ m["num"] ~ ". " ~ m["note"]; + notes_[(m["num"])]["ocn"] = obj.metainfo.ocn.to!string; + } + } + } + } + } if (the_document_endnotes_section.length > 1) { segnames["html"] ~= "endnotes"; segnames["epub"] ~= "endnotes"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_document_endnotes_section) { + auto matches = (obj.text).matchAll(rgx.endnote_section_note); + foreach (m; matches) { + obj.metainfo.parent_ocn = notes_[(m["notenumber"])]["ocn"].to!int; + } + } + foreach (ref obj; the_document_endnotes_section) { if (obj.metainfo.is_a == "heading") { obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; } @@ -5206,6 +5424,9 @@ template docSectKeysSeq() { string[] latex() { return document_section_keys_sequenced["latex"]; } + string[] text() { + return document_section_keys_sequenced["text"]; + } } return doc_sect_keys_seq(); } diff --git a/src/sisudoc/meta/metadoc_object_setter.d b/src/sisudoc/meta/metadoc_object_setter.d index 89ef856..abcb799 100644 --- a/src/sisudoc/meta/metadoc_object_setter.d +++ b/src/sisudoc/meta/metadoc_object_setter.d @@ -57,68 +57,68 @@ module sisudoc.meta.metadoc_object_setter; template ObjectSetter() { /+ structs +/ struct DocObj_TxtAttrib_ { - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; } struct DocObj_Has_ { - bool inline_links = false; - bool inline_notes_reg = false; - bool inline_notes_star = false; - bool images = false; - bool image_without_dimensions = false; + bool inline_links = false; + bool inline_notes_reg = false; + bool inline_notes_star = false; + bool images = false; + bool image_without_dimensions = false; } struct DocObj_Table_ { - int number_of_columns = 0; - double[] column_widths = []; - string[] column_aligns = []; - bool heading = false; - bool walls = false; + int number_of_columns = 0; + double[] column_widths = []; + string[] column_aligns = []; + bool heading = false; + bool walls = false; } struct DocObj_CodeBlock_ { - string syntax = ""; - bool linenumbers = false; + string syntax = ""; + bool linenumbers = false; } struct DocObj_Stow_ { - string[] link = []; + string[] link = []; } struct DocObj_Pointer_ { - int doc_object = 0; - int html_segnames = 0; - int heading = 0; + int doc_object = 0; + int html_segnames = 0; + int heading = 0; } struct DocObj_Tags_ { - string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; - string anchor_tag_html = ""; - string in_segment_html = ""; - string segment_anchor_tag_epub = ""; - string html_segment_anchor_tag_is = ""; - string epub_segment_anchor_tag_is = ""; - string heading_lev_anchor_tag = ""; - string segname_prev = ""; - string segname_next = ""; - string[] lev4_subtoc = []; - string[] anchor_tags = []; + string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; + string anchor_tag_html = ""; + string in_segment_html = ""; + string segment_anchor_tag_epub = ""; + string html_segment_anchor_tag_is = ""; + string epub_segment_anchor_tag_is = ""; + string heading_lev_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; + string[] lev4_subtoc = []; + string[] anchor_tags = []; } struct DocObj_MetaInfo_ { - string is_of_part = ""; // frontmatter, body, backmatter - string is_of_section = ""; // toc, body, glossary, biography, book index, blurb - string is_of_type = ""; // para, block ? - string is_a = ""; // heading, para, table, code block, group, verse/poem ... - alias of_part = is_of_part; - alias of_section = is_of_section; - alias is_of = is_of_type; - string attrib = ""; - string lang = ""; // blocks: group, block, quote; not codeblock; - string syntax = ""; // codeblock only + string is_of_part = ""; // frontmatter, body, backmatter + string is_of_section = ""; // toc, body, glossary, biography, book index, blurb + string is_of_type = ""; // para, block ? + string is_a = ""; // heading, para, table, code block, group, verse/poem ... + alias of_part = is_of_part; + alias of_section = is_of_section; + alias is_of = is_of_type; + string attrib = ""; + string lang = ""; // blocks: group, block, quote; not codeblock; + string syntax = ""; // codeblock only /+ o_n +/ - int o_n_substantive = 0; - int o_n_non_substantive = 0; - int o_n_glossary = 0; - int o_n_bibliography = 0; - int o_n_book_index = 0; - int o_n_blurb = 0; + int o_n_substantive = 0; + int o_n_non_substantive = 0; + int o_n_glossary = 0; + int o_n_bibliography = 0; + int o_n_book_index = 0; + int o_n_blurb = 0; string object_number_substantive() const @property { return (o_n_substantive == 0) ? "" : o_n_substantive.to!string; } @@ -176,7 +176,7 @@ template ObjectSetter() { ubyte[32] sha256; } struct ObjGenericComposite { - string text = ""; + string text = ""; DocObj_MetaInfo_ metainfo; DocObj_TxtAttrib_ attrib; DocObj_Tags_ tags; @@ -420,6 +420,7 @@ template ObjectSetter() { tic, curly_special, tic_special, + quotemarks, } } return _e(); diff --git a/src/sisudoc/meta/metadoc_show_config.d b/src/sisudoc/meta/metadoc_show_config.d index a56e632..5bbeea6 100644 --- a/src/sisudoc/meta/metadoc_show_config.d +++ b/src/sisudoc/meta/metadoc_show_config.d @@ -54,21 +54,19 @@ template spineShowSiteConfig() { O opt_action, T config, ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.digest.crc, - std.digest.sha, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.digest.crc; + import std.digest.sha; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; auto markup = InlineMarkup(); auto char_repeat_number = 66; @@ -139,24 +137,20 @@ template spineShowSiteConfig() { } } template spineShowConfig() { - void spineShowConfig(T)( - T doc_matters, - ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.digest.crc, - std.digest.sha, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + void spineShowConfig(T)(T doc_matters) { + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.digest.crc; + import std.digest.sha; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; auto markup = InlineMarkup(); auto min_repeat_number = 66; diff --git a/src/sisudoc/meta/metadoc_show_make.d b/src/sisudoc/meta/metadoc_show_make.d index d3271bf..57721cf 100644 --- a/src/sisudoc/meta/metadoc_show_make.d +++ b/src/sisudoc/meta/metadoc_show_make.d @@ -50,24 +50,20 @@ module sisudoc.meta.metadoc_show_make; @safe: template spineShowMake() { - void spineShowMake(T)( - T doc_matters, - ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.digest.crc, - std.digest.sha, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + void spineShowMake(T)(T doc_matters) { + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.digest.crc; + import std.digest.sha; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; auto markup = InlineMarkup(); auto min_repeat_number = 66; diff --git a/src/sisudoc/meta/metadoc_show_metadata.d b/src/sisudoc/meta/metadoc_show_metadata.d index 1857df8..331ab7f 100644 --- a/src/sisudoc/meta/metadoc_show_metadata.d +++ b/src/sisudoc/meta/metadoc_show_metadata.d @@ -50,24 +50,20 @@ module sisudoc.meta.metadoc_show_metadata; @safe: template spineShowMetaData() { - void spineShowMetaData(T)( - T doc_matters, - ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.digest.crc, - std.digest.sha, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + void spineShowMetaData(T)(T doc_matters) { + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.digest.crc; + import std.digest.sha; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; auto markup = InlineMarkup(); auto min_repeat_number = 66; diff --git a/src/sisudoc/meta/metadoc_show_summary.d b/src/sisudoc/meta/metadoc_show_summary.d index 0404af4..ceb4fd5 100644 --- a/src/sisudoc/meta/metadoc_show_summary.d +++ b/src/sisudoc/meta/metadoc_show_summary.d @@ -50,25 +50,21 @@ module sisudoc.meta.metadoc_show_summary; @safe: template spineMetaDocSummary() { - void spineMetaDocSummary(S,T)( - const S doc_abstraction, - T doc_matters, - ) { - import - sisudoc.meta.defaults, - sisudoc.meta.rgx; - import - std.array, - std.digest.crc, - std.digest.sha, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; + void spineMetaDocSummary(D)(D doc) { + auto doc_matters = doc.matters; + import sisudoc.meta.defaults; + import sisudoc.meta.rgx; + import std.array; + import std.digest.crc; + import std.digest.sha; + import std.exception; + import std.regex; + import std.stdio; + import std.string; + import std.typecons; + import std.uni; + import std.utf; + import std.conv : to; mixin InternalMarkup; auto markup = InlineMarkup(); auto min_repeat_number = 66; @@ -77,7 +73,7 @@ template spineMetaDocSummary() { char_repeat_number = (char_repeat_number > min_repeat_number) ? char_repeat_number : min_repeat_number; - if (doc_matters.opt.action.vox_gt1 + if (doc_matters.opt.action.vox_gt_2 || doc_matters.opt.action.show_summary) { string[string] check = [ "last_object_number" : "NA [debug \"checkdoc\" not run]", @@ -85,7 +81,7 @@ template spineMetaDocSummary() { "last_object_number_book_index" : "0", ]; foreach (k; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[k]) { + foreach (obj; doc.abstraction[k]) { if (obj.metainfo.is_of_part != "empty") { if (!empty(obj.metainfo.object_number)) { if (k == "body") { @@ -116,9 +112,9 @@ template spineMetaDocSummary() { doc_matters.src.language, markup.repeat_character_by_number_provided("-", char_repeat_number), "- toc arr length:", - to!int(doc_abstraction["toc"].length), - "- doc_abstraction arr length:", - to!int(doc_abstraction["body"].length), + to!int(doc.abstraction["toc"].length), + "- doc.abstraction arr length:", + to!int(doc.abstraction["body"].length), " doc body last obj on.#:", to!int(check["last_object_number_body"]), " - number of tables:", @@ -134,26 +130,26 @@ template spineMetaDocSummary() { " - number of images:", doc_matters.has.images, "- endnotes length:", // subtract headings - (doc_abstraction["endnotes"].length > 2) - ? (to!int(doc_abstraction["endnotes"].length - 2)) + (doc.abstraction["endnotes"].length > 2) + ? (to!int(doc.abstraction["endnotes"].length - 2)) : 0, "- glossary length:", - (doc_abstraction["glossary"].length > 1) - ? (to!int(doc_abstraction["glossary"].length)) + (doc.abstraction["glossary"].length > 1) + ? (to!int(doc.abstraction["glossary"].length)) : 0, "- biblio length:", - (doc_abstraction["bibliography"].length > 1) - ? (to!int(doc_abstraction["bibliography"].length)) + (doc.abstraction["bibliography"].length > 1) + ? (to!int(doc.abstraction["bibliography"].length)) : 0, "- bookindex length:", - (doc_abstraction["bookindex"].length > 1) - ? (to!int(doc_abstraction["bookindex"].length)) + (doc.abstraction["bookindex"].length > 1) + ? (to!int(doc.abstraction["bookindex"].length)) : 0, " book idx last obj on.#:", to!int(check["last_object_number_book_index"]), "- blurb length:", - (doc_abstraction["blurb"].length > 1) - ? (to!int(doc_abstraction["blurb"].length)) + (doc.abstraction["blurb"].length > 1) + ? (to!int(doc.abstraction["blurb"].length)) : 0, "* last obj on.#:", to!int(check["last_object_number"]), diff --git a/src/sisudoc/meta/package.d b/src/sisudoc/meta/package.d index d24afbb..911952b 100644 --- a/src/sisudoc/meta/package.d +++ b/src/sisudoc/meta/package.d @@ -48,17 +48,15 @@ +/ module sisudoc.meta; -public import - sisudoc.meta.defaults; +public import sisudoc.meta.defaults; /+ std +/ -public import - std.array, - std.exception, - std.range, - std.regex, - std.stdio, - std.string, - std.typecons, - // std.uni, - std.utf, - std.conv : to; +public import std.array; +public import std.exception; +public import std.range; +public import std.regex; +public import std.stdio; +public import std.string; +public import std.typecons; +// public import std.uni; +public import std.utf; +public import std.conv : to; diff --git a/src/sisudoc/meta/rgx.d b/src/sisudoc/meta/rgx.d index eb6fc04..86ca40c 100644 --- a/src/sisudoc/meta/rgx.d +++ b/src/sisudoc/meta/rgx.d @@ -108,8 +108,8 @@ static template spineRgxIn() { static para_attribs = ctRegex!(`^_(?:(?:[0-9])(?:_([0-9]))?|(?:[1-9])?[*]) `); static para_inline_link_anchor = ctRegex!(`\*[~](?P<anchor>[a-z0-9_.-]+)(?= |$)`,"i"); /+ blocked markup +/ - static block_open = ctRegex!("^((code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|^`{3} (code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?|^[{]table[(](?:h;)?(?P<columns>(?:[ ,]+[0-9]+)+)[)][}]"); - static block_poem_open = ctRegex!("^((poem(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|`{3} poem(?:[(][ a-zA-Z0-9;:,]*[)])?)"); + static block_open = ctRegex!("^((code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|^[`']{3} (code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?|^[{]table[(](?:h;)?(?P<columns>(?:[ ,]+[0-9]+)+)[)][}]"); + static block_poem_open = ctRegex!("^((poem(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|[`']{3} poem(?:[(][ a-zA-Z0-9;:,]*[)])?)"); /+ blocked markup tics +/ static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); static block_tic_poem_open = ctRegex!("^`{3} poem(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); @@ -118,6 +118,14 @@ static template spineRgxIn() { static block_tic_quote_open = ctRegex!("^`{3} quote(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); static block_tic_table_open = ctRegex!("^`{3} table(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); // ctRegex!("^`{3} table(?:\(.*?\))?"); static block_tic_close = ctRegex!("^(`{3})$","m"); + /+ blocked markup tics +/ + static block_quotemarks_code_open = ctRegex!(`^'{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); + static block_quotemarks_poem_open = ctRegex!(`^'{3} poem(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); + static block_quotemarks_group_open = ctRegex!(`^'{3} group(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); + static block_quotemarks_block_open = ctRegex!(`^'{3} block(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); + static block_quotemarks_quote_open = ctRegex!(`^'{3} quote(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); + static block_quotemarks_table_open = ctRegex!(`^'{3} table(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?`); // ctRegex!("^'{3} table(?:\(.*?\))?"); + static block_quotemarks_close = ctRegex!(`^('{3})$`,"m"); /+ blocked markup curly +/ static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P<syntax>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); static block_curly_code_close = ctRegex!(`^([}]code)`); @@ -140,16 +148,16 @@ static template spineRgxIn() { static table_col_separator_nl = ctRegex!(`[┊]$`, "mg"); /+ inline markup footnotes endnotes +/ static inline_notes_curly_gen = ctRegex!(`~\{.+?\}~`, "m"); - static inline_notes_curly = ctRegex!(`~\{\s*(.+?)\}~`, "mg"); - static inline_notes_curly_sp_asterisk = ctRegex!(`~\{[*]+\s+(.+?)\}~`, "m"); - static inline_notes_curly_sp_plus = ctRegex!(`~\{[+]+\s+(.+?)\}~`, "m"); + static inline_notes_curly = ctRegex!(`~\{\s*(.+?)\s*\}~`, "mg"); + static inline_notes_curly_sp_asterisk = ctRegex!(`~\{[*]+\s+(.+?)\s*\}~`, "m"); + static inline_notes_curly_sp_plus = ctRegex!(`~\{[+]+\s+(.+?)\s*\}~`, "m"); static note_ref = ctRegex!(`^\S+?noteref_(?P<ref>[0-9]+)`, "mg"); // {^{73.}^}#noteref_73 static smid_inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); static smid_inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); static smid_inline_link_naked_url = ctRegex!(`(?P<pre>^|[ (\[])(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?=[.,;:?!'"]?([ )\]]|$))`, "mg"); static smid_inline_link_markup_regular = ctRegex!(`(?P<pre>^|[ (\[])\{\s*(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); - static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); - static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); + static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); + static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); static smid_image = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); static smid_image_generic = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); @@ -213,9 +221,9 @@ static template spineRgxIn() { static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg"); static br_linebreaks_newlines = ctRegex!(`[\n┘┙]`, "mg"); static br_linebreaks = ctRegex!(`[┘┙]`, "mg"); - static br_line = ctRegex!(`┘`, "mg"); - static br_line_inline = ctRegex!(`┙`, "mg"); - static br_line_spaced = ctRegex!(`┚`, "mg"); + static br_line = ctRegex!(`\s*┘\s*`, "mg"); + static br_line_inline = ctRegex!(`\s*┙\s*`, "mg"); + static br_line_spaced = ctRegex!(`\s*┚\s*`, "mg"); /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented @@ -228,6 +236,7 @@ static template spineRgxIn() { static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|.+))`, "mg"); + static endnote_section_note = ctRegex!(`┥\s*⑆\^┨(?P<notenumber>\d+)\.┣\^┝┤(?P<link>¤?.+?)├.+`, "mg"); /+ inline markup links +/ static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); @@ -242,6 +251,7 @@ static template spineRgxIn() { static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static find_bookindex_ocn_link_and_comma = ctRegex!(`[, ]*┥.+?┝┤#?\S+?├`, "mg"); static url = ctRegex!(`https?://`, "mg"); static uri = ctRegex!(`(?:https?|git)://`, "mg"); static uri_identify_components = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); diff --git a/src/sisudoc/meta/rgx_yaml_tags.d b/src/sisudoc/meta/rgx_yaml.d index ee57469..ee57469 100644 --- a/src/sisudoc/meta/rgx_yaml_tags.d +++ b/src/sisudoc/meta/rgx_yaml.d diff --git a/src/sisudoc/share/defaults.d b/src/sisudoc/share/defaults.d index 502aca0..c285260 100644 --- a/src/sisudoc/share/defaults.d +++ b/src/sisudoc/share/defaults.d @@ -57,12 +57,12 @@ template Msg() { auto Msg(I)(I doc_matters) { struct Msg_ { void v()(string message) { - if (doc_matters.opt.action.vox_gt1) { + if (doc_matters.opt.action.vox_gt_2) { writeln(message); } } void vv()(string message) { - if (doc_matters.opt.action.vox_gt2) { + if (doc_matters.opt.action.vox_gt_3) { writeln(message); } } diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d index fc2b2dd..f53fc09 100755 --- a/src/sisudoc/spine.d +++ b/src/sisudoc/spine.d @@ -1,4 +1,3 @@ -#!/usr/bin/env rdmd /+ - Name: SisuDoc Spine, Doc Reform [a part of] - Description: documents, structuring, processing, publishing, search @@ -55,32 +54,30 @@ description "A SiSU inspired document parser written in D." homepage "https://sisudoc.org" +/ @safe: -import - std.algorithm, - std.datetime, - std.getopt, - std.file, - std.path, - std.process; -import - sisudoc.conf.compile_time_info, - sisudoc.meta, - sisudoc.meta.metadoc, - sisudoc.meta.metadoc_curate, - sisudoc.meta.metadoc_curate_authors, - sisudoc.meta.metadoc_curate_topics, - sisudoc.meta.metadoc_from_src, - sisudoc.meta.conf_make_meta_structs, - sisudoc.meta.conf_make_meta_json, - sisudoc.meta.defaults, - sisudoc.meta.doc_debugs, - sisudoc.meta.rgx, - sisudoc.meta.rgx_yaml, - sisudoc.meta.rgx_files, - sisudoc.io_in.paths_source, - sisudoc.io_in.read_config_files, - sisudoc.io_in.read_source_files, - sisudoc.io_out.hub; +import std.algorithm; +import std.datetime; +import std.getopt; +import std.file; +import std.path; +import std.process; +import sisudoc.conf.compile_time_info; +import sisudoc.meta; +import sisudoc.meta.metadoc; +import sisudoc.meta.metadoc_curate; +import sisudoc.meta.metadoc_curate_authors; +import sisudoc.meta.metadoc_curate_topics; +import sisudoc.meta.metadoc_from_src; +import sisudoc.meta.conf_make_meta_structs; +import sisudoc.meta.conf_make_meta_json; +import sisudoc.meta.defaults; +import sisudoc.meta.doc_debugs; +import sisudoc.meta.rgx; +import sisudoc.meta.rgx_yaml; +import sisudoc.meta.rgx_files; +import sisudoc.io_in.paths_source; +import sisudoc.io_in.read_config_files; +import sisudoc.io_in.read_source_files; +import sisudoc.io_out.hub; mixin(import("version.txt")); mixin(import("configuration.txt")); mixin CompileTimeInfo; @@ -147,6 +144,7 @@ string program_name = "spine"; "html-link-pdf-a4" : false, "html-link-pdf-letter" : false, "html-link-search" : false, + "html-link-text" : false, "html-seg" : false, "html-scroll" : false, "latex" : false, @@ -156,6 +154,7 @@ string program_name = "spine"; "light" : false, "manifest" : false, "hide-ocn" : false, + "no-ocn" : false, "ocn-off" : false, "odf" : false, "odt" : false, @@ -179,6 +178,7 @@ string program_name = "spine"; "show-pod" : false, "show-sqlite" : false, "show-summary" : false, + "skel" : false, "source" : false, "sqlite-discrete" : false, "sqlite-db-create" : false, @@ -188,9 +188,11 @@ string program_name = "spine"; "sqlite-insert" : false, "sqlite-update" : false, "text" : false, - "vox_is0" : false, - "vox_gt1" : false, - "vox_gt2" : false, + "vox_is0" : false, // silent + "vox_is1" : false, // quiet + "vox_is2" : false, // default (unset) + "vox_is3" : false, // verbose + "vox_is4" : false, // very verbose "xhtml" : false, "section_toc" : true, "section_body" : true, @@ -251,6 +253,7 @@ string program_name = "spine"; "html-link-pdf", "provide html link to pdf a4 & letter output", &opts["html-link-pdf"], "html-link-pdf-a4", "provide html link to pdf a4 output", &opts["html-link-pdf-a4"], "html-link-pdf-letter", "provide html link to pdf letter size output", &opts["html-link-pdf-letter"], + "html-link-text", "provide html link to text output", &opts["html-link-text"], "html-link-search", "html embedded search submission", &opts["html-link-search"], "html-seg", "process html output", &opts["html-seg"], "html-scroll", "process html output", &opts["html-scroll"], @@ -261,6 +264,7 @@ string program_name = "spine"; "latex-header-sty", "latex document header sty files", &opts["latex-header-sty"], "light", "default light theme", &opts["light"], "manifest", "process manifest output", &opts["manifest"], + "no-ocn", "object cite numbers", &opts["no-ocn"], "ocn-off", "object cite numbers", &opts["ocn-off"], "odf", "open document format text (--odt)", &opts["odf"], "odt", "open document format text", &opts["odt"], @@ -271,7 +275,7 @@ string program_name = "spine"; "pdf-color-links", "mono or color links for pdfs", &opts["pdf-color-links"], "pdf-init", "initialise latex shared files (see latex-header-sty)", &opts["pdf-init"], "pod", "spine (doc reform) pod source content bundled", &opts["pod"], - "quiet|q", "output to terminal", &opts["vox_is0"], + "quiet|q", "output to terminal", &opts["vox_is1"], "section-backmatter", "document backmatter (default)" , &opts["backmatter"], "section-biblio", "document biblio (default)", &opts["section_biblio"], "section-blurb", "document blurb (default)", &opts["section_blurb"], @@ -296,9 +300,11 @@ string program_name = "spine"; "show-sqlite", "show sqlite", &opts["show-sqlite"], "show-summary", "show summary", &opts["show-summary"], "source", "document markup source", &opts["source"], + "silent", "output to terminal", &opts["vox_is0"], "set-digest", "default hash digest type (e.g. sha256)", &settings["set-digest"], "set-papersize", "default papersize (latex pdf eg. a4 or a5 or b4 or letter)", &settings["set-papersize"], "set-textwrap", "default textwrap (e.g. 80 (characters)", &settings["set-textwrap"], + "skel", "skel (dummy outline)", &opts["skel"], "sqlite-discrete", "process discrete sqlite output", &opts["sqlite-discrete"], "sqlite-db-create", "create db, create tables", &opts["sqlite-db-create"], "sqlite-db-drop", "drop tables & db", &opts["sqlite-db-drop"], @@ -308,16 +314,16 @@ string program_name = "spine"; "sqlite-delete", "sqlite output", &opts["sqlite-delete"], "sqlite-insert", "sqlite output", &opts["sqlite-insert"], "sqlite-update", "sqlite output", &opts["sqlite-update"], + "text", "text output", &opts["text"], + "txt", "text output", &opts["text"], "www-http", "http or https", &settings["www-http"], "www-host", "web server host (domain) name", &settings["www-host"], "www-host-doc-root", "web host host (domain) name with path to doc root", &settings["www-host-doc-root"], "www-url-doc-root", "e.g. http://localhost", &settings["www-url-doc-root"], - "text", "text output", &opts["text"], "theme-dark", "alternative dark theme", &opts["theme-dark"], "theme-light", "default light theme", &opts["theme-light"], - "txt", "text output", &opts["text"], - "verbose|v", "output to terminal", &opts["vox_gt1"], - "very-verbose", "output to terminal", &opts["vox_gt2"], + "verbose|v", "output to terminal", &opts["vox_is3"], + "very-verbose", "output to terminal", &opts["vox_is4"], "workon", "(reserved for some matters under development & testing)", &opts["workon"], "xhtml", "xhtml output", &opts["xhtml"], "config", "=/path/to/config/file/including/filename", &settings["config"], @@ -339,7 +345,7 @@ string program_name = "spine"; if (helpInfo.helpWanted) { defaultGetoptPrinter("Some information about the program.", helpInfo.options); } - enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } + enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff, text, skel } struct OptActions { @trusted bool allow_downloads() { return opts["allow-downloads"]; @@ -443,6 +449,12 @@ string program_name = "spine"; @trusted bool html_link_pdf_letter() { return (opts["html-link-pdf-letter"]) ? true : false; } + @trusted bool html_link_text() { + return (opts["html-link-text"]) ? true : false; + } + @trusted bool text_link_curate() { + return (opts["text-link-curate"]) ? true : false; + } @trusted bool html_link_search() { return (opts["html-link-search"]) ? true : false; } @@ -477,7 +489,7 @@ string program_name = "spine"; return opts["hide-ocn"]; } @trusted bool ocn_off() { - return opts["ocn-off"]; + return ((opts["ocn-off"]) || (opts["no-ocn"])) ? true : false; } @trusted bool pod() { return opts["pod"]; @@ -489,10 +501,10 @@ string program_name = "spine"; return opts["show-curate"]; } @trusted bool show_curate_authors() { - return (opts["show-curate"] || opts["show-curate-authors"] || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; + return (opts["show-curate"] || opts["show-curate-authors"] || vox_gt_2) ? true : false; } @trusted bool show_curate_topics() { - return (opts["show-curate"] || opts["show-curate-topics"] || opts["vox_gt2"]) ? true : false; + return (opts["show-curate"] || opts["show-curate-topics"] || vox_gt_3) ? true : false; } @trusted bool show_epub() { return opts["show-epub"]; @@ -516,10 +528,10 @@ string program_name = "spine"; return opts["show-pod"]; } @trusted bool show_sqlite() { - return (opts["show-sqlite"] || opts["vox_gt2"]) ? true : false; + return (opts["show-sqlite"] || vox_gt_3) ? true : false; } @trusted bool show_summary() { - return (opts["show-summary"] || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; + return (opts["show-summary"] || vox_gt_2) ? true : false; } @trusted bool source() { return opts["source"]; @@ -551,21 +563,48 @@ string program_name = "spine"; || opts["sqlite-update"] ) ? true : false; } - @trusted bool vox_is0() { // --quiet -q + @trusted bool skel() { + return opts["skel"]; + } + @trusted bool text() { + return opts["text"]; + } + @trusted bool vox_0() { // --silent return opts["vox_is0"]; } - @trusted bool vox_gt0() { // normal, minimal, without flag - return (!(opts["vox_is0"]) || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; + @trusted bool vox_1() { // --quiet -q + return opts["vox_is1"]; } - @trusted bool vox_gt1() { // -- verbose -v - return (opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; + @trusted bool vox_2() { // normal, minimal, without flag + bool _vox_default = true; + if (opts["vox_is0"] || opts["vox_is1"] || opts["vox_is3"] || opts["vox_is4"]) { _vox_default = false; + } else { _vox_default = true; + } + return _vox_default; } - @trusted bool vox_gt2() { // --very-verbose - return opts["vox_gt2"]; + @trusted bool vox_3() { // --verbose -v + return opts["vox_is3"]; } - @trusted bool text() { - return opts["text"]; + @trusted bool vox_4() { // --very-verbose + return opts["vox_is4"]; + } + @trusted bool vox_gt_0() { // --quiet -q and above + return ( vox_1 || vox_2 || vox_3 || vox_4) ? true : false; } + @trusted bool vox_gt_1() { // normal, and above + return (vox_2 || vox_3 || vox_4) ? true : false; + } + @trusted bool vox_gt_2() { // --verbose -v and above + return ( vox_3 || vox_4) ? true : false; + } + @trusted bool vox_gt_3() { // --very-verbose + return (vox_4) ? true : false; + } + @trusted bool vox_silent() { return vox_0; } // --silent + @trusted bool vox_quiet() { return vox_gt_0; } // --quiet -q & above + @trusted bool vox_default() { return vox_gt_1; } // defalt, & above + @trusted bool vox_verbose() { return vox_gt_2; } // --verbose -v & above + @trusted bool vox_very_verbose() { return vox_gt_3; } // --very-verbose @trusted bool xhtml() { return opts["xhtml"]; } @@ -679,6 +718,8 @@ string program_name = "spine"; || latex || manifest || sqlite_discrete + || text + || skel ) { _is = true; } else { _is = false; } @@ -689,30 +730,16 @@ string program_name = "spine"; } auto output_task_scheduler() { int[] schedule; - if (source_or_pod) { - schedule ~= outTask.source_or_pod; - } - if (sqlite_discrete) { - schedule ~= outTask.sqlite; - } - if (epub) { - schedule ~= outTask.epub; - } - if (html_scroll) { - schedule ~= outTask.html_scroll; - } - if (html_seg) { - schedule ~= outTask.html_seg; - } - if (html_stuff) { - schedule ~= outTask.html_stuff; - } - if (odt) { - schedule ~= outTask.odt; - } - if (latex) { - schedule ~= outTask.latex; - } + if (source_or_pod) { schedule ~= outTask.source_or_pod; } + if (sqlite_discrete) { schedule ~= outTask.sqlite; } + if (epub) { schedule ~= outTask.epub; } + if (html_scroll) { schedule ~= outTask.html_scroll; } + if (html_seg) { schedule ~= outTask.html_seg; } + if (html_stuff) { schedule ~= outTask.html_stuff; } + if (odt) { schedule ~= outTask.odt; } + if (latex) { schedule ~= outTask.latex; } + if (text) { schedule ~= outTask.text; } + if (skel) { schedule ~= outTask.skel; } return schedule.sort().uniq; } @trusted bool abstraction() { @@ -729,6 +756,8 @@ string program_name = "spine"; || sqlite_discrete || sqlite_delete || sqlite_update + || text + || skel ) ? true : false; } @trusted bool require_processing_files() { @@ -750,6 +779,7 @@ string program_name = "spine"; || sqlite_update || text || xhtml + || skel ) ? true : false; } @trusted bool meta_processing_general() { @@ -762,6 +792,8 @@ string program_name = "spine"; || latex || sqlite_discrete || sqlite_update + || text + || skel ) ? true :false; } @trusted bool meta_processing_xml_dom() { @@ -885,94 +917,53 @@ string program_name = "spine"; ); if (exists(sisudoc_txt_)) { try { - if (exists(sisudoc_txt_)) { - import dyaml; - try { - Node pod_manifest_yaml; - try { - pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); - } catch (ErrnoException ex) { - } catch (FileException ex) { - writeln("ERROR failed to read config file"); - } catch (Throwable) { - writeln("ERROR failed to read config file content, not parsed as yaml"); - } - if ("doc" in pod_manifest_yaml) { - if (pod_manifest_yaml["doc"].type.mapping - && pod_manifest_yaml["doc"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("path" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_seq)) { - foreach (string _path; pod_manifest_yaml["doc"]["path"]) { - markup_contents_location_ ~= _path ~ "\n"; - pod_manifest_root_content_paths_to_markup_location_raw_ ~= - _path ~ "\n"; - } - } else if ( - pod_manifest_yaml["doc"]["path"].type.string - && pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_str) - ) { - markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; - pod_manifest_root_content_paths_to_markup_location_raw_ = - pod_manifest_yaml["doc"]["path"].get!string; - } + import dyaml; + Node pod_manifest_yaml; + try { + pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); + } catch (ErrnoException ex) { + } catch (FileException ex) { + writeln("ERROR failed to read config file"); + } catch (Throwable) { + writeln("ERROR failed to read config file content, not parsed as yaml"); + } + if ("doc" in pod_manifest_yaml) { + if (pod_manifest_yaml["doc"].type.mapping + && pod_manifest_yaml["doc"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("path" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_seq)) { + foreach (string _path; pod_manifest_yaml["doc"]["path"]) { + markup_contents_location_ ~= _path ~ "\n"; + pod_manifest_root_content_paths_to_markup_location_raw_ ~= + _path ~ "\n"; } - if ("filename" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_seq)) { - foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { - if ("language" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { - foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { - markup_contents_location_ ~= - "media/text/" - ~ _lang ~ "/" - ~ _filename ~ "\n"; - } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str) - ) { - markup_contents_location_ = - "media/text/" - ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ _filename ~ "\n"; - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } - } else if ( - pod_manifest_yaml["doc"]["filename"].type.string - && pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_str) - ) { - if ("language" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { - foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { - markup_contents_location_ ~= - "media/text/" - ~ _lang ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str)) { - markup_contents_location_ = - "media/text/" - ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } else { - string _lang_default = "en"; + } else if ( + pod_manifest_yaml["doc"]["path"].type.string + && pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_str) + ) { + markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; + pod_manifest_root_content_paths_to_markup_location_raw_ = + pod_manifest_yaml["doc"]["path"].get!string; + } + } + if ("filename" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_seq)) { + foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { + if ("language" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { + foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { markup_contents_location_ ~= "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + ~ _lang ~ "/" + ~ _filename ~ "\n"; } + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str) + ) { + markup_contents_location_ = + "media/text/" + ~ pod_manifest_yaml["doc"]["language"].get!string + ~ "/" ~ _filename ~ "\n"; } else { string _lang_default = "en"; markup_contents_location_ ~= @@ -980,11 +971,47 @@ string program_name = "spine"; ~ _lang_default ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } } + } else if ( + pod_manifest_yaml["doc"]["filename"].type.string + && pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_str) + ) { + if ("language" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { + foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { + markup_contents_location_ ~= + "media/text/" + ~ _lang ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str)) { + markup_contents_location_ = + "media/text/" + ~ pod_manifest_yaml["doc"]["language"].get!string + ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } } } - } catch (ErrnoException ex) { } } } catch (ErrnoException ex) { @@ -1037,7 +1064,7 @@ string program_name = "spine"; foreach(manifest; parallel(_manifests[1..$])) { if (!empty(manifest.src.filename)) { scope(success) { - if (_opt_action.vox_gt0) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } + if (_opt_action.vox_gt_1) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } } scope(failure) { debug(checkdoc) { @@ -1059,71 +1086,64 @@ string program_name = "spine"; ) { writeln("--->\nstepX commence → (document abstraction) [", manifest.src.filename, "]"); } - auto t = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); - static assert(t.length==2); - auto doc_abstraction = t[dAM.abstraction]; - auto doc_matters = t[dAM.matters]; - if ((doc_matters.opt.action.debug_do) + auto doc = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); + if ((doc.matters.opt.action.debug_do) || (_opt_action.debug_do_stages) ) { writeln("- stepX complete for [", manifest.src.filename, "]"); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_summary) { + if (doc.matters.opt.action.show_summary) { import sisudoc.meta.metadoc_show_summary; - spineMetaDocSummary!()(doc_abstraction, doc_matters); + spineMetaDocSummary!()(doc); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_metadata) { + if (doc.matters.opt.action.show_metadata) { import sisudoc.meta.metadoc_show_metadata; - spineShowMetaData!()(doc_matters); + spineShowMetaData!()(doc.matters); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_make) { + if (doc.matters.opt.action.show_make) { import sisudoc.meta.metadoc_show_make; - spineShowMake!()(doc_matters); + spineShowMake!()(doc.matters); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_config) { + if (doc.matters.opt.action.show_config) { import sisudoc.meta.metadoc_show_config; - spineShowConfig!()(doc_matters); + spineShowConfig!()(doc.matters); } - if (doc_matters.opt.action.curate) { - auto _hvst = spineMetaDocCurate!()(doc_matters, hvst); + if (doc.matters.opt.action.curate) { + auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( _hvst.title.length > 0 && _hvst.author_surname_fn.length > 0 ) { hvst.curates ~= _hvst; } else { - if ((doc_matters.opt.action.debug_do) + if ((doc.matters.opt.action.debug_do) || (_opt_action.debug_do_curate) - || (doc_matters.opt.action.vox_gt2) + || (doc.matters.opt.action.vox_gt_3) ) { writeln("WARNING curate: document header yaml does not contain information related to: title or author: ", _hvst.path_html_segtoc); } } } /+ ↓ debugs +/ - if (doc_matters.opt.action.debug_do) { - spineDebugs!()(doc_abstraction, doc_matters); + if (doc.matters.opt.action.debug_do) { + spineDebugs!()(doc.abstraction, doc.matters); } /+ ↓ output hub +/ - if (!(doc_matters.opt.action.skip_output)) { - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { + if (!(doc.matters.opt.action.skip_output)) { + if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) { writeln("step5 commence → (process outputs) [", manifest.src.filename, "]"); } - doc_abstraction.outputHub!()(doc_matters); - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { + doc.outputHub!(); + if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) { writeln("- step5 complete for [", manifest.src.filename, "]"); } } scope(exit) { - if (_opt_action.vox_gt0) { + if (_opt_action.vox_gt_1) { writefln( "processed file: %s [%s]", manifest.src.filename, @@ -1140,10 +1160,10 @@ string program_name = "spine"; } } else { // note cannot parallelise sqlite shared db foreach(manifest; _manifests[1..$]) { - if (_opt_action.vox_gt2) { writeln("parallelisation off: actions include sqlite shared db"); } + if (_opt_action.vox_gt_3) { writeln("parallelisation off: actions include sqlite shared db"); } if (!empty(manifest.src.filename)) { scope(success) { - if (_opt_action.vox_gt0) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } + if (_opt_action.vox_gt_1) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } } scope(failure) { debug(checkdoc) { @@ -1165,71 +1185,64 @@ string program_name = "spine"; ) { writeln("--->\nstepX commence → (document abstraction) [", manifest.src.filename, "]"); } - auto t = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); - static assert(t.length==2); - auto doc_abstraction = t[dAM.abstraction]; - auto doc_matters = t[dAM.matters]; - if ((doc_matters.opt.action.debug_do) + auto doc = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); + if ((doc.matters.opt.action.debug_do) || (_opt_action.debug_do_stages) ) { writeln("- stepX complete for [", manifest.src.filename, "]"); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_summary) { + if (doc.matters.opt.action.show_summary) { import sisudoc.meta.metadoc_show_summary; - spineMetaDocSummary!()(doc_abstraction, doc_matters); + spineMetaDocSummary!()(doc); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_metadata) { + if (doc.matters.opt.action.show_metadata) { import sisudoc.meta.metadoc_show_metadata; - spineShowMetaData!()(doc_matters); + spineShowMetaData!()(doc.matters); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_make) { + if (doc.matters.opt.action.show_make) { import sisudoc.meta.metadoc_show_make; - spineShowMake!()(doc_matters); + spineShowMake!()(doc.matters); } /+ ↓ debugs +/ - if (doc_matters.opt.action.show_config) { + if (doc.matters.opt.action.show_config) { import sisudoc.meta.metadoc_show_config; - spineShowConfig!()(doc_matters); + spineShowConfig!()(doc.matters); } - if (doc_matters.opt.action.curate) { - auto _hvst = spineMetaDocCurate!()(doc_matters, hvst); + if (doc.matters.opt.action.curate) { + auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( _hvst.title.length > 0 && _hvst.author_surname_fn.length > 0 ) { hvst.curates ~= _hvst; } else { - if ((doc_matters.opt.action.debug_do) + if ((doc.matters.opt.action.debug_do) || (_opt_action.debug_do_curate) - || (doc_matters.opt.action.vox_gt2) + || (doc.matters.opt.action.vox_gt_3) ) { writeln("WARNING curate: document header yaml does not contain information related to: title or author: ", _hvst.path_html_segtoc); } } } /+ ↓ debugs +/ - if (doc_matters.opt.action.debug_do) { - spineDebugs!()(doc_abstraction, doc_matters); + if (doc.matters.opt.action.debug_do) { + spineDebugs!()(doc.abstraction, doc.matters); } /+ ↓ output hub +/ - if (!(doc_matters.opt.action.skip_output)) { - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { + if (!(doc.matters.opt.action.skip_output)) { + if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) { writeln("step5 commence → (process outputs) [", manifest.src.filename, "]"); } - doc_abstraction.outputHub!()(doc_matters); - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { + doc.outputHub!(); + if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) { writeln("- step5 complete for [", manifest.src.filename, "]"); } } scope(exit) { - if (_opt_action.vox_gt0) { + if (_opt_action.vox_gt_1) { writefln( "processed file: %s [%s]", manifest.src.filename, @@ -1253,7 +1266,7 @@ string program_name = "spine"; if (_opt_action.curate_authors) { spineMetaDocCuratesAuthors!()(hvst.curates, _make_and_meta_struct, _opt_action); } - if (_opt_action.vox_gt0) { + if (_opt_action.vox_gt_1) { import sisudoc.io_out.paths_output; auto out_pth = spinePathsHTML!()(_make_and_meta_struct.conf.output_path, ""); if (_opt_action.curate_authors) { |