From 90873fabd7451e1dd8c4b39303906e19bdc481f7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 10 Apr 2024 22:24:34 -0400 Subject: 0.16.0 sisudoc (src/sisudoc sisudoc spine) - src/sisudoc (replaces src/doc_reform) - sisudoc spine (used more) --- src/doc_reform/meta/conf_make_meta_json.d | 695 --- src/doc_reform/meta/conf_make_meta_structs.d | 316 -- src/doc_reform/meta/conf_make_meta_yaml.d | 1277 ------ src/doc_reform/meta/defaults.d | 297 -- src/doc_reform/meta/doc_debugs.d | 252 -- src/doc_reform/meta/metadoc.d | 296 -- src/doc_reform/meta/metadoc_curate.d | 92 - src/doc_reform/meta/metadoc_curate_authors.d | 530 --- src/doc_reform/meta/metadoc_curate_topics.d | 693 --- src/doc_reform/meta/metadoc_from_src.d | 1509 ------- src/doc_reform/meta/metadoc_from_src_functions.d | 5216 ---------------------- src/doc_reform/meta/metadoc_object_setter.d | 426 -- src/doc_reform/meta/metadoc_show_config.d | 232 - src/doc_reform/meta/metadoc_show_make.d | 123 - src/doc_reform/meta/metadoc_show_metadata.d | 171 - src/doc_reform/meta/metadoc_show_summary.d | 162 - src/doc_reform/meta/package.d | 64 - src/doc_reform/meta/rgx.d | 270 -- src/doc_reform/meta/rgx_files.d | 72 - src/doc_reform/meta/rgx_yaml_tags.d | 62 - 20 files changed, 12755 deletions(-) delete mode 100644 src/doc_reform/meta/conf_make_meta_json.d delete mode 100644 src/doc_reform/meta/conf_make_meta_structs.d delete mode 100644 src/doc_reform/meta/conf_make_meta_yaml.d delete mode 100644 src/doc_reform/meta/defaults.d delete mode 100644 src/doc_reform/meta/doc_debugs.d delete mode 100644 src/doc_reform/meta/metadoc.d delete mode 100644 src/doc_reform/meta/metadoc_curate.d delete mode 100644 src/doc_reform/meta/metadoc_curate_authors.d delete mode 100644 src/doc_reform/meta/metadoc_curate_topics.d delete mode 100644 src/doc_reform/meta/metadoc_from_src.d delete mode 100644 src/doc_reform/meta/metadoc_from_src_functions.d delete mode 100644 src/doc_reform/meta/metadoc_object_setter.d delete mode 100644 src/doc_reform/meta/metadoc_show_config.d delete mode 100644 src/doc_reform/meta/metadoc_show_make.d delete mode 100644 src/doc_reform/meta/metadoc_show_metadata.d delete mode 100644 src/doc_reform/meta/metadoc_show_summary.d delete mode 100644 src/doc_reform/meta/package.d delete mode 100644 src/doc_reform/meta/rgx.d delete mode 100644 src/doc_reform/meta/rgx_files.d delete mode 100644 src/doc_reform/meta/rgx_yaml_tags.d (limited to 'src/doc_reform/meta') diff --git a/src/doc_reform/meta/conf_make_meta_json.d b/src/doc_reform/meta/conf_make_meta_json.d deleted file mode 100644 index eca4a7d..0000000 --- a/src/doc_reform/meta/conf_make_meta_json.d +++ /dev/null @@ -1,695 +0,0 @@ -/+ -- Name: 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 - 2024 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/] - -+/ -/++ - json headers
- extract json header return json -+/ -module doc_reform.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 - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json, - doc_reform.meta.defaults, - doc_reform.meta.rgx; - ConfComposite _struct_composite; - auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) { - mixin spineRgxIn; - static auto rgx = RgxI(); - debug (json) { - writeln(">> --------------------------- >>"); - foreach (tag0; _json.object.byKeyValue) { - if (tag0.value.stringof == "string") { - writeln(tag0.key, ": ", tag0.value); - } else { // writeln(tag0.key, ":"); - foreach (tag1; tag0.value.object.byKeyValue) { - writeln(tag0.key, ":", tag1.key, ": ", tag1.value); - } - } - } - writeln("<< --------------------------- <<"); - } - confCompositeMakeBuild _mk; - /+ make ------------------------------------------------------------------- +/ - if ("make" in _json.object) { - if ("doc_type" in _json.object["make"] - && (_json.object["make"]["doc_type"].type().to!string == "string") - ) { - _struct_composite.make_str.doc_type = _json.object["make"]["doc_type"].str; - } - if ("breaks" in _json.object["make"] - && (_json.object["make"]["breaks"].type().to!string == "string") - ) { - _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; - } - if ("bold" in _json.object["make"] - && (_json.object["make"]["bold"].type().to!string == "string") - ) { - _struct_composite.make_str.bold = _json.object["make"]["bold"].str; - } - if ("cover_image" in _json.object["make"] - && (_json.object["make"]["cover_image"].type().to!string == "string") - ) { - _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; - } - if ("css" in _json.object["make"] - && (_json.object["make"]["css"].type().to!string == "string") - ) { - _struct_composite.make_str.css = _json.object["make"]["css"].str; - } - if ("emphasis" in _json.object["make"] - && (_json.object["make"]["emphasis"].type().to!string == "string") - ) { - _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; - } - if ("footer" in _json.object["make"]) { - if (_json.object["make"]["footer"].type().to!string == "string") { - char[][] __match_footer_array - = (cast(char[]) _json.object["make"]["footer"].str) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.footer = __match_footer_array.to!(string[]); - } else if (_json.object["make"]["footer"].type().to!string == "array") { - string[] _match_footer_array; - foreach (_match_heading; _json.object["make"]["footer"].arrayNoRef) { - _match_footer_array ~= _match_heading.str; - } - _struct_composite.make_str.footer = _match_footer_array; - } - } - if ("headings" in _json.object["make"]) { - if (_json.object["make"]["headings"].type().to!string == "string") { - char[][] __match_headings_array - = (cast(char[]) _json.object["make"]["headings"].str) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.headings = __match_headings_array.to!(string[]); - } else if (_json.object["make"]["headings"].type().to!string == "array") { - string[] _match_headings_array; - foreach (_match_heading; _json.object["make"]["headings"].arrayNoRef) { - _match_headings_array ~= _match_heading.str; - } - _struct_composite.make_str.headings = _match_headings_array; - } - } - if ("home_button_image" in _json.object["make"]) { - if (_json.object["make"]["home_button_image"].type().to!string == "string") { - char[][] __match_home_button_image_array - = (cast(char[]) _json.object["make"]["home_button_image"].str) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.home_button_image = __match_home_button_image_array.to!(string[]); - } else if (_json.object["make"]["home_button_image"].type().to!string == "array") { - string[] _match_home_button_image_array; - foreach (_match_heading; _json.object["make"]["home_button_image"].arrayNoRef) { - _match_home_button_image_array ~= _match_heading.str; - } - _struct_composite.make_str.home_button_image = _match_home_button_image_array; - } - } - if ("home_button_text" in _json.object["make"]) { - if (_json.object["make"]["home_button_text"].type().to!string == "string") { - _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; - } else if (_json.object["make"]["home_button_text"].type().to!string == "array") { - string[] _match_home_button_text_array; - foreach (_match_heading; _json.object["make"]["home_button_text"].arrayNoRef) { - _match_home_button_text_array ~= _match_heading.str; - } - string _match_home_button_text_str = (_match_home_button_text_array).join("; "); - _struct_composite.make_str.home_button_text = _match_home_button_text_str; - } - } - if ("italics" in _json.object["make"] - && (_json.object["make"]["italics"].type().to!string == "string") - ) { - _struct_composite.make_str.italics = _json.object["make"]["italics"].str; - } - if ("auto_num_top_at_level" in _json.object["make"] // str == A - D, 1 - 4 - && (_json.object["make"]["auto_num_top_at_level"].type().to!string == "string") - ) { - _struct_composite.make_str.auto_num_top_at_level = _json.object["make"]["auto_num_top_at_level"].str; - switch (_json.object["make"]["auto_num_top_at_level"].str) { - case "A": - break; - case "B": _struct_composite.make_str.auto_num_top_lv = 1; - break; - case "C": _struct_composite.make_str.auto_num_top_lv = 2; - break; - case "D": _struct_composite.make_str.auto_num_top_lv = 3; - break; - case "1": _struct_composite.make_str.auto_num_top_lv = 4; - break; - case "2": _struct_composite.make_str.auto_num_top_lv = 5; - break; - case "3": _struct_composite.make_str.auto_num_top_lv = 6; - break; - case "4": _struct_composite.make_str.auto_num_top_lv = 7; - break; - default: - break; - } - } - if ("auto_num_depth" in _json.object["make"]) { - if (_json.object["make"]["auto_num_depth"].type().to!string == "int") { // TODO watch this match - _struct_composite.make_str.auto_num_depth = _json.object["make"]["auto_num_depth"].integer.to!int; - } else if (_json.object["make"]["auto_num_depth"].type().to!string == "string") { - _struct_composite.make_str.auto_num_depth = _json.object["make"]["auto_num_depth"].str.to!int; - } - } - if ("substitute" in _json.object["make"]) { - string[][] _sub; - if (_json.object["make"]["substitute"].type().to!string == "array") { - if (_json.object["make"]["substitute"][0].type().to!string == "array") { - foreach (substitute_pair; _json.object["make"]["substitute"].arrayNoRef) { - if ((substitute_pair.type().to!string) == "array") { - if (!empty(substitute_pair[0].str) && !empty(substitute_pair[1].str)) { - _sub ~= [ substitute_pair[0].str, substitute_pair[1].str]; - } - } - } - } else if (_json.object["make"]["substitute"][0].type().to!string == "string") { - if (!empty(_json.object["make"]["substitute"][0].str) && !empty(_json.object["make"]["substitute"][1].str)) { - _sub = [[_json.object["make"]["substitute"][0].str, _json.object["make"]["substitute"][1].str]]; - } - } - } - // writeln(_sub); - _struct_composite.make_str.substitute = _sub; - } - if ("texpdf_font" in _json.object["make"] - && (_json.object["make"]["texpdf_font"].type().to!string == "string") - ) { - _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; - } - _struct_composite.make.bold = _mk.bold(_struct_composite.make_str.bold); - _struct_composite.make.breaks = _mk.breaks(_struct_composite.make_str.breaks); - _struct_composite.make.cover_image = _mk.cover_image(_struct_composite.make_str.cover_image); - _struct_composite.make.css = _mk.css(_struct_composite.make_str.css); - _struct_composite.make.emphasis = _mk.emphasis(_struct_composite.make_str.emphasis); - _struct_composite.make.footer = _mk.footer(_struct_composite.make_str.footer); - _struct_composite.make.headings = _mk.headings(_struct_composite.make_str.headings); - _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); - _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); - _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); - _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); - _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); - _struct_composite.make.auto_num_depth = _mk.auto_num_depth(_struct_composite.make_str.auto_num_depth); - _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); - _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); - } - /+ conf ------------------------------------------------------------------- +/ - if ("webserv" in _json.object) { - if ("data_root_url" in _json.object["webserv"] - && (_json.object["webserv"]["data_root_url"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_data_root_url = _json.object["webserv"]["data_root_url"].str; - if (auto m = _struct_composite.conf.w_srv_data_root_url.match(rgx.webserv_data_root_url)) { - _struct_composite.conf.w_srv_url_host = m.captures[2].to!string; - _struct_composite.conf.w_srv_url_doc_path = m.captures[3].to!string; - } - } - if ("images" in _json.object["webserv"] - && (_json.object["webserv"]["images"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_images = _json.object["webserv"]["images"].str; - } - if ("cgi" in _json.object["webserv"] - && (_json.object["webserv"]["cgi"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi = _json.object["webserv"]["cgi"].str; - } - if ("cgi_host" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_host"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi_host = _json.object["webserv"]["cgi_host"].str; - } - if ("cgi_host_path" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_host_path"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; - } - if ("cgi_port" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_port"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi_port = _json.object["webserv"]["cgi_port"].str; - } - if ("cgi_user" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_user"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi_user = _json.object["webserv"]["cgi_user"].str; - } - if ("cgi_file_links" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_file_links"].type().to!string == "string") - ) { - _struct_composite.conf.w_srv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; - } - } - if ("processing" in _json.object) { - if ("path" in _json.object["processing"] - && (_json.object["processing"]["path"].type().to!string == "string") - ) { - _struct_composite.conf.processing_path = _json.object["processing"]["path"].str; - } - if ("dir" in _json.object["processing"] - && (_json.object["processing"]["dir"].type().to!string == "string") - ) { - _struct_composite.conf.processing_dir = _json.object["processing"]["dir"].str; - } - if ("concord_max" in _json.object["processing"] - && (_json.object["processing"]["concord_max"].type().to!string == "string") - ) { - _struct_composite.conf.processing_concord_max = _json.object["processing"]["concord_max"].str; - } - } - if ("flag" in _json.object) { - if ("act0" in _json.object["flag"] - && (_json.object["flag"]["act0"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act0 = _json.object["flag"]["act0"].str; - } - if ("act1" in _json.object["flag"] - && (_json.object["flag"]["act1"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act1 = _json.object["flag"]["act1"].str; - } - if ("act2" in _json.object["flag"] - && (_json.object["flag"]["act2"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act2 = _json.object["flag"]["act2"].str; - } - if ("act3" in _json.object["flag"] - && (_json.object["flag"]["act3"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act3 = _json.object["flag"]["act3"].str; - } - if ("act4" in _json.object["flag"] - && (_json.object["flag"]["act4"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act4 = _json.object["flag"]["act4"].str; - } - if ("act5" in _json.object["flag"] - && (_json.object["flag"]["act5"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act5 = _json.object["flag"]["act5"].str; - } - if ("act6" in _json.object["flag"] - && (_json.object["flag"]["act6"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act6 = _json.object["flag"]["act6"].str; - } - if ("act7" in _json.object["flag"] - && (_json.object["flag"]["act7"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act7 = _json.object["flag"]["act7"].str; - } - if ("act8" in _json.object["flag"] - && (_json.object["flag"]["act8"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act8 = _json.object["flag"]["act8"].str; - } - if ("act9" in _json.object["flag"] - && (_json.object["flag"]["act9"].type().to!string == "string") - ) { - _struct_composite.conf.flag_act9 = _json.object["flag"]["act9"].str; - } - } - if ("default" in _json.object) { - if ("papersize" in _json.object["default"] - && (_json.object["default"]["papersize"].type().to!string == "string") - ) { - _struct_composite.conf.set_papersize = _json.object["default"]["papersize"].str; - } - if ("text_wrap" in _json.object["default"] - && (_json.object["default"]["text_wrap"].type().to!string == "string") - ) { - _struct_composite.conf.set_text_wrap = _json.object["default"]["text_wrap"].str; - } - if ("emphasis" in _json.object["default"] - && (_json.object["default"]["emphasis"].type().to!string == "string") - ) { - _struct_composite.conf.set_emphasis = _json.object["default"]["emphasis"].str; - } - if ("language" in _json.object["default"] - && (_json.object["default"]["language"].type().to!string == "string") - ) { - _struct_composite.conf.set_language = _json.object["default"]["language"].str; - } - if ("digest" in _json.object["default"] - && (_json.object["default"]["digest"].type().to!string == "string") - ) { - _struct_composite.conf.set_digest = _json.object["default"]["digest"].str; - } - } - if ("search" in _json.object) { - if ("flag" in _json.object["search"] - && (_json.object["search"]["flag"].type().to!string == "string") - ) { - _struct_composite.conf.search_flag = _json.object["search"]["flag"].str; - } - if ("action" in _json.object["search"] - && (_json.object["search"]["action"].type().to!string == "string") - ) { - _struct_composite.conf.search_action = _json.object["search"]["action"].str; - } - if ("db" in _json.object["search"] - && (_json.object["search"]["db"].type().to!string == "string") - ) { - _struct_composite.conf.search_db = _json.object["search"]["db"].str; - } - if ("title" in _json.object["search"] - && (_json.object["search"]["title"].type().to!string == "string") - ) { - _struct_composite.conf.search_title = _json.object["search"]["title"].str; - } - } - /+ meta ------------------------------------------------------------------- +/ - if (_struct_composite.meta.creator_author.empty) { - if ("creator" in _json.object) { - if ("author" in _json.object["creator"] - && (_json.object["creator"]["author"].type().to!string == "string") - ) { - _struct_composite.meta.creator_author = _json.object["creator"]["author"].str; - } - if ("email" in _json.object["creator"] - && (_json.object["creator"]["email"].type().to!string == "string") - ) { - _struct_composite.meta.creator_author_email = _json.object["creator"]["email"].str; - } - if ("illustrator" in _json.object["creator"] - && (_json.object["creator"]["illustrator"].type().to!string == "string") - ) { - _struct_composite.meta.creator_illustrator = _json.object["creator"]["illustrator"].str; - } - if ("translator" in _json.object["creator"] - && (_json.object["creator"]["translator"].type().to!string == "string") - ) { - _struct_composite.meta.creator_translator = _json.object["creator"]["translator"].str; - } - } - string[] author_arr; - string[][string] authors_hash_arr = [ "first" : [], "last" : [], "full" : [], "last_first" : [], "as_input" : [] ]; - string[] authors_raw_arr - = _struct_composite.meta.creator_author.split(rgx.arr_delimiter); - auto _lastname = appender!(char[])(); - foreach (author_raw; authors_raw_arr) { - if (auto m = author_raw.match(rgx.raw_author_munge)) { - author_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - authors_hash_arr["first"] ~= author_raw.replace(rgx.raw_author_munge, "$2"); - authors_hash_arr["last"] ~= author_raw.replace(rgx.raw_author_munge, "$1"); - authors_hash_arr["full"] ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - (m.captures[1]).map!toUpper.copy(_lastname); - authors_hash_arr["last_first"] ~= _lastname.data.to!string ~ ", " ~ m.captures[2]; - _lastname = appender!(char[])(); - } { - author_arr ~= author_raw; - authors_hash_arr["last"] ~= author_raw; - authors_hash_arr["full"] ~= author_raw; - authors_hash_arr["last_first"] ~= author_raw; - } - authors_hash_arr["as_input"] ~= author_raw; - } - _struct_composite.meta.creator_author_arr = author_arr; - _struct_composite.meta.creator_author = author_arr.join(", ").chomp.chomp; - _struct_composite.meta.creator_author_surname = (authors_hash_arr["last"].length > 0) ? authors_hash_arr["last"][0] : ""; - string _author_name_last_first = authors_hash_arr["last_first"].join("; ").chomp.chomp; - _struct_composite.meta.creator_author_surname_fn = (_author_name_last_first.length > 0) - ? _author_name_last_first - : authors_hash_arr["as_input"].join("; ").chomp.chomp; - } - if (_struct_composite.meta.title_main.empty) { - if ("title" in _json.object) { - if ((_json.object["title"].type().to!string) == "string") { - _struct_composite.meta.title_main = _json.object["title"].str; - } else { - if ("edition" in _json.object["title"] - && (_json.object["title"]["edition"].type().to!string == "string") - ) { - _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; - } - if ("full" in _json.object["title"] - && (_json.object["title"]["full"].type().to!string == "string") - ) {} - if ("language" in _json.object["title"] - && (_json.object["title"]["language"].type().to!string == "string") - ) { - _struct_composite.meta.title_language = _json.object["title"]["language"].str; - } - if ("main" in _json.object["title"] - && (_json.object["title"]["main"].type().to!string == "string") - ) { - _struct_composite.meta.title_main = _json.object["title"]["main"].str; - } else if ("title" in _json.object["title"] - && (_json.object["title"]["title"].type().to!string == "string") - ) { - _struct_composite.meta.title_main = _json.object["title"]["title"].str; - } - if ("note" in _json.object["title"] - && (_json.object["title"]["note"].type().to!string == "string") - ) { - _struct_composite.meta.title_note = _json.object["title"]["note"].str; - } - if ("sub" in _json.object["title"] - && (_json.object["title"]["sub"].type().to!string == "string") - ) { - _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; - } - if ("subtitle" in _json.object["title"] - && (_json.object["title"]["subtitle"].type().to!string == "string") - ) { - _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; - } - } - } - if ((!(_struct_composite.meta.title_subtitle.empty)) - && (_struct_composite.meta.title_sub.empty)) { - _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; - } - _struct_composite.meta.title_full = (_struct_composite.meta.title_sub.empty) - ? _struct_composite.meta.title_main - : format( - "%s - %s", - _struct_composite.meta.title_main, - _struct_composite.meta.title_sub, - ); - } - if ("classify" in _json.object) { - if ("dewey" in _json.object["classify"] - && (_json.object["classify"]["dewey"].type().to!string == "string") - ) { - _struct_composite.meta.classify_dewey = _json.object["classify"]["dewey"].str; - } - if ("keywords" in _json.object["classify"] - && (_json.object["classify"]["keywords"].type().to!string == "string") - ) { - _struct_composite.meta.classify_keywords = _json.object["classify"]["keywords"].str; - } - if ("loc" in _json.object["classify"] - && (_json.object["classify"]["loc"].type().to!string == "string") - ) { - _struct_composite.meta.classify_loc = _json.object["classify"]["loc"].str; - } - if ("subject" in _json.object["classify"] - && (_json.object["classify"]["subject"].type().to!string == "string") - ) { - _struct_composite.meta.classify_subject = _json.object["classify"]["subject"].str; - } - if ("topic_register" in _json.object["classify"] - && (_json.object["classify"]["topic_register"].type().to!string == "string") - ) { - _struct_composite.meta.classify_topic_register = _json.object["classify"]["topic_register"].str.strip; - string[] main_topics_ = _struct_composite.meta.classify_topic_register.strip.split(rgx.topic_register_main_terms_split); - string[] topics; - string topics_tmp; - string[] multiple_sub_terms; - foreach (mt; main_topics_) { - topics_tmp = mt.replaceAll(rgx.topic_register_main_term_plus_rest_split, mkup.sep); - if (auto m = topics_tmp.match(rgx.topic_register_multiple_sub_terms_split)) { - multiple_sub_terms = m.captures[1].split(rgx.topic_register_sub_terms_split); - foreach (subterm; multiple_sub_terms) { - topics ~= m.captures.pre ~ mkup.sep ~ subterm; - } - } else { - topics ~= topics_tmp; - } - } - _struct_composite.meta.classify_topic_register_arr = topics; - } - } - if ("date" in _json.object) { - if ("added_to_site" in _json.object["date"] - && (_json.object["date"]["added_to_site"].type().to!string == "string") - ) { - _struct_composite.meta.date_added_to_site = _json.object["date"]["added_to_site"].str; - } - if ("available" in _json.object["date"] - && (_json.object["date"]["available"].type().to!string == "string") - ) { - _struct_composite.meta.date_available = _json.object["date"]["available"].str; - } - if ("created" in _json.object["date"] - && (_json.object["date"]["created"].type().to!string == "string") - ) { - _struct_composite.meta.date_created = _json.object["date"]["created"].str; - } - if ("issued" in _json.object["date"] - && (_json.object["date"]["issued"].type().to!string == "string") - ) { - _struct_composite.meta.date_issued = _json.object["date"]["issued"].str; - } - if ("modified" in _json.object["date"] - && (_json.object["date"]["modified"].type().to!string == "string") - ) { - _struct_composite.meta.date_modified = _json.object["date"]["modified"].str; - } - if ("published" in _json.object["date"] - && (_json.object["date"]["published"].type().to!string == "string") - ) { - _struct_composite.meta.date_published = _json.object["date"]["published"].str; - } - if ("valid" in _json.object["date"] - && (_json.object["date"]["valid"].type().to!string == "string") - ) { - _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; - } - _struct_composite.meta.language_document_char = _manifested.src.language; - } - if ("links" in _json.object) {} - if ("notes" in _json.object) { - if ("abstract" in _json.object["notes"] - && (_json.object["notes"]["abstract"].type().to!string == "string") - ) { - _struct_composite.meta.notes_abstract = _json.object["notes"]["abstract"].str; - } - if ("description" in _json.object["notes"] - && (_json.object["notes"]["description"].type().to!string == "string") - ) { - _struct_composite.meta.notes_description = _json.object["notes"]["description"].str; - } - } - if ("original" in _json.object) { - if ("language" in _json.object["original"] - && (_json.object["original"]["language"].type().to!string == "string") - ) { - _struct_composite.meta.original_language = _json.object["original"]["language"].str; - } - if ("language_char" in _json.object["original"] - && (_json.object["original"]["language_char"].type().to!string == "string") - ) { - _struct_composite.meta.original_language_char = _json.object["original"]["language_char"].str; - } - if ("source" in _json.object["original"] - && (_json.object["original"]["source"].type().to!string == "string") - ) { - _struct_composite.meta.original_source = _json.object["original"]["source"].str; - } - if ("title" in _json.object["original"] - && (_json.object["original"]["title"].type().to!string == "string") - ) { - _struct_composite.meta.original_title = _json.object["original"]["title"].str; - } - } - if ("publisher" in _json.object) {} - if ("rights" in _json.object) { - if ("copyright" in _json.object["rights"] - && (_json.object["rights"]["copyright"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright = _json.object["rights"]["copyright"].str; - } - if ("copyright_text" in _json.object["rights"] - && (_json.object["rights"]["copyright_text"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_text = _json.object["rights"]["copyright_text"].str; - } - if ("copyright_audio" in _json.object["rights"] - && (_json.object["rights"]["copyright_audio"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_audio = _json.object["rights"]["copyright_audio"].str; - } - if ("copyright_cover" in _json.object["rights"] - && (_json.object["rights"]["copyright_cover"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_cover = _json.object["rights"]["copyright_cover"].str; - } - if ("copyright_illustrations" in _json.object["rights"] - && (_json.object["rights"]["copyright_illustrations"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_illustrations = _json.object["rights"]["copyright_illustrations"].str; - } - if ("copyright_photographs" in _json.object["rights"] - && (_json.object["rights"]["copyright_photographs"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_photographs = _json.object["rights"]["copyright_photographs"].str; - } - if ("copyright_translation" in _json.object["rights"] - && (_json.object["rights"]["copyright_translation"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_translation = _json.object["rights"]["copyright_translation"].str; - } - if ("copyright_video" in _json.object["rights"] - && (_json.object["rights"]["copyright_video"].type().to!string == "string") - ) { - _struct_composite.meta.rights_copyright_video = _json.object["rights"]["copyright_video"].str; - } - if ("license" in _json.object["rights"] - && (_json.object["rights"]["license"].type().to!string == "string") - ) { - _struct_composite.meta.rights_license = _json.object["rights"]["license"].str; - } - } - return _struct_composite; - } -} diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d deleted file mode 100644 index b80bb45..0000000 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ /dev/null @@ -1,316 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.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 - doc_reform.meta.defaults, - doc_reform.meta.rgx_yaml, - doc_reform.meta.rgx; -mixin spineRgxIn; -static auto rgx = RgxI(); -mixin spineRgxYamlTags; -static auto rgx_y = RgxYaml(); -mixin InternalMarkup; -static auto mkup = InlineMarkup(); -string url_markup(string line) { - string line_ = line - .replaceAll( - rgx.smid_inline_link_markup_regular, - ("$1" - ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c - ~ mkup.url_o ~ "$3" ~ mkup.url_c - ) // ("$1{ $2 }$3$4") - ) - .replaceAll( - rgx.smid_inline_link_naked_url, - ("$1" - ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ) // ("$1{ $2 }$2$3") - ) - .replaceAll( - rgx.arr_delimiter, - mkup.br_line - ); - return line_; -} -struct ConfCompositeMakeStr { - string doc_type = "book"; // book, article - string breaks; - string bold; - string cover_image; - string css; - string emphasis; - string[] footer; - string[] headings; - string[] home_button_image; - string home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├" - ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├" - ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├"; - string italics; - string auto_num_top_at_level; - int auto_num_top_lv = 9; - int auto_num_depth = 2; - string[][] substitute; - string texpdf_font; -} -@trusted struct confCompositeMakeBuild { - string[] bold(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "*{$1}*", "$1"]; - } - return _out; - } - string doc_type(string _mk) { - return _mk; - } - string breaks(string _mk) { - return _mk; - } - string cover_image(string _mk) { - return _mk; - } - string css(string _mk) { - return _mk; - } - string[] emphasis(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "!{$1}!", "$1" ]; - } - return _out; - } - string[] footer(string[] _mk) { - string line_; - string[] _mk2; - foreach (line; _mk) { - _mk2 ~= url_markup(line); - } - return _mk2; - } - string[] headings(string[] _mk) { - return _mk; - } - string[] home_button_image(string[] _mk) { - return _mk; - } - string home_button_text(string _mk) { - return url_markup(_mk); - } - string[] italics(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "/{$1}/", "$1" ]; - } - return _out; - } - string auto_num_top_at_level(string _mk) { - return _mk; - } - int auto_num_top_lv(int _mk) { - return _mk; - } - int auto_num_depth(int _mk) { - return _mk; - } - string[][] substitute(string[][] _mk) { - return _mk; - } - string texpdf_font(string _mk) { - return _mk; - } -} -struct ConfCompositeMakeInit { - string doc_type; - string breaks; - string cover_image; - string css; - string[] bold; - string[] emphasis; - string[] footer; - string[] headings; - string[] home_button_image; - string home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├" - ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├" - ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├"; - string[] italics; - string auto_num_top_at_level; - int auto_num_top_lv = 9; - int auto_num_depth = 2; - string[][] substitute; - string texpdf_font; -} -struct ConfCompositeSiteLocal { - string w_srv_http; - string w_srv_host; - string w_srv_data_http; // if not set same as webserv_http - string w_srv_data_host; // if not set same as webserv_host - string w_srv_data_root_part; - string w_srv_data_root_url; - string w_srv_data_root_url_html; - string w_srv_data_root_path; - string w_srv_images_root_part; - // string w_srv_url_doc_path; - string w_srv_cgi_search_form_title; - string w_srv_cgi_http; // if not set same as webserv_http - string w_srv_cgi_host; // if not set same as webserv_host - string w_srv_cgi_bin_subpath; - string w_srv_cgi_bin_path; - string w_srv_cgi_search_script; - string w_srv_cgi_search_script_raw_fn_d; - string w_srv_cgi_port; - string w_srv_cgi_user; - string w_srv_cgi_action; - string w_srv_cgi_bin_url; - string w_srv_db_sqlite_filename; - string w_srv_db_sqlite_path; - // string w_srv_db_pg; - string w_srv_db_pg_table; - string w_srv_db_pg_user; - // string webserv_cgi_file_links; - string output_path; - string processing_path; - string processing_dir; - string processing_concord_max; - string flag_act0; - string flag_act1; - string flag_act2; - string flag_act3; - string flag_act4; - string flag_act5; - string flag_act6; - string flag_act7; - string flag_act8; - string flag_act9; - string[] set_papersize; - string set_text_wrap; - string set_emphasis; - string set_language; - string set_digest; - string permission_share_source; - string search_flag; - string search_action; - string search_db; - string search_title; -} -struct MetaComposite { - string classify_dewey; - string classify_keywords; - string classify_loc; - string classify_subject; - string classify_topic_register; - string[] classify_topic_register_arr; - string[] classify_topic_register_expanded_arr; // experimental use in sqlite topics table - string[] creator_author_arr; - string creator_author; - string creator_author_surname_fn; - string creator_author_surname; - string creator_author_email; - string creator_illustrator; - string creator_translator; - string date_added_to_site; - string date_available; - string date_created; - string date_issued; - string date_modified; - string date_published; - string date_valid; - string identifier_isbn; - string identifier_oclc; - string identifier_pg; - string language_document; - string language_document_char; - string links; - string notes_abstract; - string notes_description; - string notes_summary; - string original_language; - string original_language_char; - string original_publisher; - string original_source; - string original_title; - string publisher; - string rights_copyright; - string rights_copyright_audio; - string rights_copyright_cover; - string rights_copyright_illustrations; - string rights_copyright_photographs; - string rights_copyright_text; - string rights_copyright_translation; - string rights_copyright_video; - string rights_license; - string title_edition; - string title_full; - string title_language; - string title_main; - string title_note; - string title_short; - string title_sub; - string title_subtitle; -} -struct ConfComposite { - MetaComposite meta; - ConfCompositeMakeInit make; - ConfCompositeMakeStr make_str; - ConfCompositeSiteLocal conf; -} -JSONValue config_jsonstr = `{ -}`; diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d deleted file mode 100644 index 9bc6311..0000000 --- a/src/doc_reform/meta/conf_make_meta_yaml.d +++ /dev/null @@ -1,1277 +0,0 @@ -/+ -- Name: 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 - 2024 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/] - -+/ -/++ - yaml headers
- extract yaml header return struct -+/ -module doc_reform.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 - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.defaults, - doc_reform.meta.rgx_yaml, - doc_reform.meta.rgx; - ConfComposite _struct_composite; - @system auto contentYAMLtoSpineStruct(C,Y,M,O,Cfg)( - C _struct_composite, - Y _yaml, - M _manifested, - O _opt_action, - Cfg _cfg, - string _identifier - ) { - mixin spineRgxIn; - static auto rgx = RgxI(); - mixin spineRgxYamlTags; - static auto rgx_y = RgxYaml(); - string check_input_markup()( - string _txt, - ) { - _txt = _txt - .replaceAll(regex(r"\\"), mkup.br_line_inline) - .strip; - return _txt; - } - confCompositeMakeBuild _mk; - if (_identifier != "header") { // called only once per run anyway - /+ conf ------------------------------------------------------------------- +/ - /+ - _cfg. build defaults (else program runtime defaults) - local_site_configuration defaults - command line overrides - +/ - { - if (_opt_action.webserver_http.length > 0) { - _struct_composite.conf.w_srv_http - = _opt_action.webserver_http; - } else { - _struct_composite.conf.w_srv_http - = (_cfg.http_request_type.empty) - ? "http" - : _cfg.http_request_type; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("http" in _yaml["webserv"] - && _yaml["webserv"]["http"].type.string - && _yaml["webserv"]["http"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_http - = _yaml["webserv"]["http"].get!string; - } - } - } - if (_opt_action.cgi_search_title.length > 0) { - _struct_composite.conf.w_srv_cgi_search_form_title - = _opt_action.cgi_search_title; - } else { - _struct_composite.conf.w_srv_cgi_search_form_title - = (_cfg.cgi_search_form_title.empty) - ? "≅ SiSU spine search form" - : _cfg.cgi_search_form_title; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("cgi_search_form_title" in _yaml["webserv"] - && _yaml["webserv"]["cgi_search_form_title"].type.string - && _yaml["webserv"]["cgi_search_form_title"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_search_form_title - = _yaml["webserv"]["cgi_search_form_title"].get!string; - } - } - } - if (_opt_action.cgi_sqlite_search_filename.length > 0) { - _struct_composite.conf.w_srv_cgi_search_script - = _opt_action.cgi_sqlite_search_filename; - } else { - _struct_composite.conf.w_srv_cgi_search_script - = (_cfg.cgi_filename.empty) - ? "spine_search" - : _cfg.cgi_filename; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("cgi_search_script" in _yaml["webserv"] - && _yaml["webserv"]["cgi_search_script"].type.string - && _yaml["webserv"]["cgi_search_script"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_search_script - = _yaml["webserv"]["cgi_search_script"].get!string; - } - } - } - if (_opt_action.sqliteDB_filename.length > 0) { - _struct_composite.conf.w_srv_db_sqlite_filename - = _opt_action.sqliteDB_filename; - } else { - _struct_composite.conf.w_srv_db_sqlite_filename - = (_cfg.db_sqlite_filename.empty) - ? "spine.search.db" - : _cfg.db_sqlite_filename; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("db_sqlite_filename" in _yaml["webserv"] - && _yaml["webserv"]["db_sqlite_filename"].type.string - && _yaml["webserv"]["db_sqlite_filename"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_db_sqlite_filename - = _yaml["webserv"]["db_sqlite_filename"].get!string; - } - } - } - if (_opt_action.sqliteDB_path.length > 0) { - _struct_composite.conf.w_srv_db_sqlite_path - = _opt_action.sqliteDB_path; - } else { - _struct_composite.conf.w_srv_db_sqlite_path - = (_cfg.db_sqlite_path.empty) - ? "/var/www/sqlite" - : _cfg.db_sqlite_path; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("db_sqlite_path" in _yaml["webserv"] - && _yaml["webserv"]["db_sqlite_path"].type.string - && _yaml["webserv"]["db_sqlite_path"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_db_sqlite_path - = _yaml["webserv"]["db_sqlite_path"].get!string; - } - } - } - if (_opt_action.cgi_url_action.length > 0) { - _struct_composite.conf.w_srv_cgi_action - = _opt_action.cgi_url_action; - } else { - _struct_composite.conf.w_srv_cgi_action - = (_cfg.www_url_doc_root.empty) - ? "http://locahost" // "https://sisudoc.org" - : _cfg.www_url_doc_root; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("cgi_action" in _yaml["webserv"] - && _yaml["webserv"]["cgi_action"].type.string - && _yaml["webserv"]["cgi_action"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_action - = _yaml["webserv"]["cgi_action"].get!string; - } else if (_opt_action.cgi_sqlite_search_filename.length > 0) { - _struct_composite.conf.w_srv_cgi_action - = _struct_composite.conf.w_srv_cgi_bin_url ~ "/" ~ _opt_action.cgi_sqlite_search_filename; - } - } - } - if (!(_struct_composite.conf.output_path)) { - _struct_composite.conf.output_path = ((_manifested.output.path).asNormalizedPath).array; - } { - if (_opt_action.output_dir_set.length > 0) { - _struct_composite.conf.output_path - = (_opt_action.output_dir_set.asNormalizedPath).array; - } else { - _struct_composite.conf.output_path - = (_cfg.processing_path_doc_root.empty) - ? "/srv/www/spine" - : _cfg.processing_path_doc_root; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if (_yaml["output"].type.mapping - && _yaml["output"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("path" in _yaml["output"] - && _yaml["output"]["path"].type.string - && _yaml["output"]["path"].tag.match(rgx_y.yaml_tag_is_str) - ) { - if (_manifested.output.path == _manifested.env.pwd - && _yaml["output"]["path"].get!string.length > 0 - ) { - _struct_composite.conf.output_path = (((_yaml["output"]["path"].get!string).expandTilde).asNormalizedPath).array; - } - } - } - } - } - if (_opt_action.webserver_host_doc_root.length > 0) { // same as output_path immediately above, resolve FIX REMOVE - _struct_composite.conf.w_srv_data_root_path - = _opt_action.webserver_host_doc_root; - } else { - _struct_composite.conf.w_srv_data_root_path - = (_cfg.processing_path_doc_root.empty) - ? "/var/www/spine" - : _cfg.processing_path_doc_root; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("data_root_path" in _yaml["webserv"] - && _yaml["webserv"]["data_root_path"].type.string - && _yaml["webserv"]["data_root_path"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_data_root_path - = _yaml["webserv"]["data_root_path"].get!string; - } - } - } - } - if (_opt_action.cgi_bin_root.length > 0) { - _struct_composite.conf.w_srv_cgi_bin_path - = _opt_action.cgi_bin_root; - } else { - _struct_composite.conf.w_srv_cgi_bin_path - = (_cfg.cgi_bin_root.empty) - ? "/var/www/cgi/cgi-bin" - : _cfg.cgi_bin_root; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("cgi_bin_path" in _yaml["webserv"] - && _yaml["webserv"]["cgi_bin_path"].type.string - && _yaml["webserv"]["cgi_bin_path"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_bin_path - = _yaml["webserv"]["cgi_bin_path"].get!string; - } - } - } - { _struct_composite.conf.w_srv_data_root_part - = ""; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("data_root_part" in _yaml["webserv"] - && _yaml["webserv"]["data_root_part"].type.string - && _yaml["webserv"]["data_root_part"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_data_root_part = _yaml["webserv"]["data_root_part"].get!string; - } - } - } - { _struct_composite.conf.w_srv_images_root_part - = "image"; - if (("webserv" in _yaml && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { - if ("images_root_part" in _yaml["webserv"] - && _yaml["webserv"]["images_root_part"].type.string - && _yaml["webserv"]["images_root_part"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_images_root_part = _yaml["webserv"]["images_root_part"].get!string; - } - } - } - } - if (("webserv" in _yaml - && _yaml["webserv"].type.sequence) - && (_yaml["webserv"].type.mapping - && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) - ) { // cannot be used as is with opt_action FIX look at remaining, decide what to do later - if ("data_http" in _yaml["webserv"] - && _yaml["webserv"]["data_http"].type.string - && _yaml["webserv"]["data_http"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_data_http = _yaml["webserv"]["data_http"].get!string; - } - // if (_opt_action.*.length > 0) { - if ("cgi_http" in _yaml["webserv"] - && _yaml["webserv"]["cgi_http"].type.string - && _yaml["webserv"]["cgi_http"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_http = _yaml["webserv"]["cgi_http"].get!string; - } - // if (_opt_action.*.length > 0) { - if ("host" in _yaml["webserv"] - && _yaml["webserv"]["host"].type.string - && _yaml["webserv"]["host"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_host = _yaml["webserv"]["host"].get!string; - } - if ("data_root_url" in _yaml["webserv"] - && _yaml["webserv"]["data_root_url"].type.string - && _yaml["webserv"]["data_root_url"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; - _struct_composite.conf.w_srv_data_root_url_html = - _yaml["webserv"]["data_root_url"].get!string - ~ _struct_composite.conf.w_srv_data_root_part ~ "/" - ~ _manifested.src.language ~ "/" - ~ "html"; - } else { - _struct_composite.conf.w_srv_data_root_url = _struct_composite.conf.w_srv_data_root_part; - _struct_composite.conf.w_srv_data_root_url_html = - _struct_composite.conf.w_srv_data_root_part ~ "/" - ~ _manifested.src.language ~ "/" - ~ "html"; - } - if ("cgi_host" in _yaml["webserv"] - && _yaml["webserv"]["cgi_host"].type.string - && _yaml["webserv"]["cgi_host"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_host = _yaml["webserv"]["cgi_host"].get!string; - } else { // composite construct - _struct_composite.conf.w_srv_cgi_host = _struct_composite.conf.w_srv_host; - } - if ("cgi_bin_subpath" in _yaml["webserv"] - && _yaml["webserv"]["cgi_bin_subpath"].type.string - && _yaml["webserv"]["cgi_bin_subpath"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_bin_subpath = _yaml["webserv"]["cgi_bin_subpath"].get!string; - } - if ("cgi_port" in _yaml["webserv"] - && _yaml["webserv"]["cgi_port"].type.string - && _yaml["webserv"]["cgi_port"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_port = _yaml["webserv"]["cgi_port"].get!string; - } - if ("cgi_user" in _yaml["webserv"] - && _yaml["webserv"]["cgi_user"].type.string - && _yaml["webserv"]["cgi_user"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_user = _yaml["webserv"]["cgi_user"].get!string; - } - if ("cgi_bin_url" in _yaml["webserv"] - && _yaml["webserv"]["cgi_bin_url"].type.string - && _yaml["webserv"]["cgi_bin_url"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.w_srv_cgi_bin_url = _yaml["webserv"]["cgi_bin_url"].get!string; - } else { - _struct_composite.conf.w_srv_cgi_bin_url = - (_struct_composite.conf.w_srv_cgi_http.empty) - ? _struct_composite.conf.w_srv_http - :_struct_composite.conf.w_srv_cgi_http - ~ "://" - ~ (_struct_composite.conf.w_srv_cgi_host.empty) - ? _struct_composite.conf.w_srv_cgi_host - : _struct_composite.conf.w_srv_host - ~ _struct_composite.conf.w_srv_cgi_bin_subpath; - } - // if ("cgi_file_links" in _yaml["webserv"] - // && _yaml["webserv"]["cgi_file_links"].type.string - // && _yaml["webserv"]["cgi_file_links"].tag.match(rgx_y.yaml_tag_is_str) - // ) { - // _struct_composite.conf.w_srv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string; - // } - } - // make (in: conf, make, meta)? - if ("processing" in _yaml - && _yaml["processing"].type.sequence - ) { - if (_yaml["processing"].type.mapping - && _yaml["processing"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("concord_max" in _yaml["processing"] - && _yaml["processing"]["concord_max"].type.string - && _yaml["processing"]["concord_max"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.processing_concord_max = _yaml["processing"]["concord_max"].get!string; - } - } - } - if ("flag" in _yaml - && _yaml["flag"].type.sequence - ) { - if (_yaml["flag"].type.mapping - && _yaml["flag"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("act0" in _yaml["flag"] - && _yaml["flag"]["act0"].type.string - && _yaml["flag"]["act0"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act0 = _yaml["flag"]["act0"].get!string; - } - if ("act1" in _yaml["flag"] - && _yaml["flag"]["act1"].type.string - && _yaml["flag"]["act1"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act1 = _yaml["flag"]["act1"].get!string; - } - if ("act2" in _yaml["flag"] - && _yaml["flag"]["act2"].type.string - && _yaml["flag"]["act2"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act2 = _yaml["flag"]["act2"].get!string; - } - if ("act3" in _yaml["flag"] - && _yaml["flag"]["act3"].type.string - && _yaml["flag"]["act3"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act3 = _yaml["flag"]["act3"].get!string; - } - if ("act4" in _yaml["flag"] - && _yaml["flag"]["act4"].type.string - && _yaml["flag"]["act4"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act4 = _yaml["flag"]["act4"].get!string; - } - if ("act5" in _yaml["flag"] - && _yaml["flag"]["act5"].type.string - && _yaml["flag"]["act5"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act5 = _yaml["flag"]["act5"].get!string; - } - if ("act6" in _yaml["flag"] - && _yaml["flag"]["act6"].type.string - && _yaml["flag"]["act6"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act6 = _yaml["flag"]["act6"].get!string; - } - if ("act7" in _yaml["flag"] - && _yaml["flag"]["act7"].type.string - && _yaml["flag"]["act7"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act7 = _yaml["flag"]["act7"].get!string; - } - if ("act8" in _yaml["flag"] - && _yaml["flag"]["act8"].type.string - && _yaml["flag"]["act8"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act8 = _yaml["flag"]["act8"].get!string; - } - if ("act9" in _yaml["flag"] - && _yaml["flag"]["act9"].type.string - && _yaml["flag"]["act9"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.flag_act9 = _yaml["flag"]["act9"].get!string; - } - } - } - string[] selected_papersize(string _sizes_str) { - string[] _sizes = _sizes_str.split(regex(r"\s*,\s*")); - string[] _selected_sizes; - foreach (_size; _sizes) { - switch (_size) { - case "a4": - _selected_sizes ~= "a4.portrait"; - _selected_sizes ~= "a4.landscape"; - break; - case "a4.portrait": - _selected_sizes ~= _size; - break; - case "a4.landscape": - _selected_sizes ~= _size; - break; - case "b4": - _selected_sizes ~= "b4.portrait"; - _selected_sizes ~= "b4.landscape"; - break; - case "b4.portrait": - _selected_sizes ~= _size; - break; - case "b4.landscape": - _selected_sizes ~= _size; - break; - case "a5": - _selected_sizes ~= "a5.portrait"; - _selected_sizes ~= "a5.landscape"; - break; - case "a5.portrait": - _selected_sizes ~= _size; - break; - case "a5.landscape": - _selected_sizes ~= _size; - break; - case "letter": - _selected_sizes ~= "letter.portrait"; - _selected_sizes ~= "letter.landscape"; - break; - case "letter.portrait": - _selected_sizes ~= _size; - break; - case "letter.landscape": - _selected_sizes ~= _size; - break; - case "legal": - _selected_sizes ~= "legal.portrait"; - _selected_sizes ~= "legal.landscape"; - break; - case "legal.portrait": - _selected_sizes ~= _size; - break; - case "legal.landscape": - _selected_sizes ~= _size; - break; - default: break; - } - } - return _selected_sizes; - } - string _set_papersize; - if (_opt_action.latex_papersize.length > 0) { - _set_papersize - = _opt_action.latex_papersize; - } else { - _set_papersize - = (_cfg.default_papersize.empty) - ? "a4,letter.portrait" - : _cfg.default_papersize; - if ("papersize" in _yaml["default"] - && _yaml["default"]["papersize"].type.string - && _yaml["default"]["papersize"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _set_papersize - = _yaml["default"]["papersize"].get!string; - } - } - _struct_composite.conf.set_papersize = selected_papersize(_set_papersize); - if ( - "default" in _yaml - && _yaml["default"].type.sequence - && _yaml["default"].type.mapping - && _yaml["default"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("text_wrap" in _yaml["default"] - && _yaml["default"]["text_wrap"].type.string - && _yaml["default"]["text_wrap"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.set_text_wrap = _yaml["default"]["text_wrap"].get!string; - } - if ("emphasis" in _yaml["default"] - && _yaml["default"]["emphasis"].type.string - && _yaml["default"]["emphasis"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.set_emphasis = _yaml["default"]["emphasis"].get!string; - } - if ("language" in _yaml["default"] - && _yaml["default"]["language"].type.string - && _yaml["default"]["language"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.set_language = _yaml["default"]["language"].get!string; - } - if ("digest" in _yaml["default"] - && _yaml["default"]["digest"].type.string - && _yaml["default"]["digest"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.set_digest = _yaml["default"]["digest"].get!string; - } - } - if ("search" in _yaml - && _yaml["search"].type.sequence - ) { - if (_yaml["search"].type.mapping - && _yaml["search"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("flag" in _yaml["search"] - && _yaml["search"]["flag"].type.string - && _yaml["search"]["flag"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.search_flag = _yaml["search"]["flag"].get!string; - } - if ("action" in _yaml["search"] - && _yaml["search"]["action"].type.string - && _yaml["search"]["action"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.search_action = _yaml["search"]["action"].get!string; - } - if ("db" in _yaml["search"] - && _yaml["search"]["db"].type.string - && _yaml["search"]["db"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.search_db = _yaml["search"]["db"].get!string; - } - if ("title" in _yaml["search"] - && _yaml["search"]["title"].type.string - && _yaml["search"]["title"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.conf.search_title = _yaml["search"]["title"].get!string; - } - } - } - } else { - /+ make ------------------------------------------------------------------- +/ - if ("make" in _yaml - && _yaml["make"].type.sequence - ) { - if (_yaml["make"].type.mapping - && _yaml["make"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("doc_type" in _yaml["make"] - && _yaml["make"]["doc_type"].type.string - && _yaml["make"]["doc_type"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.doc_type = _yaml["make"]["doc_type"].get!string; - } - if ("breaks" in _yaml["make"] - && _yaml["make"]["breaks"].type.string - && _yaml["make"]["breaks"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.breaks = _yaml["make"]["breaks"].get!string; - } - if ("bold" in _yaml["make"] - && _yaml["make"]["bold"].type.string - && _yaml["make"]["bold"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.bold = _yaml["make"]["bold"].get!string; - } - if ("cover_image" in _yaml["make"] - && _yaml["make"]["cover_image"].type.string - && _yaml["make"]["cover_image"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.cover_image = _yaml["make"]["cover_image"].get!string; - } - if ("css" in _yaml["make"] - && _yaml["make"]["css"].type.string - && _yaml["make"]["css"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.css = _yaml["make"]["css"].get!string; - } - if ("emphasis" in _yaml["make"] - && _yaml["make"]["emphasis"].type.string - && _yaml["make"]["emphasis"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.emphasis = _yaml["make"]["emphasis"].get!string; - } - if ("footer" in _yaml["make"] - && _yaml["make"]["footer"].type.string - && _yaml["make"]["footer"].tag.match(rgx_y.yaml_tag_is_str) - ) { - char[][] __match_footer_array - = (cast(char[]) _yaml["make"]["footer"].get!string) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.footer = __match_footer_array.to!(string[]); - } - if ("headings" in _yaml["make"] - && _yaml["make"]["headings"].type.string - && _yaml["make"]["headings"].tag.match(rgx_y.yaml_tag_is_str) - ) { - char[][] __match_headings_array - = (cast(char[]) _yaml["make"]["headings"].get!string) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.headings = __match_headings_array.to!(string[]); - } else if ("headings" in _yaml["make"] - && _yaml["make"]["headings"].type.string - && _yaml["make"]["headings"].tag.match(rgx_y.yaml_tag_is_seq) - ) { - foreach(string identify_heading_level; _yaml["make"]["headings"]) { - _struct_composite.make_str.headings ~= identify_heading_level; - } - } - if ("home_button_image" in _yaml["make"] - && _yaml["make"]["home_button_image"].type.string - && _yaml["make"]["home_button_image"].tag.match(rgx_y.yaml_tag_is_str) - ) { - char[][] __match_home_button_image_array - = (cast(char[]) _yaml["make"]["home_button_image"].get!string) - .split(rgx.make_heading_delimiter); - _struct_composite.make_str.home_button_image = __match_home_button_image_array.to!(string[]); - } - if ("home_button_text" in _yaml["make"] - && _yaml["make"]["home_button_text"].type.string - && _yaml["make"]["home_button_text"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.home_button_text = _yaml["make"]["home_button_text"].get!string; - } else if ("home_button_text" in _yaml["make"] - && _yaml["make"]["home_button_text"].type.string - && _yaml["make"]["home_button_text"].tag.match(rgx_y.yaml_tag_is_seq) - ) { - _struct_composite.make_str.home_button_text = ""; - foreach(string hbt; _yaml["make"]["home_button_text"]) { - _struct_composite.make_str.home_button_text ~= hbt ~ "; "; - } - } - if ("italics" in _yaml["make"] - && _yaml["make"]["italics"].type.string - && _yaml["make"]["italics"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.italics = _yaml["make"]["italics"].get!string; - } - if ("auto_num_top_at_level" in _yaml["make"] - && _yaml["make"]["auto_num_top_at_level"].type.string - && _yaml["make"]["auto_num_top_at_level"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.make_str.auto_num_top_at_level = _yaml["make"]["auto_num_top_at_level"].get!string; - switch (_yaml["make"]["auto_num_top_at_level"].get!string) { - case "A": - break; - case "B": _struct_composite.make_str.auto_num_top_lv = 1; - break; - case "C": _struct_composite.make_str.auto_num_top_lv = 2; - break; - case "D": _struct_composite.make_str.auto_num_top_lv = 3; - break; - case "1": _struct_composite.make_str.auto_num_top_lv = 4; - break; - case "2": _struct_composite.make_str.auto_num_top_lv = 5; - break; - case "3": _struct_composite.make_str.auto_num_top_lv = 6; - break; - case "4": _struct_composite.make_str.auto_num_top_lv = 7; - break; - default: - break; - } - } - if ("auto_num_depth" in _yaml["make"] - && _yaml["make"]["auto_num_depth"].type.string - && _yaml["make"]["auto_num_depth"].tag.match(rgx_y.yaml_tag_is_int) - ) { // not sure implemented for documents - _struct_composite.make_str.auto_num_depth = _yaml["make"]["auto_num_depth"].get!int; - } else if ("auto_num_depth" in _yaml["make"] - && _yaml["make"]["auto_num_depth"].type.string - && _yaml["make"]["auto_num_depth"].tag.match(rgx_y.yaml_tag_is_str) - ) { // not sure implemented for documents - _struct_composite.make_str.auto_num_depth = _yaml["make"]["auto_num_depth"].get!int; - } - if ("texpdf_font" in _yaml["make"] - && _yaml["make"]["texpdf_font"].type.string - ) { - _struct_composite.make_str.texpdf_font = _yaml["make"]["texpdf_font"].get!string; - } - } - _struct_composite.make.doc_type = _mk.doc_type(_struct_composite.make_str.doc_type); - _struct_composite.make.breaks = _mk.breaks(_struct_composite.make_str.breaks); - _struct_composite.make.bold = _mk.bold(_struct_composite.make_str.bold); - _struct_composite.make.cover_image = _mk.cover_image(_struct_composite.make_str.cover_image); - _struct_composite.make.css = _mk.css(_struct_composite.make_str.css); - _struct_composite.make.emphasis = _mk.emphasis(_struct_composite.make_str.emphasis); - _struct_composite.make.footer = _mk.footer(_struct_composite.make_str.footer); - _struct_composite.make.headings = _mk.headings(_struct_composite.make_str.headings); - _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); - _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); - _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); - _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); - _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); - _struct_composite.make.auto_num_depth = _mk.auto_num_depth(_struct_composite.make_str.auto_num_depth); - _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); - _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); - } - /+ meta ------------------------------------------------------------------- +/ - if (_struct_composite.meta.creator_author.empty) { - if ("creator" in _yaml - && _yaml["creator"].type.sequence - ) { - if (_yaml["creator"].type.mapping - && _yaml["creator"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("author" in _yaml["creator"] - && _yaml["creator"]["author"].type.string - && _yaml["creator"]["author"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.creator_author = _yaml["creator"]["author"].get!string; - } - if ("email" in _yaml["creator"] - && _yaml["creator"]["email"].type.string - && _yaml["creator"]["email"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.creator_author_email = _yaml["creator"]["email"].get!string; - } - if ("illustrator" in _yaml["creator"] - && _yaml["creator"]["illustrator"].type.string - && _yaml["creator"]["illustrator"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.creator_illustrator = _yaml["creator"]["illustrator"].get!string; - } - if ("translator" in _yaml["creator"] - && _yaml["creator"]["translator"].type.string - && _yaml["creator"]["translator"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.creator_translator = _yaml["creator"]["translator"].get!string; - } - } else if (_yaml["creator"].type.string - && _yaml["creator"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.creator_author = _yaml["creator"].get!string; - } - } - string[] author_arr; - string[][string] authors_hash_arr = [ "first" : [], "last" : [], "full" : [], "last_first" : [], "as_input" : [] ]; - string[] authors_raw_arr - = _struct_composite.meta.creator_author.split(rgx.arr_delimiter); - auto _lastname = appender!(char[])(); - foreach (author_raw; authors_raw_arr) { - if (auto m = author_raw.match(rgx.raw_author_munge)) { - author_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - authors_hash_arr["first"] ~= author_raw.replace(rgx.raw_author_munge, "$2"); - authors_hash_arr["last"] ~= author_raw.replace(rgx.raw_author_munge, "$1"); - authors_hash_arr["full"] ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - (m.captures[1]).map!toUpper.copy(_lastname); - authors_hash_arr["last_first"] ~= _lastname.data.to!string ~ ", " ~ m.captures[2]; - _lastname = appender!(char[])(); - } else { - author_arr ~= author_raw; - authors_hash_arr["last"] ~= author_raw; - authors_hash_arr["full"] ~= author_raw; - authors_hash_arr["last_first"] ~= author_raw; - } - authors_hash_arr["as_input"] ~= author_raw; - } - _struct_composite.meta.creator_author_arr = author_arr; - _struct_composite.meta.creator_author = author_arr.join(", ").chomp.chomp; - _struct_composite.meta.creator_author_surname = (authors_hash_arr["last"].length > 0) ? authors_hash_arr["last"][0] : ""; - string _author_name_last_first = authors_hash_arr["last_first"].join("; ").chomp.chomp; - _struct_composite.meta.creator_author_surname_fn = (_author_name_last_first.length > 0) - ? _author_name_last_first - : authors_hash_arr["as_input"].join("; ").chomp.chomp; - } - if (_struct_composite.meta.title_main.empty) { - if ("title" in _yaml - && _yaml["title"].type.sequence - ) { - if (_yaml["title"].type.mapping - && _yaml["title"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("main" in _yaml["title"] - && _yaml["title"]["main"].type.string - && _yaml["title"]["main"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_main = _yaml["title"]["main"].get!string; - } else if ("title" in _yaml["title"] - && _yaml["title"]["title"].type.string - && _yaml["title"]["title"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_main = _yaml["title"]["title"].get!string; - } - if ("edition" in _yaml["title"] - && _yaml["title"]["edition"].type.string - && _yaml["title"]["edition"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_edition = _yaml["title"]["edition"].get!string; - } - if ("full" in _yaml["title"] - && _yaml["title"]["full"].type.string - && _yaml["title"]["full"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_full = _yaml["title"]["full"].get!string; - } - if ("language" in _yaml["title"] - && _yaml["title"]["language"].type.string - && _yaml["title"]["language"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_language = _yaml["title"]["language"].get!string; - } - if ("note" in _yaml["title"] - && _yaml["title"]["note"].type.string - && _yaml["title"]["note"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_note = _yaml["title"]["note"].get!string; - } - if ("subtitle" in _yaml["title"] - && _yaml["title"]["subtitle"].type.string - && _yaml["title"]["subtitle"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_subtitle = _yaml["title"]["subtitle"].get!string; - } else if ("sub" in _yaml["title"] - && _yaml["title"]["sub"].type.string - && _yaml["title"]["sub"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_subtitle = _yaml["title"]["sub"].get!string; - } - } else if ( - _yaml["title"].type.string - && _yaml["title"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.title_main = _yaml["title"].get!string; - } - } - _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; - if ((!(_struct_composite.meta.title_subtitle.empty)) - && (_struct_composite.meta.title_sub.empty)) { - _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; - } - _struct_composite.meta.title_full = (_struct_composite.meta.title_subtitle.empty) - ? _struct_composite.meta.title_main - : format( - "%s - %s", - _struct_composite.meta.title_main, - _struct_composite.meta.title_subtitle, - ); - } - if ("classify" in _yaml - && _yaml["classify"].type.sequence - ) { - if (_yaml["classify"].type.mapping - && _yaml["classify"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("dewey" in _yaml["classify"] - && _yaml["classify"]["dewey"].type.string - && _yaml["classify"]["dewey"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.classify_dewey = _yaml["classify"]["dewey"].get!string; - } - if ("loc" in _yaml["classify"] - && _yaml["classify"]["loc"].type.string - && _yaml["classify"]["loc"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.classify_loc = _yaml["classify"]["loc"].get!string; - } - if ("keywords" in _yaml["classify"] - && _yaml["classify"]["keywords"].type.string - && _yaml["classify"]["keywords"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.classify_keywords = _yaml["classify"]["keywords"].get!string; - } - if ("topic_register" in _yaml["classify"] - && _yaml["classify"]["topic_register"].type.string - && _yaml["classify"]["topic_register"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.classify_topic_register = _yaml["classify"]["topic_register"].get!string; - if (_struct_composite.meta.classify_topic_register.length > 0) { - auto wrds = ctRegex!(`([\wa-zA-Z(). -]+)`); // ctRegex!(`([(]?\w+[a-zA-Z(). -]*)+`); - auto mkp_delim = ctRegex!(`:([^:]+?)(;|$)`); - string _topic_register = _struct_composite.meta.classify_topic_register; - _topic_register = _topic_register - .replaceAll(wrds, "\"$1\"") - .replaceAll(mkp_delim, ":$1$2"); - } - string[] main_topics_ = _struct_composite.meta.classify_topic_register.strip.split(rgx.topic_register_main_terms_split); - string[] topics; - string topics_tmp; - string[] multiple_sub_terms; - foreach (mt; main_topics_) { - topics_tmp = mt.replaceAll(rgx.topic_register_main_term_plus_rest_split, mkup.sep); - if (auto m = topics_tmp.match(rgx.topic_register_multiple_sub_terms_split)) { - multiple_sub_terms = m.captures[1].split(rgx.topic_register_sub_terms_split); - foreach (subterm; multiple_sub_terms) { - topics ~= m.captures.pre ~ mkup.sep ~ subterm; - } - } else { - topics ~= topics_tmp; - } - } - _struct_composite.meta.classify_topic_register_arr = topics; - string[] topics_expanded; - if (_struct_composite.meta.classify_topic_register_arr.length > 0) { - foreach (i, topic; _struct_composite.meta.classify_topic_register_arr) { - string[] subject_tree = topic.split(mkup.sep); - if (topic.length > 0) { - topics_expanded ~= subject_tree.join(", "); - } - } - } - _struct_composite.meta.classify_topic_register_expanded_arr = topics_expanded; - // writeln("\n------\n", _struct_composite.meta.title_full); - // writeln(_struct_composite.meta.classify_topic_register); - // writeln(_struct_composite.meta.classify_topic_register_expanded_arr.sort.join("\n")); - // writeln(_struct_composite.meta.classify_topic_register_arr); - } - } - } - if ("date" in _yaml - && _yaml["date"].type.sequence - ) { - if (_yaml["date"].type.mapping - && _yaml["date"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("added_to_site" in _yaml["date"] - && _yaml["date"]["added_to_site"].type.string - && _yaml["date"]["added_to_site"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_added_to_site = _yaml["date"]["added_to_site"].get!string; - } - if ("available" in _yaml["date"] - && _yaml["date"]["available"].type.string - && _yaml["date"]["available"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_available = _yaml["date"]["available"].get!string; - } - if ("created" in _yaml["date"] - && _yaml["date"]["created"].type.string - && _yaml["date"]["created"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_created = _yaml["date"]["created"].get!string; - } - if ("issued" in _yaml["date"] - && _yaml["date"]["issued"].type.string - && _yaml["date"]["issued"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_issued = _yaml["date"]["issued"].get!string; - } - if ("modified" in _yaml["date"] - && _yaml["date"]["modified"].type.string - && _yaml["date"]["modified"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_modified = _yaml["date"]["modified"].get!string; - } - if ("published" in _yaml["date"] - && _yaml["date"]["published"].type.string - && _yaml["date"]["published"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_published = _yaml["date"]["published"].get!string; - } - if ("valid" in _yaml["date"] - && _yaml["date"]["valid"].type.string - && _yaml["date"]["valid"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.date_valid = _yaml["date"]["valid"].get!string; - } - } - } - _struct_composite.meta.language_document_char = _manifested.src.language; // move - if ("links" in _yaml) { - // if ("" in _yaml["links"]) { - // _struct_composite.meta.links_ = _yaml["links"][""].str; - // } - } - if ("notes" in _yaml - && _yaml["notes"].type.sequence - ) { - if (_yaml["notes"].type.mapping - && _yaml["notes"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("abstract" in _yaml["notes"] - && _yaml["notes"]["abstract"].type.string - && _yaml["notes"]["abstract"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.notes_abstract = _yaml["notes"]["abstract"].get!string; - } - if ("description" in _yaml["notes"] - && _yaml["notes"]["description"].type.string - && _yaml["notes"]["description"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.notes_description = _yaml["notes"]["description"].get!string; - } - if ("summary" in _yaml["notes"] - && _yaml["notes"]["summary"].type.string - && _yaml["notes"]["summary"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.notes_summary = _yaml["notes"]["summary"].get!string; - } - } - } - if ("original" in _yaml - && _yaml["original"].type.sequence - ) { - if (_yaml["original"].type.mapping - && _yaml["original"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("language" in _yaml["original"] - && _yaml["original"]["language"].type.string - && _yaml["original"]["language"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.original_language = _yaml["original"]["language"].get!string; - } - if ("language_char" in _yaml["original"] - && _yaml["original"]["language_char"].type.string - && _yaml["original"]["language_char"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.original_language_char = _yaml["original"]["language_char"].get!string; - } - if ("source" in _yaml["original"] - && _yaml["original"]["source"].type.string - && _yaml["original"]["source"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.original_source = _yaml["original"]["source"].get!string; - } - if ("title" in _yaml["original"] - && _yaml["original"]["title"].type.string - && _yaml["original"]["title"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.original_title = _yaml["original"]["title"].get!string; - } - } - } - if ("publisher" in _yaml) { - // if ("" in _yaml["publisher"]) { - // _struct_composite.meta.publisher = _yaml["publisher"][""].str; - // } - } - if ("rights" in _yaml - && _yaml["rights"].type.sequence - ) { - if (_yaml["rights"].type.mapping - && _yaml["rights"].tag.match(rgx_y.yaml_tag_is_map) - ) { - if ("copyright" in _yaml["rights"] - && _yaml["rights"]["copyright"].type.string - && _yaml["rights"]["copyright"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright = check_input_markup(_yaml["rights"]["copyright"].get!string); - } - if ("copyright_text" in _yaml["rights"] - && _yaml["rights"]["copyright_text"].type.string - && _yaml["rights"]["copyright_text"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_text = _yaml["rights"]["copyright_text"].get!string; - } - if ("copyright_audio" in _yaml["rights"] - && _yaml["rights"]["copyright_audio"].type.string - && _yaml["rights"]["copyright_audio"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_audio = _yaml["rights"]["copyright_audio"].get!string; - } - if ("copyright_cover" in _yaml["rights"] - && _yaml["rights"]["copyright_cover"].type.string - && _yaml["rights"]["copyright_cover"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_cover = _yaml["rights"]["copyright_cover"].get!string; - } - if ("copyright_illustrations" in _yaml["rights"] - && _yaml["rights"]["copyright_illustrations"].type.string - && _yaml["rights"]["copyright_illustrations"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_illustrations = _yaml["rights"]["copyright_illustrations"].get!string; - } - if ("copyright_photographs" in _yaml["rights"] - && _yaml["rights"]["copyright_photographs"].type.string - && _yaml["rights"]["copyright_photographs"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_photographs = _yaml["rights"]["copyright_photographs"].get!string; - } - if ("copyright_translation" in _yaml["rights"] - && _yaml["rights"]["copyright_translation"].type.string - && _yaml["rights"]["copyright_translation"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_translation = _yaml["rights"]["copyright_translation"].get!string; - } - if ("copyright_video" in _yaml["rights"] - && _yaml["rights"]["copyright_video"].type.string - && _yaml["rights"]["copyright_video"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_copyright_video = _yaml["rights"]["copyright_video"].get!string; - } - if ("license" in _yaml["rights"] - && _yaml["rights"]["license"].type.string - && _yaml["rights"]["license"].tag.match(rgx_y.yaml_tag_is_str) - ) { - _struct_composite.meta.rights_license = check_input_markup(_yaml["rights"]["license"].get!string); - } - } - } - } - return _struct_composite; - } -} -template configParseYAMLreturnSpineStruct() { - import dyaml; - import - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json; - mixin contentYAMLtoSpineStruct; - @system auto configParseYAMLreturnSpineStruct(T,CCm,M,O,Cfg)( - T _document_struct, - CCm _make_and_meta_struct, - M _manifested, - O _opt_action, - Cfg _cfg - ){ - Node _yaml; - if (_document_struct.content.length > 0) { - try { - _yaml = Loader.fromString(_document_struct.content).load(); - } catch (Throwable) { - import std.stdio; - writeln("ERROR failed to parse content as yaml: ", _document_struct.filename); - // writeln(_document_struct.content); - } - try { - _make_and_meta_struct - = contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, _cfg, _document_struct.filename); - } catch (Throwable) { - import std.stdio; - writeln("ERROR failed to convert yaml to struct: ", _document_struct.filename); - } - } - return _make_and_meta_struct; - } -} -template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { - import - std.exception, - std.regex, - std.stdio, - std.traits, - std.typecons, - std.utf, - std.conv : to; - import - dyaml; - import - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json, - doc_reform.meta.rgx_yaml, - doc_reform.meta.rgx; - mixin spineRgxIn; - mixin contentJSONtoSpineStruct; - static auto rgx = RgxI(); - mixin spineRgxYamlTags; - static auto rgx_y = RgxYaml(); - @system auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M,O,Cfg)( - Src header_src, - CCm _make_and_meta_struct, - M _manifested, - O _opt_action, - Cfg _cfg, - ) { - Node _yaml; - try { - _yaml = Loader.fromString(header_src).load(); - if (("title" in _yaml) && ("creator" in _yaml)) {} else { // need test for _yaml content (does not work) - writeln("ERROR failed to read document header, yaml header does not contain essential information related to title and author"); - } - return contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, _cfg, "header"); - } catch (Throwable) { - writeln("ERROR failed to read document header, header not parsed as yaml: ", _manifested.src.filename); - return _make_and_meta_struct; - } - } -} diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d deleted file mode 100644 index e3e2827..0000000 --- a/src/doc_reform/meta/defaults.d +++ /dev/null @@ -1,297 +0,0 @@ -/+ -- Name: 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 - 2024 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/] - -+/ -/++ - default settings -+/ -module doc_reform.meta.defaults; -@safe: -template spineNode() { - static string[string] node_metadata_heading_str() { - string[string] _node = [ - "is" : "", - "ocn" : "", - "marked_up_lev" : "", - "segment_anchor_tag_html" : "", - "segment_anchor_tag_epub" : "", - "attrib" : "", - ]; - return _node; - } - static int[string] node_metadata_heading_int() { - int[string] _node = [ - "ocn" : 0, // decide whether to use or keep? - "ptr_doc_object" : 0, - "ptr_html_segnames" : 0, - "ptr_heading" : 0, - "heading_lev_markup" : 9, - "heading_lev_collapsed" : 9, - "parent_ocn" : 0, - "parent_lev_markup" : 9, - ]; - return _node; - } - static string[string] node_metadata_para_str() { - string[string] _node = [ - "is" : "", - "ocn" : "", - "attrib" : "", - ]; - return _node; - } - static int[string] node_metadata_para_int() { - int[string] _node = [ - "ocn" : 0, - "indent_base" : 0, - "indent_hang" : 0, - "bullet" : 0, // bool (0|1) - ]; - return _node; - } -} -template spineCurateMetadata() { - auto spineCurateMetadata() { - struct _Curate { - struct Curate { - string title = ""; - string[] author_arr = []; - string author = ""; - string author_surname = ""; - string author_surname_fn = ""; - string language = ""; - string language_original = ""; - string uid = ""; - string date_published = ""; - string[] topic_register_arr = []; - string path_html_metadata = ""; - string path_html_scroll = ""; - string path_html_segtoc = ""; - string path_epub = ""; - string path_abs_html_segtoc = ""; - string path_abs_html_scroll = ""; - string path_abs_epub = ""; - string url_html_seg = ""; - string url_html_scroll = ""; - string url_epub = ""; - } - Curate curate; - Curate[] curates; - Curate[][string][string][string][string] subject_trees; - } - return _Curate(); - } -} -template spineBiblio() { - // required: deemed_author (author || editor); year; fulltitle; - struct BibJsnStr { - static auto biblio_entry_tags_jsonstr() { - string x = `{ - "is" : "", - "sortby_deemed_author_year_title" : "", - "deemed_author" : "", - "author_raw" : "", - "author" : "", - "author_arr" : [ "" ], - "editor_raw" : "", - "editor" : "", - "editor_arr" : [ "" ], - "title" : "", - "subtitle" : "", - "fulltitle" : "", - "language" : "", - "trans" : "", - "src" : "", - "journal" : "", - "in" : "", - "volume" : "", - "edition" : "", - "year" : "", - "place" : "", - "publisher" : "", - "url" : "", - "pages" : "", - "note" : "", - "short_name" : "", - "id" : "" - }`; // is: book, article, magazine, newspaper, blog, other - return x; - } - } -} -template InternalMarkup() { - import std.array; - static struct InlineMarkup { - string en_a_o = "【"; string en_a_c = "】"; - string en_b_o = "〖"; string en_b_c = "〗"; - string quote_o = "“"; string quote_c = "”"; - string ff_i = "⑆"; string ff_o = "┨"; string ff_c = "┣"; // fontface - string lnk_o = "┥"; string lnk_c = "┝"; - string url_o = "┤"; string url_c = "├"; - string emph = "*"; - string bold = "!"; - string italic = "/"; - string underscore = "_"; - string superscript = "^"; - string subscript = ","; - string mono = "■"; - string cite = "‖"; - string mark_internal_site_lnk = "¤"; - string nbsp = "░"; - string br_line = "┘"; - string br_line_inline = "┙"; - string br_line_spaced = "┚"; - string br_obj = "break_obj"; - string br_page_line = "┼"; - string br_page = "┿"; - string br_page_new = "╂"; - string tc_s = "┊"; - string tc_o = "┏"; - string tc_c = "┚"; - string tc_p = "┆"; - string img = "☼"; - string sep = "␣"; // "~";"␣"; // "~"; - string uid_sep = ":"; - string on_o = "「"; string on_c = "」"; - string mk_bullet = "● "; - static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { - _indent_spaces = replicate(_indent_spaces, indent); - return _indent_spaces; - } - static string repeat_character_by_number_provided(C,N)(C _character ="-", N number=10) { - _character = replicate(_character, number); - return _character; - } - } -} -template spineLanguageCodes() { - /+ language codes +/ - struct Lang { - static string[string][string] codes() { - auto _lang_codes = [ - "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], - "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], - "bn": [ "c": "bn", "n": "Bengali", "t": "Bengali", "xlp": "bengali" ], - "br": [ "c": "br", "n": "Breton", "t": "Breton", "xlp": "breton" ], - "ca": [ "c": "ca", "n": "Catalan", "t": "catalan", "xlp": "catalan" ], - "cs": [ "c": "cs", "n": "Czech", "t": "česky", "xlp": "czech" ], - "cy": [ "c": "cy", "n": "Welsh", "t": "Welsh", "xlp": "welsh" ], - "da": [ "c": "da", "n": "Danish", "t": "dansk", "xlp": "danish" ], - "de": [ "c": "de", "n": "German", "t": "Deutsch", "xlp": "german" ], - "el": [ "c": "el", "n": "Greek", "t": "Ελληνικά (Ellinika)", "xlp": "greek" ], - "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], - "eo": [ "c": "eo", "n": "Esperanto", "t": "Esperanto", "xlp": "esperanto" ], - "es": [ "c": "es", "n": "Spanish", "t": "español", "xlp": "spanish" ], - "et": [ "c": "et", "n": "Estonian", "t": "Estonian", "xlp": "estonian" ], - "eu": [ "c": "eu", "n": "Basque", "t": "basque", "xlp": "basque" ], - "fi": [ "c": "fi", "n": "Finnish", "t": "suomi", "xlp": "finnish" ], - "fr": [ "c": "fr", "n": "French", "t": "français", "xlp": "french" ], - "ga": [ "c": "ga", "n": "Irish", "t": "Irish", "xlp": "irish" ], - "gl": [ "c": "gl", "n": "Galician", "t": "Galician", "xlp": "galician" ], - "he": [ "c": "he", "n": "Hebrew", "t": "Hebrew", "xlp": "hebrew" ], - "hi": [ "c": "hi", "n": "Hindi", "t": "Hindi", "xlp": "hindi" ], - "hr": [ "c": "hr", "n": "Croatian", "t": "Croatian", "xlp": "croatian" ], - "hy": [ "c": "hy", "n": "Armenian", "t": "Armenian", "xlp": "armenian" ], - "ia": [ "c": "ia", "n": "Interlingua", "t": "Interlingua", "xlp": "interlingua" ], - "is": [ "c": "is", "n": "Icelandic", "t": "Icelandic", "xlp": "icelandic" ], - "it": [ "c": "it", "n": "Italian", "t": "Italiano", "xlp": "italian" ], - "ja": [ "c": "ja", "n": "Japanese", "t": "日本語 (Nihongo)", "xlp": "japanese" ], - "ko": [ "c": "ko", "n": "Korean", "t": "Korean", "xlp": "korean" ], - "la": [ "c": "la", "n": "Latin", "t": "Latin", "xlp": "latin" ], - "lo": [ "c": "lo", "n": "Lao", "t": "Lao", "xlp": "lao" ], - "lt": [ "c": "lt", "n": "Lithuanian", "t": "Lithuanian", "xlp": "lithuanian" ], - "lv": [ "c": "lv", "n": "Latvian", "t": "Latvian", "xlp": "latvian" ], - "ml": [ "c": "ml", "n": "Malayalam", "t": "Malayalam", "xlp": "malayalam" ], - "mr": [ "c": "mr", "n": "Marathi", "t": "Marathi", "xlp": "marathi" ], - "nl": [ "c": "nl", "n": "Dutch", "t": "Nederlands", "xlp": "dutch" ], - "no": [ "c": "no", "n": "Norwegian", "t": "norsk", "xlp": "norsk" ], - "nn": [ "c": "nn", "n": "Norwegian Nynorsk", "t": "nynorsk", "xlp": "nynorsk" ], - "oc": [ "c": "oc", "n": "Occitan", "t": "Occitan", "xlp": "occitan" ], - "pl": [ "c": "pl", "n": "Polish", "t": "polski", "xlp": "polish" ], - "pt": [ "c": "pt", "n": "Portuguese", "t": "Português", "xlp": "portuges" ], - "pt_BR": [ "c": "pt_BR", "n": "Portuguese Brazil", "t": "Brazilian Português", "xlp": "brazilian" ], - "ro": [ "c": "ro", "n": "Romanian", "t": "română", "xlp": "romanian" ], - "ru": [ "c": "ru", "n": "Russian", "t": "Русский (Russkij)", "xlp": "russian" ], - "sa": [ "c": "sa", "n": "Sanskrit", "t": "Sanskrit", "xlp": "sanskrit" ], - "se": [ "c": "se", "n": "Sami", "t": "Samin", "xlp": "samin" ], - "sk": [ "c": "sk", "n": "Slovak", "t": "slovensky", "xlp": "slovak" ], - "sl": [ "c": "sl", "n": "Slovenian", "t": "Slovenian", "xlp": "slovenian" ], - "sq": [ "c": "sq", "n": "Albanian", "t": "Albanian", "xlp": "albanian" ], - "sr": [ "c": "sr", "n": "Serbian", "t": "Serbian", "xlp": "serbian" ], - "sv": [ "c": "sv", "n": "Swedish", "t": "svenska", "xlp": "swedish" ], - "ta": [ "c": "ta", "n": "Tamil", "t": "Tamil", "xlp": "tamil" ], - "te": [ "c": "te", "n": "Telugu", "t": "Telugu", "xlp": "telugu" ], - "th": [ "c": "th", "n": "Thai", "t": "Thai", "xlp": "thai" ], - "tk": [ "c": "tk", "n": "Turkmen", "t": "Turkmen", "xlp": "turkmen" ], - "tr": [ "c": "tr", "n": "Turkish", "t": "Türkçe", "xlp": "turkish" ], - "uk": [ "c": "uk", "n": "Ukranian", "t": "українська (ukrajins\"ka)", "xlp": "ukrainian" ], - "ur": [ "c": "ur", "n": "Urdu", "t": "Urdu", "xlp": "urdu" ], - "us": [ "c": "en", "n": "English (American)","t": "English", "xlp": "english" ], - "vi": [ "c": "vi", "n": "Vietnamese", "t": "Vietnamese", "xlp": "vietnamese" ], - "zh": [ "c": "zh", "n": "Chinese", "t": "中文", "xlp": "chinese" ], - "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], - "xx": [ "c": "xx", "n": "Default", "t": "English", "xlp": "english" ], - ]; - return _lang_codes; - } - static string[] code_arr_ptr() { - string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; - return _lang_codes; - } - static string[] code_arr() { - string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; - return _lang_codes; - } - static auto codes_() { - return "(" ~ join(code_arr,"|") ~ ")"; - } - static auto codes_regex() { - return regex(codes_); - } - } -} diff --git a/src/doc_reform/meta/doc_debugs.d b/src/doc_reform/meta/doc_debugs.d deleted file mode 100644 index 00aced9..0000000 --- a/src/doc_reform/meta/doc_debugs.d +++ /dev/null @@ -1,252 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -/++ - output debugs -+/ -module doc_reform.meta.doc_debugs; -template spineDebugs() { - import - doc_reform.meta.defaults, - doc_reform.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; - auto spineDebugs(S,T)( - const S contents, - T doc_matters, - ) { - mixin spineRgxFiles; - mixin InternalMarkup; - static auto rgx_files = RgxFiles(); - auto markup = InlineMarkup(); - string key; - debug(parent) { - writefln( - "%s:%s", - __FILE__, - __LINE__, - ); - foreach (key; doc_matters.has.keys_seq.seg) { - foreach (obj; contents[key]) { - if (obj.metainfo.is_of_part != "empty") { - if (obj.metainfo.is_a == "heading") { - writefln( - "%s node: %s heading: %s %s", - obj.object_number, - obj.node, - obj.heading_lev_markup, - obj.text, - ); - } - } - } - } - } - debug(checkdoc) { - if ((doc_matters.opt.action.debug_do)) { - debug(checkdoc) { - if (auto mfn=match(doc_matters.src.filename, rgx_files.src_fn)) { - if (doc_matters.opt.action.assertions) { - switch (mfn.captures[2]) { - // live manual: - case "live-manual.ssm": - assert(check["last_object_number"] == - "1019","last object_number should be: 1019 (check test, document is frequently updated)"); // ok - break; - // sisu_markup: - case "sisu_markup.sst": - assert(check["last_object_number"] == - "297","last object_number expected to be: 297 rather than " ~ check["last_object_number"]); // ok - // assert(check["last_object_number"] == "297","last object_number expected to be: 297 rather than " ~ check["last_object_number"]); - // notes for first divergance study sisu headings 247 250 - // sisu has issue with code that contains heading 1~ which results in no object_number! ?? - // sisu currently has incorrect last body object_number of 294! - // bug in sisu? attend - break; - // sisu-markup-samples: - case "accelerando.charles_stross.sst": - assert(check["last_object_number"] == - "2861","last object_number expected to be: 2861 rather than " ~ check["last_object_number"]); // ok - break; - case "alices_adventures_in_wonderland.lewis_carroll.sst": - assert(check["last_object_number"] == - "805","last object_number expected to be: 805 rather than " ~ check["last_object_number"]); // 808 - break; - case "autonomy_markup0.sst": - assert(check["last_object_number"] == - "77","last object_number expected to be: 77 rather than " ~ check["last_object_number"]); // ok endnotes - // assert(check["last_object_number"] == "78","last object_number expected to be: 78 rather than " ~ check["last_object_number"]); - break; - case "content.cory_doctorow.sst": - assert(check["last_object_number"] == - "953","last object_number expected to be: 953 rather than " ~ check["last_object_number"]); // 1007 way off, check object_number off switches - // assert(check["last_object_number"] == "953","last object_number expected to be: 953 rather than " ~ check["last_object_number"]); - break; - case "democratizing_innovation.eric_von_hippel.sst": - // fixed ERROR! range violation, broken check! endnotes, bookindex, biblio - // error in bookindex ... (ch1; ch6; ch8 ) - assert(check["last_object_number"] == - "905","last object_number expected to be: 905 rather than " ~ check["last_object_number"]); // 911 - break; - case "down_and_out_in_the_magic_kingdom.cory_doctorow.sst": - assert(check["last_object_number"] == - "1417","last object_number expected to be: 1417 rather than " ~ check["last_object_number"]); // 1455 check object_number off switches - break; - case "for_the_win.cory_doctorow.sst": - assert(check["last_object_number"] == - "3510","last object_number expected to be: 3510 rather than " ~ check["last_object_number"]); // 3569 check object_number off switches - break; - case "free_as_in_freedom_2.richard_stallman_and_the_free_software_revolution.sam_williams.richard_stallman.sst": - assert(check["last_object_number"] == - "1082","last object_number expected to be: 1082 rather than " ~ check["last_object_number"]); // check 1079 too few - break; - case "free_culture.lawrence_lessig.sst": - assert(check["last_object_number"] == - "1330","last object_number expected to be: 1330 rather than " ~ check["last_object_number"]); // 1312 - // fixed ERROR! range violation, broken check! - // error in bookindex ... sections piracy (ch1) & property (ch10 market concentration) fixed - break; - case "free_for_all.peter_wayner.sst": // endnotes, bookindex, biblio - assert(check["last_object_number"] == - "1559","last object_number expected to be: 1559 rather than " ~ check["last_object_number"]); // 1560, check object_number off switches, has endnotes so 2 too many - // assert(check["last_object_number"] == "1559","last object_number expected to be: 1559 rather than " ~ check["last_object_number"]); - break; - case "gpl2.fsf.sst": - assert(check["last_object_number"] == - "65","last object_number expected to be: 65 rather than " ~ check["last_object_number"]); // ok endnotes? check - // assert(check["last_object_number"] == "66","last object_number expected to be: 66 rather than " ~ check["last_object_number"]); - break; - case "gpl3.fsf.sst": - assert(check["last_object_number"] == - "123","last object_number expected to be: 123 rather than " ~ check["last_object_number"]); // ok - break; - case "gullivers_travels.jonathan_swift.sst": - assert(check["last_object_number"] == - "668","last object_number expected to be: 668 rather than " ~ check["last_object_number"]); // 674 - break; - case "little_brother.cory_doctorow.sst": - assert(check["last_object_number"] == - "3130","last object_number expected to be: 3130 rather than " ~ check["last_object_number"]); // 3204, check object_number off switches - break; - case "the_cathedral_and_the_bazaar.eric_s_raymond.sst": - assert(check["last_object_number"] == - "258","last object_number expected to be: 258 rather than " ~ check["last_object_number"]); // ok - break; - case "the_public_domain.james_boyle.sst": - assert(check["last_object_number"] == - "970","last object_number expected to be: 970 rather than " ~ check["last_object_number"]); // 978 - break; - case "the_wealth_of_networks.yochai_benkler.sst": // endnotes, bookindex - assert(check["last_object_number"] == - "829","last object_number expected to be: 829 rather than " ~ check["last_object_number"]); // ok - // assert(check["last_object_number"] == "832","last object_number expected to be: 832 rather than " ~ check["last_object_number"]); - // has endnotes and bookindex, issue with sisu.rb - break; - case "through_the_looking_glass.lewis_carroll.sst": - assert(check["last_object_number"] == - "949","last object_number expected to be: 949 rather than " ~ check["last_object_number"]); // 955 - break; - case "two_bits.christopher_kelty.sst": // endnotes, bookindex, biblio - assert(check["last_object_number"] == - "1190","last object_number expected to be: 1190 rather than " ~ check["last_object_number"]); // 1191 - // assert(check["last_object_number"] == "1193","last object_number expected to be: 1193 rather than " ~ check["last_object_number"]); // 1191 ok? - // has endnotes and bookindex, issue with sisu.rb - break; - // fixed ERROR! range violation! - // error in bookindex ... (ch3 the movement) - case "un_contracts_international_sale_of_goods_convention_1980.sst": - assert(check["last_object_number"] == - "377","last object_number expected to be: 377 rather than " ~ check["last_object_number"]); // ok - break; - case "viral_spiral.david_bollier.sst": // endnotes, bookindex - assert(check["last_object_number"] == - "1078","last object_number expected to be: 1078 rather than " ~ check["last_object_number"]); // 1100 - // fixed ERROR! range violation! - // error in bookindex ... (ch7 ... building the cc machine, an extra semi colon) - break; - default: - writeln(doc_matters.src.filename); - break; - } - } - } - } - debug(checkdoc) { - void out_segnames(S,T)( - const S contents, - T doc_matters, - ) { - foreach (key; doc_matters.has.keys_seq.seg) { - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - if (obj.heading_lev_markup == 4) { - writeln(obj.ptr_html_segnames, ". (", doc_matters.has.segnames_lv4[obj.ptr_html_segnames], ") -> ", obj.text); - } - } - } - } - } - } - } - } - } -} diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d deleted file mode 100644 index b153347..0000000 --- a/src/doc_reform/meta/metadoc.d +++ /dev/null @@ -1,296 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta.metadoc; -@safe: -template spineAbstraction() { - import - std.datetime; - import - doc_reform.meta, - doc_reform.meta.metadoc_from_src, - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json, - doc_reform.meta.defaults, - doc_reform.io_in.paths_source, - doc_reform.io_in.read_config_files, - doc_reform.io_in.read_source_files, - doc_reform.io_out.hub; - mixin spineBiblio; - mixin outputHub; - enum headBody { header, body_content, insert_file_list, image_list } - enum makeMeta { make, meta } - enum docAbst { doc_abstract_obj, doc_has } - @system auto spineAbstraction(E,P,O,Cfg,M,S)( - E _env, - P program_info, - O _opt_action, - Cfg _cfg, - M _manifest, - S _make_and_meta_struct - ){ - { /+ document config/make file +/ - auto _config_document_struct = readConfigDoc!()(_manifest, _env); - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = _config_document_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifest, _opt_action, _cfg); - } - /+ ↓ read file (filename with path) +/ - /+ ↓ file tuple of header and content +/ - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("step1 commence → (get document header & body & insert file list & if needed image list) [", _manifest.src.filename, "]"); - } - auto _header_body_insertfilelist_imagelist - = spineRawMarkupContent!()(_opt_action, _manifest.src.path_and_fn); - static assert(_header_body_insertfilelist_imagelist.length==4); - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("- step1 complete for [", _manifest.src.filename, "]"); - } - debug(header_and_body) { - writeln(header); - writeln(_header_body_insertfilelist_imagelist.length); - writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]); - } - /+ ↓ split header into make and meta +/ - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("step2 commence → (read document header (yaml) return struct) [", _manifest.src.filename, "]"); - } - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = - docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()( - _header_body_insertfilelist_imagelist[headBody.header], - _make_and_meta_struct, - _manifest, - _opt_action, - _cfg, - ); - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("- step2 complete for [", _manifest.src.filename, "]"); - } - /+ ↓ document abstraction: process document, return abstraction as tuple +/ - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters) [", _manifest.src.filename, "]"); - } - auto da = docAbstraction!()( - _header_body_insertfilelist_imagelist[headBody.body_content], - _make_and_meta_struct, - _opt_action, - _manifest, - true, - ); - auto doc_abstraction = da.document_the; - auto _doc_has_struct = da.doc_has; - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("- step3 complete for [", _manifest.src.filename, "]"); - } - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("step4 commence → (doc_matters) [", _manifest.src.filename, "]"); - } - struct DocumentMatters { - auto generator_program() { - struct Prog_ { - string project_name() { - return "spine"; - } - string name() { - return program_info.name; - } - string ver() { - return program_info.ver; - } - @trusted string name_and_version() { - return program_info.name_and_version; - } - @trusted string name_version_and_compiler() { - return program_info.name_version_and_compiler; - } - string url_home() { - return "https://sisudoc.org"; - } - string url_git() { - return "https://git.sisudoc.org/projects/"; - } - auto compiler() { - return program_info.compiler; - } - auto time_output_generated() { - return program_info.time_output_generated; - } - } - return Prog_(); - } - auto generated_time() { - auto _st = Clock.currTime(UTC()); - auto _time = _st.year.to!string - ~ "-" ~ _st.month.to!int.to!string // prefer as month number - ~ "-" ~ _st.day.to!string - ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" - ~ " " ~ _st.hour.to!string - ~ ":" ~ _st.minute.to!string - ~ ":" ~ _st.second.to!string; - return _time; - } - auto conf_make_meta() { - return _make_and_meta_struct; - } - auto has() { - return _doc_has_struct; - } - auto env() { - struct Env_ { - auto pwd() { - return _manifest.env.pwd; - } - auto home() { - return _manifest.env.home; - } - } - return Env_(); - } - auto opt() { - struct Opt_ { - auto action() { - /+ getopt options, commandline instructions, raw - - processing instructions --epub --html etc. - - command line config instructions --output - +/ - return _opt_action; - } - } - return Opt_(); - } - auto src() { - return _manifest.src; - } - auto src_path_info() { - return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path - } - auto pod() { - return _manifest.pod; - } - auto sqlite() { - struct SQLite_ { - string filename() { - string _fn = ""; - string _pth = ""; - if (_opt_action.sqliteDB_filename.length > 0) { - _fn = _opt_action.sqliteDB_filename; - } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_db_sqlite_filename; - } - return _fn; - } - string path() { - string _pth = ""; - if (_opt_action.sqliteDB_path.length > 0) { - _pth = _opt_action.sqliteDB_path; - } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_path.length > 0) { - _pth = _make_and_meta_struct.conf.w_srv_db_sqlite_path; - } - return _pth; - } - string cgi_filename() { - string _fn = ""; - if (_opt_action.cgi_sqlite_search_filename.length > 0) { - _fn = _opt_action.cgi_sqlite_search_filename; - } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script; - } - return _fn; - } - string cgi_filename_d() { - string _fn = ""; - if (_opt_action.cgi_sqlite_search_filename_d.length > 0) { - _fn = _opt_action.cgi_sqlite_search_filename_d; - } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d; - } - return _fn; - } - } - return SQLite_(); - } - auto output_path() { - return _make_and_meta_struct.conf.output_path; - } - auto srcs() { - struct SRC_ { - auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - } - auto image_list() { - return _doc_has_struct.imagelist; - } - } - return SRC_(); - } - } - auto doc_matters = DocumentMatters(); - if ((_opt_action.debug_do) - || (_opt_action.debug_do_stages) - ) { - writeln("- step4 complete for [", _manifest.src.filename, "]"); - } - auto t = tuple(doc_abstraction, doc_matters); - return t; - } -} diff --git a/src/doc_reform/meta/metadoc_curate.d b/src/doc_reform/meta/metadoc_curate.d deleted file mode 100644 index 3263015..0000000 --- a/src/doc_reform/meta/metadoc_curate.d +++ /dev/null @@ -1,92 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -module doc_reform.meta.metadoc_curate; -@safe: -template spineMetaDocCurate() { - auto spineMetaDocCurate(T,H)( - T doc_matters, - H hvst, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - static auto mkup = InlineMarkup(); - import doc_reform.io_out.paths_output; - auto pth_html_abs = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); - auto pth_html_rel = spineDocRootTreeHTML!()(doc_matters.src.language); - hvst.curate.title = doc_matters.conf_make_meta.meta.title_full; - hvst.curate.author = doc_matters.conf_make_meta.meta.creator_author; - hvst.curate.author_surname = doc_matters.conf_make_meta.meta.creator_author_surname; - hvst.curate.author_surname_fn = doc_matters.conf_make_meta.meta.creator_author_surname_fn; - hvst.curate.author_arr = doc_matters.conf_make_meta.meta.creator_author_arr; - hvst.curate.language_original = doc_matters.conf_make_meta.meta.original_language; - hvst.curate.language = doc_matters.src.language; - hvst.curate.uid = doc_matters.src.doc_uid; - hvst.curate.date_published = doc_matters.conf_make_meta.meta.date_published; - hvst.curate.topic_register_arr = doc_matters.conf_make_meta.meta.classify_topic_register_arr; - hvst.curate.path_html_metadata = pth_html_rel.fn_metadata(doc_matters.src.filename); - hvst.curate.path_html_scroll = pth_html_rel.fn_scroll(doc_matters.src.filename); - hvst.curate.path_html_segtoc = pth_html_rel.fn_seg(doc_matters.src.filename, "toc"); - hvst.curate.path_abs_html_scroll = pth_html_abs.fn_scroll(doc_matters.src.filename); - hvst.curate.path_abs_html_segtoc = pth_html_abs.fn_seg(doc_matters.src.filename, "toc"); - return hvst.curate; - } -} diff --git a/src/doc_reform/meta/metadoc_curate_authors.d b/src/doc_reform/meta/metadoc_curate_authors.d deleted file mode 100644 index 8757b26..0000000 --- a/src/doc_reform/meta/metadoc_curate_authors.d +++ /dev/null @@ -1,530 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -module doc_reform.meta.metadoc_curate_authors; -@safe: - import - std.algorithm, - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.conv : to; - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - mixin spineCurateMetadata; - mixin InternalMarkup; -template spineMetaDocCuratesAuthors() { - static auto mkup = InlineMarkup(); - void spineMetaDocCuratesAuthors(H,M,O)( - H curates, - M _make_and_meta_struct, - O _opt_action, - ) { - string inline_search_form(M)( - M _make_and_meta_truct, - ) { - string o; - string _form; - if (_opt_action.html_link_search) { - o = format(q"┃ -
- - - -
┃", - _make_and_meta_struct.conf.w_srv_cgi_action, - (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) - ? "" - : "\n ", - ); - } else { - o = ""; - } - return o; - } -string theme_dark_0 = format(q"┃ - body { - color : #CCCCCC; - background : #000000; - background-color : #000000; - } - a:link { - color : #FFFFFF; - text-decoration : none; - } - a:visited { - color : #999999; - text-decoration : none; - } - a:hover { - color : #000000; - background-color : #555555; - } - a:hover img { - background-color : #000000; - } - a:active { - color : #888888; - text-decoration : underline; - } - a.lev0:hover { - color : #FFFFFF; - background-color : #000000; - } - a.lev1:hover { - color : #FFFFFF; - background : #333333; - } - a.lev2:hover { - color : #FFFFFF; - background : #555555; - } - a.lev3:hover { - color : #FFFFFF; - background : #777777; - } - a.lnkicon:link { - text-decoration : none; - } - a.lnkicon:visited { - text-decoration : none; - } - a.lnkicon:hover { - font-size : 160%%; - } - a:hover img { - background-color : #FFFFFF; - } - input, select, textarea { - font-size : 150%%; - } - input { - color : #FFFFFF; - background-color : #777777; - } -┃"); -string theme_light_0 = format(q"┃ - body { - color : #000000; - background : #FFFFFF; - background-color : #FFFFFF; - } - a:link { - color : #003399; - text-decoration : none; - } - a:visited { - color : #003399; - text-decoration : none; - } - a:hover { - color : #000000; - background-color : #f9f9aa; - } - a:hover img { - background-color : #FFFFFF; - } - a:active { - color : #003399; - text-decoration : underline; - } - a.lev0:hover { - color : #000000; - background-color : #FFFFFF; - } - a.lev1:hover { - color : #FFFFFF; - background : #444444; - } - a.lev2:hover { - background : #888888; - } - a.lev3:hover { - background : #BBBBBB; - } - a.lnkicon:link { - text-decoration : none; - } - a.lnkicon:visited { - text-decoration : none; - } - a.lnkicon:hover { - font-size : 160%%; - } - a:hover img { - background-color : #FFFFFF; - } - input, select, textarea { - font-size : 150%%; - } - input { - color : #000000; - background-color : #FFFFFF; - } -┃"); -string theme_dark_1 = format(q"┃ - h1 { - color : #FFFFFF; - background : #000000; - } - p.letter { - color : #FFFFFF; - background : #333333; - } - p.lev0 { - color : #FFFFFF; - background : #000000; - } - p.lev1 { - color : #FFFFFF; - background : #333333; - } - p.lev2 { - background : #555555; - } - p.lev3 { - background : #777777; - } - p.lev4 { - background : #AAAAAA; - } - p.lev5 { - } -┃"); -string theme_light_1 = format(q"┃ - h1 { - color : #FFFFFF; - background : #1A3A7A; - } - p.letter { - color : #FFFFFF; - background : #1A3A7A; - } - p.lev0 { - color : #FFFFFF; - background : #000000; - } - p.lev1 { - color : #FFFFFF; - background : #444444; - } - p.lev2 { - background : #888888; - } - p.lev3 { - background : #BBBBBB; - } - p.lev4 { - background : #EEEEEE; - } - p.lev5 { - } -┃"); - string[] authors = []; - authors ~= format(q"┃ - - - - -⌘ Curated metadata - 🖋 Authors - - - - - - - - - - - - - -

⌘ Curated metadata - 🖋 Authors (output organised by language & filetype)

-
- -%s -
-

-
-

ABCDEFGHIJKLMNOPQRSTUVWXYZ,  -┃", - _opt_action.css_theme_default ? theme_light_0 : theme_dark_0, - _opt_action.css_theme_default ? theme_light_1 : theme_dark_1, - inline_search_form(_make_and_meta_struct), -) ~ "\n"; - string[string] _au; - string[] _auth_date_title; - string[] _author_date_title; - string _prev_auth = ""; - char _prev_k = "_".to!char; - foreach(doc_curate; - curates - .multiSort!( - "toUpper(a.author_surname_fn) < toUpper(b.author_surname_fn)", - "a.date_published < b.date_published", - "a.title < b.title", - SwapStrategy.unstable - ) - ) { - if (doc_curate.author_surname_fn != _prev_auth) { - _au[doc_curate.author_surname_fn] - = format(q"┃

%s

%s "%s" [ %s ]

┃", - doc_curate.author_surname.translate([' ' : "_"]), - doc_curate.author_surname_fn, - (doc_curate.date_published.length > 0) - ? doc_curate.date_published : "", - doc_curate.path_html_segtoc, - doc_curate.title, - doc_curate.path_html_metadata, - doc_curate.language, - ); - _prev_auth = doc_curate.author_surname_fn; - } else { - _au[doc_curate.author_surname_fn] - ~= format(q"┃

%s "%s" [ %s ]

┃", - (doc_curate.date_published.length > 0) - ? doc_curate.date_published : "", - doc_curate.path_html_segtoc, - doc_curate.title, - doc_curate.path_html_metadata, - doc_curate.language, - ); - } - _author_date_title ~= format(q"┃%s %s "%s" [ %s ]%s┃", - doc_curate.author_surname_fn, - (doc_curate.date_published.length > 0) - ? "(" ~ doc_curate.date_published ~ ")" : "", - doc_curate.title, - doc_curate.path_html_metadata, - doc_curate.language, - (_opt_action.show_curate_authors) ? "\n " ~ doc_curate.path_abs_html_scroll : "", - ); - } - foreach (k; _au.keys.sort) { - if (k.toUpper.to!(char[])[0] != _prev_k) { - authors ~= format(q"┃

%s

┃", - k.toUpper.to!(char[])[0], - k.toUpper.to!(char[])[0], - ); - _prev_k = k.toUpper.to!(char[])[0]; - } - authors ~= _au[k]; - } - authors - ~= format(q"┃ -
- - - - - - - - -┃") ~ "\n"; - import doc_reform.io_out.paths_output; - auto out_pth = spinePathsHTML!()(_make_and_meta_struct.conf.output_path, ""); - try { - auto f = File(out_pth.curate("authors.html"), "w"); - foreach (o; authors) { - f.writeln(o); - } - } catch (ErrnoException ex) { - // Handle error - } - if (_opt_action.show_curate_authors) { - foreach(_adt; _author_date_title.sort) { - writeln(_adt); - } - } - } -} diff --git a/src/doc_reform/meta/metadoc_curate_topics.d b/src/doc_reform/meta/metadoc_curate_topics.d deleted file mode 100644 index 9fc7604..0000000 --- a/src/doc_reform/meta/metadoc_curate_topics.d +++ /dev/null @@ -1,693 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -module doc_reform.meta.metadoc_curate_topics; -@safe: - import - std.algorithm, - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.conv : to; - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - mixin spineCurateMetadata; - mixin InternalMarkup; -template spineMetaDocCuratesTopics() { - static auto mkup = InlineMarkup(); - void spineMetaDocCuratesTopics(H,M,O)( - H hvst, - M _make_and_meta_struct, - O _opt_action, - ) { - string inline_search_form(M)( - M _make_and_meta_truct, - ) { - string o; - string _form; - if (_opt_action.html_link_search) { - o = format(q"┃ -
- - - -
┃", - _make_and_meta_struct.conf.w_srv_cgi_action, - (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) - ? "" - : "\n ", - ); - } else { - o = ""; - } - return o; - } - auto min_repeat_number = 42; - string[] _document_topic_register; - string[] _topic_register; - string[] _sub_topic_register; - string[] topics = []; - string _auth = ""; - foreach(k, doc_curate; hvst.curates) { - _topic_register = []; - foreach(topic; doc_curate.topic_register_arr.sort) { - _sub_topic_register = []; - string _spaces; - string[] subject_tree = topic.split(mkup.sep); - switch (subject_tree.length) { - case 1: - hvst.subject_trees[subject_tree[0]]["_a"]["_a"]["_a"] ~= doc_curate; - break; - case 2: - hvst.subject_trees[subject_tree[0]][subject_tree[1]]["_a"]["_a"] ~= doc_curate; - break; - case 3: - hvst.subject_trees[subject_tree[0]][subject_tree[1]][subject_tree[2]]["_a"] ~= doc_curate; - break; - case 4: - hvst.subject_trees[subject_tree[0]][subject_tree[1]][subject_tree[2]][subject_tree[3]] ~= doc_curate; - break; - default: - break; - } - _topic_register ~= _sub_topic_register.join("\n"); - } - auto char_repeat_number = (doc_curate.title.length - + doc_curate.author.length + 16); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - _document_topic_register ~= format( - "\"%s\", %s%s\n%s", - doc_curate.title, - doc_curate.author, - (doc_curate.date_published.length > 0) ? " (" ~ doc_curate.date_published ~ ")" : "", - _topic_register.sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable).release.join("\n"), - ); - } -string theme_dark_0 = format(q"┃ - body { - color : #CCCCCC; - background : #000000; - background-color : #000000; - } - a:link { - color : #FFFFFF; - text-decoration : none; - } - a:visited { - color : #999999; - text-decoration : none; - } - a:hover { - color : #000000; - background-color : #555555; - } - a:hover img { - background-color : #000000; - } - a:active { - color : #888888; - text-decoration : underline; - } - a.lev0:hover { - color : #FFFFFF; - background-color : #000000; - } - a.lev1:hover { - color : #FFFFFF; - background : #333333; - } - a.lev2:hover { - color : #FFFFFF; - background : #555555; - } - a.lev3:hover { - color : #FFFFFF; - background : #777777; - } - a.lnkicon:link { - text-decoration : none; - } - a.lnkicon:visited { - text-decoration : none; - } - a.lnkicon:hover { - font-size : 160%%; - } - a:hover img { - background-color : #FFFFFF; - } - input, select, textarea { - font-size : 150%%; - } - input { - color : #FFFFFF; - background-color : #777777; - } -┃"); -string theme_light_0 = format(q"┃ - body { - color : #000000; - background : #FFFFFF; - background-color : #FFFFFF; - } - a:link { - color : #003399; - text-decoration : none; - } - a:visited { - color : #003399; - text-decoration : none; - } - a:hover { - color : #000000; - background-color : #f9f9aa; - } - a:hover img { - background-color : #FFFFFF; - } - a:active { - color : #003399; - text-decoration : underline; - } - a.lev0:hover { - color : #000000; - background-color : #FFFFFF; - } - a.lev1:hover { - color : #FFFFFF; - background : #444444; - } - a.lev2:hover { - background : #888888; - } - a.lev3:hover { - background : #BBBBBB; - } - a.lnkicon:link { - text-decoration : none; - } - a.lnkicon:visited { - text-decoration : none; - } - a.lnkicon:hover { - font-size : 160%%; - } - a:hover img { - background-color : #FFFFFF; - } - input, select, textarea { - font-size : 150%%; - } - input { - color : #000000; - background-color : #FFFFFF; - } -┃"); -string theme_dark_1 = format(q"┃ - h1 { - color : #FFFFFF; - background : #000000; - } - p.letter { - color : #FFFFFF; - background : #333333; - } - p.lev0 { - color : #FFFFFF; - background : #000000; - } - p.lev1 { - color : #FFFFFF; - background : #333333; - } - p.lev2 { - background : #555555; - } - p.lev3 { - background : #777777; - } - p.lev4 { - background : #AAAAAA; - } - p.lev5 { - } -┃"); -string theme_light_1 = format(q"┃ - h1 { - color : #FFFFFF; - background : #1A3A7A; - } - p.letter { - color : #FFFFFF; - background : #1A3A7A; - } - p.lev0 { - color : #FFFFFF; - background : #000000; - } - p.lev1 { - color : #FFFFFF; - background : #444444; - } - p.lev2 { - background : #888888; - } - p.lev3 { - background : #BBBBBB; - } - p.lev4 { - background : #EEEEEE; - } - p.lev5 { - } -┃"); - topics ~= format(q"┃ - - - -⌘ Curated metadata - ⌘ Topics - - - - - - - - - - - - - -

⌘ Curated metadata - ⌘ Topics (output organised by language & filetype)

-
- - %s -
-

ABCDEFGHIJKLMNOPQRSTUVWXYZ,  -

-
-┃", - _opt_action.css_theme_default ? theme_light_0 : theme_dark_0, - _opt_action.css_theme_default ? theme_light_1 : theme_dark_1, - inline_search_form(_make_and_meta_struct), -) ~ "\n"; - char _prev_k = "_".to!char; - int _kn; - foreach(k0; - hvst.subject_trees.keys - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) - ) { - if (k0.toUpper.to!(char[])[0] != _prev_k) { - topics ~= format(q"┃

%s

┃", - k0.toUpper.to!(char[])[0], - k0.toUpper.to!(char[])[0], - ); - _prev_k = k0.toUpper.to!(char[])[0]; - } - if (k0 != "_a") { - topics ~= format(q"┃

%s

┃", - k0.translate([' ' : "_"]), k0,) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln("", k0); - } - if ("_a" in hvst.subject_trees[k0]) { - foreach (t_a_; - hvst.subject_trees[k0]["_a"]["_a"]["_a"] - .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) - ) { - _auth = []; - if (t_a_.author_arr.length < 2) { - _auth = format(q"┃ %s┃", - t_a_.author_surname.translate([' ' : "_"]), - t_a_.author, - ); - } else { - foreach (a; t_a_.author_arr) { - _auth ~= format(q"┃ %s,┃", - t_a_.author_surname.translate([' ' : "_"]), - a, - ); - } - } - topics ~= format(q"┃

"%s" - %s [ %s ]┃", - t_a_.path_html_segtoc, - t_a_.title, - _auth, - t_a_.path_html_metadata, - t_a_.language, - ) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln("- ", t_a_.title, " - ", t_a_.author); - } - } - } - foreach(k1; - hvst.subject_trees[k0].keys - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) - ) { - if (k1 != "_a") { - topics ~= format(q"┃

%s

┃", - k0.translate([' ' : "_"]), - k1.translate([' ' : "_"]), k1,) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" ", k1); - } - if ("_a" in hvst.subject_trees[k0][k1]) { - foreach (t_a_; - hvst.subject_trees[k0][k1]["_a"]["_a"] - .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) - ) { - _auth = []; - if (t_a_.author_arr.length < 2) { - _auth = format(q"┃ %s┃", - t_a_.author_surname.translate([' ' : "_"]), - t_a_.author, - ); - } else { - foreach (a; t_a_.author_arr) { - _auth ~= format(q"┃ %s,┃", - t_a_.author_surname.translate([' ' : "_"]), - a, - ); - } - } - topics ~= format(q"┃

%s - %s [ %s ]┃", - t_a_.path_html_segtoc, - t_a_.title, - _auth, - t_a_.path_html_metadata, - t_a_.language, - ) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" - ", t_a_.title, " - ", t_a_.author); - } - } - } - } - foreach(k2; - hvst.subject_trees[k0][k1].keys - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) - ) { - if (k2 != "_a") { - topics ~= format(q"┃

%s

┃", - k0.translate([' ' : "_"]), k1.translate([' ' : "_"]), - k2.translate([' ' : "_"]), k2,) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" ", k2); - } - if ("_a" in hvst.subject_trees[k0][k1][k2]) { - foreach (t_a_; - hvst.subject_trees[k0][k1][k2]["_a"] - .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) - ) { - _auth = []; - if (t_a_.author_arr.length < 2) { - _auth = format(q"┃ %s┃", - t_a_.author_surname.translate([' ' : "_"]), - t_a_.author, - ); - } else { - foreach (a; t_a_.author_arr) { - _auth ~= format(q"┃ %s,┃", - t_a_.author_surname.translate([' ' : "_"]), - a, - ); - } - } - topics ~= format(q"┃

%s - %s [ %s ]┃", - t_a_.path_html_segtoc, - t_a_.title, - _auth, - t_a_.path_html_metadata, - t_a_.language, - ) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" - ", t_a_.title, " - ", t_a_.author); - } - } - } - } - foreach(k3; - hvst.subject_trees[k0][k1][k2].keys - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) - ) { - if (k3 != "_a") { - topics ~= format(q"┃

%s

┃", - k0.translate([' ' : "_"]), k1.translate([' ' : "_"]), k2.translate([' ' : "_"]), - k3.translate([' ' : "_"]), k3,) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" ", k3); - } - { - foreach (t_a_; - hvst.subject_trees[k0][k1][k2][k3] - .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) - ) { - _auth = []; - if (t_a_.author_arr.length < 2) { - _auth = format(q"┃%s┃", - t_a_.author_surname.translate([' ' : "_"]), - t_a_.author, - ); - } else { - foreach (a; t_a_.author_arr) { - _auth ~= format(q"┃ %s,┃", - t_a_.author_surname.translate([' ' : "_"]), - a, - ); - } - } - topics ~= format(q"┃

%s - %s [ %s ]┃", - t_a_.path_html_segtoc, - t_a_.title, - _auth, - t_a_.path_html_metadata, - t_a_.language, - ) ~ "\n"; - if (_opt_action.show_curate_topics) { - writeln(" - ", t_a_.title, " - ", t_a_.author); - } - } - } - } - } - } - } - } - } - topics - ~= format(q"┃ -


- - - - - - - - -┃") ~ "\n"; - import doc_reform.io_out.paths_output; - auto out_pth = spinePathsHTML!()(_make_and_meta_struct.conf.output_path, ""); - try { - auto f = File(out_pth.curate("topics.html"), "w"); - foreach (o; topics) { - f.writeln(o); - } - } catch (ErrnoException ex) { - // Handle error - } - } -} diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d deleted file mode 100644 index cf4a7cc..0000000 --- a/src/doc_reform/meta/metadoc_from_src.d +++ /dev/null @@ -1,1509 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -// document abstraction: -// abstraction of sisu markup for downstream processing -// metadoc_from_src.d -module doc_reform.meta.metadoc_from_src; -@safe: -template docAbstraction() { - // ↓ abstraction imports - import - std.algorithm, - std.container, - std.file, - std.json, - std.path; - import - doc_reform.meta, - doc_reform.meta.defaults, - doc_reform.meta.rgx, - doc_reform.meta.metadoc_object_setter, - doc_reform.meta.rgx; - public import doc_reform.meta.metadoc_from_src_functions; - mixin docAbstractionFunctions; - @system auto docAbstraction(CMM,Opt,Mf) ( - char[][] markup_sourcefile_content, - CMM conf_make_meta, - Opt opt_action, - Mf manifested, - bool _new_doc - ) { - static auto rgx = RgxI(); - // ↓ abstraction init - scope(success) { - } - scope(failure) { - } - scope(exit) { - destroy(the_document_toc_section); - destroy(the_document_head_section); - destroy(the_document_body_section); - destroy(the_document_bibliography_section); - destroy(the_document_glossary_section); - destroy(the_document_blurb_section); - destroy(the_document_xml_dom_tail_section); - destroy(an_object); - destroy(processing); - destroy(biblio_arr_json); - previous_length = 0; - reset_note_numbers = true; - lev_anchor_tag = ""; - anchor_tag = ""; - } - mixin spineNode; - auto node_para_int_ = node_metadata_para_int; - auto node_para_str_ = node_metadata_para_str; - ObjGenericComposite comp_obj_; - line_occur = [ - "heading" : 0, - "para" : 0, - "glossary" : 0, - "blurb" : 0, - ]; - uint[string] dochas = [ - "inline_links" : 0, - "inline_notes" : 0, - "inline_notes_star" : 0, - "codeblock" : 0, - "table" : 0, - "block" : 0, - "group" : 0, - "poem" : 0, - "quote" : 0, - "images" : 0, - ]; - uint[string] pith = [ - "ocn" : 1, - "section" : 0, - "txt_is" : 0, - "block_is" : 0, - "block_state" : 0, - "block_delim" : 0, - "make_headings" : 0, - "dummy_heading_status" : 0, - "dummy_heading_multiple_objects" : 0, - "no_ocn_multiple_objects" : 0, - "verse_new" : 0, - ]; - string[string] object_number_poem = [ - "start" : "", - "end" : "" - ]; - string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ]; - int[string] lv = [ - "lv" : eN.bi.off, - "h0" : eN.bi.off, - "h1" : eN.bi.off, - "h2" : eN.bi.off, - "h3" : eN.bi.off, - "h4" : eN.bi.off, - "h5" : eN.bi.off, - "h6" : eN.bi.off, - "h7" : eN.bi.off, - "lev_int_collapsed" : 0, - ]; - int[string] collapsed_lev = [ - "h0" : eN.bi.off, - "h1" : eN.bi.off, - "h2" : eN.bi.off, - "h3" : eN.bi.off, - "h4" : eN.bi.off, - "h5" : eN.bi.off, - "h6" : eN.bi.off, - "h7" : eN.bi.off - ]; - string[string] heading_match_str = [ - "h_A": "^(none)", - "h_B": "^(none)", - "h_C": "^(none)", - "h_D": "^(none)", - "h_1": "^(none)", - "h_2": "^(none)", - "h_3": "^(none)", - "h_4": "^(none)" - ]; - Regex!char[string] heading_match_rgx = [ - "h_A": regex(r"^(none)"), - "h_B": regex(r"^(none)"), - "h_C": regex(r"^(none)"), - "h_D": regex(r"^(none)"), - "h_1": regex(r"^(none)"), - "h_2": regex(r"^(none)"), - "h_3": regex(r"^(none)"), - "h_4": regex(r"^(none)") - ]; - string _anchor_tag; - string toc_txt_; - an_object["glossary_nugget"] = ""; - an_object["blurb_nugget"] = ""; - comp_obj_ = set_object_heading("lev4", "frontmatter", "toc", "Table of Contents"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "toc"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.ptr.html_segnames = html_segnames_ptr; - comp_obj_.tags.anchor_tags = ["toc"]; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - auto toc_head = comp_obj_; - html_segnames_ptr_cntr++; - the_document_toc_section = [toc_head]; - static auto mkup = InlineMarkup(); - static auto munge = ObjInlineMarkupMunge(); - auto note_section = NotesSection(); - auto bookindex_extract_hash = BookIndexNuggetHash(); - string[][string] lev4_subtoc; - string[][string] segnames = ["html": ["toc"], "epub": ["toc"]]; - int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; - // abstraction init ↑ - debug (substitutions) { - writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); - if (!(conf_make_meta.make.headings.empty)) { - writeln(conf_make_meta.make.headings); - } - 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]); - } - } - if (conf_make_meta.make.bold) { - writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]); - } - if (conf_make_meta.make.emphasis) { - writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]); - } - if (conf_make_meta.make.italics) { - writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]); - } - } - auto loopMarkupSrcByLine( - char[][] markup_sourcefile_content, - string[string] an_object, - uint[string] pith, - ) { - _loopMarkupSrcByLineStruct ret; - srcDocLoopLineByLine_: - foreach (line; markup_sourcefile_content) { - // ↓ markup document/text line by line - // "line" variable can be empty but should never be null - // scope - scope(exit) { } - scope(failure) { - stderr.writefln( - "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n", - __MODULE__, __FUNCTION__, - __FILE__, __LINE__, - manifested.src.filename, line, - ); - } - debug(source) { writeln(line); } - debug(srclines) { if (!line.empty) { writefln("* %s", line); } } - if (!line.empty) { pith = line._check_ocn_status_(pith); } - if ( pith["block_is"] == eN.blk_is.code - && pith["block_state"] == eN.blk_state.on - ) { - // block object: code - { - ST_txt_by_line_block_generic _get = line.txt_by_line_block_code(an_object, pith); - { - an_object = _get.this_object; - pith = _get.pith; - } - } - continue; - } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { - // object other than "code block" object - // (includes regular text paragraph, headings & blocks other than code) - // heading, glossary, blurb, poem, group, block, quote, table - line = line.inline_markup_faces; // by text line (rather than by text object), linebreaks in para problematic - if (line.matchFirst(rgx.heading_biblio) - || (pith["section"] == eN.sect.bibliography - && ((!(line.matchFirst(rgx.heading_glossary))) - && (!(line.matchFirst(rgx.heading_blurb))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) - ) { - pith["section"] = eN.sect.bibliography; - if (opt_action.backmatter && opt_action.section_biblio) { - { - ST_txt_by_line_block_biblio _get = line.txt_by_line_block_biblio(pith, bib_entry, biblio_entry_str_json, biblio_arr_json); - { - pith = _get.pith; - bib_entry = _get.bib_entry; - biblio_entry_str_json = _get.biblio_entry_str_json; - biblio_arr_json = _get.biblio_arr_json; - } - } - debug(bibliobuild) { - writeln("- ", biblio_entry_str_json); - writeln("-> ", biblio_arr_json.length); - } - } - continue; - } else if (line.matchFirst(rgx.heading_glossary) - || (pith["section"] == eN.sect.glossary - && ((!(line.matchFirst(rgx.heading_biblio))) - && (!(line.matchFirst(rgx.heading_blurb))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) - ) { - // within section (block object): glossary - debug(glossary) { writeln(__LINE__); writeln(line); } - pith["section"] = eN.sect.glossary; - if (opt_action.backmatter && opt_action.section_glossary) { - ST_the_section add_to_glossary_sect = line.build_the_glossary_section(pith, tag_assoc); // double check, should not be necessary to pass pith - the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[0]; - if (add_to_glossary_sect.comp_section_obj.length > 1) { // heading - the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[1]; - } - pith = add_to_glossary_sect.pith; - tag_assoc = add_to_glossary_sect.tag_assoc; - } - continue; - } else if (line.matchFirst(rgx.heading_blurb) - || (pith["section"] == eN.sect.blurb - && ((!(line.matchFirst(rgx.heading_glossary))) - && (!(line.matchFirst(rgx.heading_biblio))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) - ) { - pith["section"] = eN.sect.blurb; - debug(blurb) { writeln(__LINE__); writeln(line); } - if ((opt_action.backmatter && opt_action.section_blurb) && !(line.empty)) { - ST_the_section add_to_blurb_sect = line.build_the_blurb_section(pith, tag_assoc, opt_action); // double check, should not be necessary to pass pith - the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[0]; - if (add_to_blurb_sect.comp_section_obj.length > 1) { // heading - the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[1]; - } - pith = add_to_blurb_sect.pith; - tag_assoc = add_to_blurb_sect.tag_assoc; - } - continue; - } else if (pith["block_state"] == eN.blk_state.on) { - if (pith["block_is"] == eN.blk_is.quote) { - line = line - ._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); - { - an_object = _get.this_object; - pith = _get.pith; - } - } - continue; - } else if (pith["block_is"] == eN.blk_is.group) { - line = line - ._doc_header_and_make_substitutions_(conf_make_meta) - ._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); - { - an_object = _get.this_object; - pith = _get.pith; - } - } - continue; - } else if (pith["block_is"] == eN.blk_is.block) { - line = line - ._doc_header_and_make_substitutions_(conf_make_meta) - ._doc_header_and_make_substitutions_fontface_(conf_make_meta); - if (auto m = line.match(rgx.spaces_keep)) { - line = line - .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); - } - { - auto _get = line.txt_by_line_block_block(an_object, pith); - { - an_object = _get.this_object; - pith = _get.pith; - } - } - 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); - { - an_object = _get.this_object; - pith = _get.pith; - cntr = _get.cntr; - } - } - continue; - } else if (pith["block_is"] == eN.blk_is.table) { - { - auto _get = line.txt_by_line_block_table(an_object, pith, conf_make_meta); - { - an_object = _get.this_object; - pith = _get.pith; - conf_make_meta = _get.conf_make_meta; - } - } - continue; - } - } else { - // not within a block group - assert( - (pith["block_state"] == eN.blk_state.off) - || (pith["block_state"] == eN.blk_state.closing), - "block status: none or closed" - ); - if (line.matchFirst(rgx.block_open)) { - if (line.matchFirst(rgx.block_poem_open)) { - // poem to verse exceptions! - object_reset(an_object); - processing.remove("verse"); - object_number_poem["start"] = obj_cite_digits.object_number.to!string; - } - { - auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem); - { - pith = _get.pith; - dochas = _get.dochas; - object_number_poem = _get.object_number_poem; - } - } - continue; - } else if (!line.empty) { - // line not empty - non blocks (headings, paragraphs) & closed blocks - assert(!line.empty, "line tested, line not empty surely:\n \"" ~ line ~ "\""); - assert( - (pith["block_state"] == eN.blk_state.off) - || (pith["block_state"] == eN.blk_state.closing), - "code block status: none or closed" - ); - if (pith["block_state"] == eN.blk_state.closing) { - debug(check) { writeln(__LINE__); writeln(line); } - assert( - line.matchFirst(rgx.book_index_item) - || line.matchFirst(rgx.book_index_item_open) - || pith["section"] == eN.sect.book_index, - "\nblocks closed, unless followed by book index, non-matching line:\n \"" - ~ line ~ "\"" - ); - } - if (line.matchFirst(rgx.book_index_item) - || 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); - { - an_object = _get.this_object; - pith = _get.pith; - book_idx_tmp = _get.book_idx_tmp; - } - } - } else { - // not book_index - an_object_key = "body_nugget"; - if (auto m = line.matchFirst(rgx.comment)) { - // matched comment - debug(comment) { writeln(line); } - an_object[an_object_key] ~= line ~= "\n"; - comp_obj_comment = comp_obj_comment.init; - comp_obj_comment.metainfo.is_of_part = "comment"; // breaks flow - comp_obj_comment.metainfo.is_of_section = "comment"; // breaks flow - comp_obj_comment.metainfo.is_of_type = "comment"; - comp_obj_comment.metainfo.is_a = "comment"; - 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); - { - line_occur = _get.line_occur; - an_object = _get.this_object; - pith = _get.pith; - } - } - processing.remove("verse"); - ++cntr; - } else if ((line_occur["para"] == eN.bi.off - && line_occur["heading"] == eN.bi.off) - && pith["txt_is"] == eN.txt_is.off - ) { // heading or para but neither flag nor line exists - if ((conf_make_meta.make.headings.length > 2) - && (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); - { - heading_match_str = _get.heading_match_str; - heading_match_rgx = _get.heading_match_rgx; - pith = _get.pith; - } - } - } - if (pith["make_headings"] == eN.bi.on - && (line_occur["para"] == eN.bi.off - && line_occur["heading"] == eN.bi.off) - && pith["txt_is"] == eN.txt_is.off - ) { - // heading make set - { - auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); - { - line = _get.line; - an_object = _get.this_object; - pith = _get.pith; - } - } - } - // TODO node info: all headings identified at this point, - // - extract node info here?? - // - how long can it wait? - // - should be incorporated in composite objects - // - should happen before endnote links set (they need to be moved down?) - if (line.matchFirst(rgx.headings)) { - // heading match - line = line._doc_header_and_make_substitutions_(conf_make_meta); - { - auto _get = line.flow_heading_matched_( - an_object, - line_occur, - an_object_key, - lv, - collapsed_lev, - pith, - conf_make_meta, - ); - { - an_object = _get.this_object; - pith = _get.pith; - } - } - } else if (line_occur["para"] == eN.bi.off) { - // para match - an_object_key = "body_nugget"; - line = line - ._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); - { - an_object = _get.this_object; - an_object_key = _get.this_object_key; - pith = _get.pith; - indent = _get.indent; - bullet = _get.bullet; - line_occur = _get.line_occur; - } - } - } - } else if (line_occur["heading"] > eN.bi.off) { - // heading - debug(heading) { writeln(line); } - an_object[an_object_key] ~= line ~= "\n"; - ++line_occur["heading"]; - } else if (line_occur["para"] > eN.bi.off) { - // paragraph - debug(para) { writeln(an_object_key, "-> ", line); } - line = line - ._doc_header_and_make_substitutions_(conf_make_meta) - ._doc_header_and_make_substitutions_fontface_(conf_make_meta); - an_object[an_object_key] ~= " " ~ line; - ++line_occur["para"]; - } - } - } else if (pith["block_state"] == eN.blk_state.closing) { - // line empty, with blocks flag - { - auto _get = line.flow_block_flag_line_empty_( - an_object, - bookindex_extract_hash, - the_document_body_section, - bookindex_unordered_hashes, - obj_cite_digits, - comp_obj_, - cntr, - pith, - object_number_poem, - conf_make_meta, - tag_in_seg, - ); - { - an_object = _get.this_object; - the_document_body_section = _get.the_document_body_section; - bookindex_unordered_hashes = _get.bookindex_unordered_hashes; - obj_cite_digits = _get.obj_cite_digits; - comp_obj_ = _get.comp_obj_; - cntr = _get.cntr; - pith = _get.pith; - } - } - } else { - // line.empty, post contents, empty variables: - assert( - line.empty, - "\nline should be empty:\n \"" - ~ line ~ "\"" - ); - assert( - (pith["block_state"] == eN.blk_state.off), - "code block status: none" - ); - if (_new_doc) { - tag_assoc = tag_assoc.init; - lv0to3_tags = lv0to3_tags.init; - tag_in_seg = tag_in_seg.init; - } - if (pith["txt_is"] == eN.txt_is.heading - && line_occur["heading"] > eN.bi.off - ) { - // heading object (current line empty) - obj_cite_digits = (an_object["lev_markup_number"].to!int == 0) - ? ocn_emit(eN.ocn.reset) - : ocn_emit(pith["ocn"]); - an_object["is"] = "heading"; - an_object_key = "body_nugget"; - ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_object_and_anchor_tags_struct - = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc)); - an_object["substantive"] = substantive_object_and_anchor_tags_struct.obj_txt; - anchor_tag = substantive_object_and_anchor_tags_struct.anchor_tag; - if (_new_doc) { - cnt1 = 1; - cnt2 = 1; - cnt3 = 1; - _new_doc = false; - } - if ( - an_object["lev_markup_number"].to!int == 4 - && (!(anchor_tag.empty) - || (lv0to3_tags.length > 0)) - ) { - tag_in_seg["seg_lv4"] = anchor_tag; - tag_in_seg["seg_lv1to4"] = anchor_tag; - lev_anchor_tag = anchor_tag; - tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; - tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; - if (lv0to3_tags.length > 0) { - // names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) - foreach (lv0_to_lv3_html_tag; lv0to3_tags) { - tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag; - } - } - anchor_tag_ = anchor_tag; - lv0to3_tags = lv0to3_tags.init; - } else if (an_object["lev_markup_number"].to!int > 4) { - tag_in_seg["seg_lv4"] = anchor_tag_; - tag_in_seg["seg_lv1to4"] = anchor_tag_; - lev_anchor_tag = anchor_tag; - tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; - tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; - } else if (an_object["lev_markup_number"].to!int < 4) { - string segn; - switch (an_object["lev_markup_number"].to!int) { - // names used for epub markup segments A to D - case 0: - segn = "_the_title"; - goto default; - case 1: - segn = "_part_" ~ cnt1.to!string; - ++cnt1; - goto default; - case 2: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; - ++cnt2; - goto default; - case 3: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; - ++cnt3; - goto default; - default: - lv0to3_tags ~= obj_cite_digits.object_number.to!string; - lv0to3_tags ~= segn; - tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known - tag_in_seg["seg_lv1to4"] = segn; - break; - } - } - 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); - _anchor_tag = obj_cite_digits.identifier; - // (incrementally build toc) table of contents here! - { - auto _get = obj_im.flow_table_of_contents_gather_headings( - an_object, - conf_make_meta, - tag_in_seg, - _anchor_tag, - lev4_subtoc, - the_document_toc_section, - ); - { - the_document_toc_section = _get.the_document_toc_section; - lev4_subtoc = _get.lev4_subtoc; - } - } - if (an_object["lev_markup_number"] == "4") { - segnames["html"] ~= tag_in_seg["seg_lv4"]; - html_segnames_ptr = html_segnames_ptr_cntr; - html_segnames_ptr_cntr++; - } - if (an_object["lev_markup_number"].to!int <= 4) { - segnames["epub"] ~= tag_in_seg["seg_lv1to4"]; - } - auto comp_obj_ = node_construct.node_emitter_heading( - an_object, - tag_in_seg, - lev_anchor_tag, - tag_assoc, - obj_cite_digits, // OCNset - cntr, // int - heading_ptr, // int - lv_ancestors_txt, // string[] - html_segnames_ptr, // int - substantive_object_and_anchor_tags_struct, - ); - ++heading_ptr; - debug(segments) { - writeln(an_object["lev_markup_number"]); - writeln(tag_in_seg["seg_lv4"]); - writeln(tag_in_seg["seg_lv1to4"]); - } - the_document_body_section ~= comp_obj_; - debug(objectrelated1) { writeln(line); } // check - { - auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); - { - line_occur = _get.line_occur; - an_object = _get.this_object; - pith = _get.pith; - } - } - an_object.remove("lev"); - an_object.remove("lev_markup_number"); - processing.remove("verse"); - ++cntr; - } else if (pith["txt_is"] == eN.txt_is.para - && line_occur["para"] > eN.bi.off - ) { // paragraph object (current line empty) - repeated character paragraph separator - if ((an_object[an_object_key].to!string).matchFirst(rgx.repeated_character_line_separator)) { - pith["ocn"] = eN.ocn.off; - } - obj_cite_digits = ocn_emit(pith["ocn"]); - 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( - 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", "para", "para", an_object["substantive"].to!string.strip, obj_cite_digits.object_number); - 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_.metainfo.identifier = obj_cite_digits.identifier; - comp_obj_.metainfo.object_number_off = (obj_cite_digits.off == 0) ? true : false; // TODO - comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_.attrib.indent_hang = indent["hang_position"]; - comp_obj_.attrib.indent_base = indent["base_position"]; - comp_obj_.attrib.bullet = bullet; - comp_obj_.tags.anchor_tags = [anchor_tag]; anchor_tag=""; - 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; - 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); - { - auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); - { - line_occur = _get.line_occur; - an_object = _get.this_object; - pith = _get.pith; - } - } - indent = [ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - processing.remove("verse"); - ++cntr; - // } else { // could be useful to test line variable should be empty and never null - } - } // close else for line empty - } // close else for not the above - } // close after non code, other blocks or regular text - // unless (the_document_body_section.length == 0) ? - if (the_document_body_section.length > 0) { - if (((the_document_body_section[$-1].metainfo.is_a == "para") - || (the_document_body_section[$-1].metainfo.is_a == "heading") - || (the_document_body_section[$-1].metainfo.is_a == "quote") - || (the_document_body_section[$-1].metainfo.is_a == "group") - || (the_document_body_section[$-1].metainfo.is_a == "block") - || (the_document_body_section[$-1].metainfo.is_a == "verse")) - && (the_document_body_section.length > previous_length)) { - if ((the_document_body_section[$-1].metainfo.is_a == "heading") - && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) { - pith["section"] = eN.sect.unset; - } - if (the_document_body_section[$-1].metainfo.is_a == "verse") { - // scan for endnotes for whole poem (each verse in poem) - foreach (i; previous_length .. the_document_body_section.length) { - if (the_document_body_section[i].metainfo.is_a == "verse") { - if ((the_document_body_section[i].text).match( - rgx.inline_notes_al_all_note - )) { - object_notes = note_section.gather_notes_for_endnote_section( - the_document_body_section, - tag_in_seg, - (i).to!int, - ); - } - } - } - } else { - // scan object for endnotes - previous_length = the_document_body_section.length.to!int; - if ((the_document_body_section[$-1].text).match( - rgx.inline_notes_al_all_note - )) { - previous_count = (the_document_body_section.length -1).to!int; - object_notes = note_section.gather_notes_for_endnote_section( - the_document_body_section, - tag_in_seg, - (the_document_body_section.length-1).to!int, - ); - } - } - previous_length = the_document_body_section.length.to!int; - } - } - } - ret.toc = the_document_toc_section; - ret.body = the_document_body_section; - ret.glossary = the_document_glossary_section; - ret.blurb = the_document_blurb_section; - ret.object_notes = object_notes; - ret.segnames = segnames; - return ret; - } - { // loopMarkupSrcByLine - auto _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; - the_document_blurb_section = _doc_by_line.blurb; - segnames = _doc_by_line.segnames; - object_notes = _doc_by_line.object_notes; // endnotes, compare, not sure is used - destroy(_doc_by_line); - } - { // EOF backMatter - comp_obj_ = set_object_heading("lev1", "backmatter", "tail", ""); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_eof"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "tail"; - comp_obj_.tags.anchor_tags = ["section_eof"]; - comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0]; - comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0]; - the_document_xml_dom_tail_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } - // endNotes - ST_endnotes en_st = note_section.backmatter_endnote_objects(obj_cite_digits, opt_action); - { // endnotes - the_document_endnotes_section = en_st.endnotes; - obj_cite_digits = en_st.ocn; - debug(endnotes) { - writefln("%s %s", __LINE__, the_document_endnotes_section.length); - foreach (o; the_document_endnotes_section) { writeln(o); } - } - } - { // glossary - if (an_object["glossary_nugget"].length == 0) { - comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Glossary section"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - the_document_glossary_section ~= comp_obj_; - } - debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } } - } - { // bibliography - string[] biblio_unsorted_incomplete = biblio_arr_json.dup; - ST_biblio_section biblio_section = backmatter_make_the_bibliography_section(biblio_unsorted_incomplete, bib_arr_json); - the_document_bibliography_section = biblio_section.bibliography_section; - tag_assoc = biblio_section.tag_assoc; - } - { // bookindex - BookIndexReportSection bi = BookIndexReportSection(); - ST_bookindex bi_st - = bi.backmatter_bookindex_build_abstraction_section(bookindex_unordered_hashes, obj_cite_digits, opt_action); - destroy(bookindex_unordered_hashes); - the_document_bookindex_section = bi_st.bookindex; - obj_cite_digits = bi_st.ocn; - debug(bookindex) { foreach (bi_entry; the_document_bookindex_section) { writeln(bi_entry); } } - } - { // blurb - if (an_object["blurb_nugget"].length == 0) { - comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Blurb section"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = ""; - comp_obj_.tags.anchor_tag_html = ""; - comp_obj_.tags.in_segment_html = ""; - the_document_blurb_section ~= comp_obj_; - } - debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } } - } - { // toc gather backmatter - the_document_toc_section ~= backmatter_gather_table_of_contents(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section); // - } - { // document head and body - the_document_head_section ~= the_document_body_section[0]; - the_document_body_section = the_document_body_section[1..$]; - } - { // document ancestors - ST_ancestors get_ancestors; - get_ancestors = the_document_body_section.after_doc_determine_ancestors(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section); - the_document_body_section = get_ancestors.the_document_body_section; - the_document_endnotes_section = get_ancestors.the_document_endnotes_section; - the_document_glossary_section = get_ancestors.the_document_glossary_section; - the_document_bibliography_section = get_ancestors.the_document_bibliography_section; - the_document_bookindex_section = get_ancestors.the_document_bookindex_section; - the_document_blurb_section = get_ancestors.the_document_blurb_section; - } - { // 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); // - segnames = get_segnames.segnames; - html_segnames_ptr_cntr = get_segnames.html_segnames_ptr_cntr; - html_segnames_ptr = get_segnames.html_segnames_ptr; - } - // document head - string[] segnames_0_to_4; - foreach (ref obj; the_document_head_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - } - if (obj.metainfo.heading_lev_markup == 0) { - // TODO second hit (of two) with same assertion failure, check, fix and reinstate - // assert( obj.metainfo.ocn == 1, - // "Title OCN should be 1 not: " ~ obj.metainfo.ocn.to!string); // bug introduced 0.18.1 - obj.metainfo.ocn = 1; - obj.metainfo.identifier = "1"; - obj.metainfo.object_number_type = OCNtype.ocn; - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } - obj = _links(obj); - } - if (the_document_toc_section.length > 1) { - // scroll - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; - dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; - foreach (ref obj; the_document_toc_section) { - if (obj.metainfo.is_a == "heading") { - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } - obj = _links(obj); - } - } - // images - string[] _images; - // multiple 1~ levels, loop through document body - if (the_document_body_section.length > 1) { - foreach (ref obj; the_document_body_section) { - if (!(obj.metainfo.identifier.empty)) { - if (!(((obj.metainfo.identifier) in tag_assoc) - && ("seg_lv4" in tag_assoc[(obj.metainfo.identifier)])) - ) { - tag_assoc[(obj.metainfo.identifier)]["seg_lv4"] - = obj.tags.html_segment_anchor_tag_is; - } - tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"] - = obj.tags.epub_segment_anchor_tag_is; - } - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } else if (obj.metainfo.is_a == "para") { - _images ~= extract_images(obj.text); - obj = _image_dimensions(obj, manifested); - } - obj = _links(obj); - } - } - auto image_list = (_images.sort()).uniq; - // endnotes optional only one 1~ level - if (the_document_endnotes_section.length > 1) { - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; - dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; - dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; - dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; - foreach (ref obj; the_document_endnotes_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup == 1) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } - obj = _links(obj); - } - } - // glossary optional only one 1~ level - if (the_document_glossary_section.length > 1) { - foreach (ref obj; the_document_glossary_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup == 1) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } else if (obj.metainfo.is_a == "glossary" && !(obj.text.empty)) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - obj = _links(obj); - } - } - // bibliography optional only one 1~ level - if (the_document_bibliography_section.length > 1) { - foreach (ref obj; the_document_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup == 1) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } else if (obj.metainfo.is_a == "bibliography") { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - obj = _links(obj); - } - } - // book index, optional only one 1~ level - int ocn_ = obj_cite_digits.object_number; - int ocn_bkidx_ = 0; - int ocn_bidx_; - if (the_document_bookindex_section.length > 1) { // scroll - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; - dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; - foreach (ref obj; the_document_bookindex_section) { - if (obj.metainfo.is_a == "heading") { - // debug(dom) { } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - } - if (obj.metainfo.heading_lev_markup == 1) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - if (obj.metainfo.heading_lev_markup <= 4) { - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } else if (obj.metainfo.is_a == "bookindex") { - obj_cite_digits = ocn_emit(eN.ocn.bkidx); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; - obj.metainfo.object_number_type = OCNtype.bkidx; - } - obj = _links(obj); - } - // TODO assert failure, reinstate - // assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); - } - // blurb optional only one 1~ level - if (the_document_blurb_section.length > 1) { - foreach (ref obj; the_document_blurb_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup == 1) { - obj_cite_digits = ocn_emit(eN.ocn.on); - obj.metainfo.ocn = obj_cite_digits.object_number; - obj.metainfo.identifier = obj_cite_digits.identifier; - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; - if (segnames["html"].length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; - } - assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], - obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); - } - } - // dom structure (marked up & collapsed) - if (opt_action.meta_processing_xml_dom) { - obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj.obj_heading_ancestors(lv_ancestors_txt); - } else if (obj.metainfo.is_a == "blurb") { - obj_cite_digits = ocn_emit(eN.ocn.off); - obj.metainfo.object_number_off = obj_cite_digits.off; - obj.metainfo.object_number_type = OCNtype.non; - } - obj = _links(obj); - } - } - // get descendants - if (the_document_body_section.length > 1) { - auto pairs = after_doc_get_descendants( - the_document_head_section ~ - the_document_body_section ~ - the_document_endnotes_section ~ - the_document_glossary_section ~ - the_document_bibliography_section ~ - the_document_bookindex_section ~ - the_document_blurb_section ~ - the_document_xml_dom_tail_section - ); - debug(descendants_tuple) { - pairs = pairs.sort(); - foreach (pair; pairs) { // (pair; pairs.sort()) - writeln(pair[0], "..", pair[1]); - } - } - foreach (ref obj; the_document_head_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - if (the_document_body_section.length > 1) { - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_endnotes_section.length > 1) { - foreach (ref obj; the_document_endnotes_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_glossary_section.length > 1) { - foreach (ref obj; the_document_glossary_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_bibliography_section.length > 1) { - foreach (ref obj; the_document_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_bookindex_section.length > 1) { - foreach (ref obj; the_document_bookindex_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_blurb_section.length > 1) { - foreach (ref obj; the_document_blurb_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - if (the_document_xml_dom_tail_section.length > 1) { - foreach (ref obj; the_document_xml_dom_tail_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_descendant_ocn = pair[1]; - } - } - } - } - } - } - // TODO - // - note create/insert heading object sole purpose eof close all open tags - // sort out: - // - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; - // - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; - comp_obj_ = set_object_heading("lev1", "empty", "empty", ""); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = ""; - comp_obj_.tags.anchor_tag_html = ""; - comp_obj_.tags.in_segment_html = ""; - comp_obj_.tags.html_segment_anchor_tag_is = ""; - comp_obj_.tags.epub_segment_anchor_tag_is = ""; - comp_obj_.metainfo.heading_lev_markup = 9; - comp_obj_.metainfo.heading_lev_collapsed = 9; - comp_obj_.metainfo.parent_ocn = 0; - comp_obj_.metainfo.parent_lev_markup = 0; - comp_obj_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; - comp_obj_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; - comp_obj_ = comp_obj_.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, 0); - comp_obj_ = comp_obj_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0); - comp_obj_ = comp_obj_.obj_heading_ancestors(lv_ancestors_txt); - // the_dom_tail_section ~= comp_obj_; // remove tail for now, decide on later - // the doc - ObjGenericComposite[][string] document_the = [ - "head": the_document_head_section, - "toc": the_document_toc_section, - // substantive/body: - "body": the_document_body_section, - // backmatter: - "endnotes": the_document_endnotes_section, - "glossary": the_document_glossary_section, - "bibliography": the_document_bibliography_section, - "bookindex": the_document_bookindex_section, - "blurb": the_document_blurb_section, - // dom tail only - "tail": the_document_xml_dom_tail_section, - ]; - // document parts keys as needed - string[][string] document_section_keys_sequenced = [ - "scroll": ["head", "toc", "body",], - "seg": ["head", "toc", "body",], - "sql": ["head", "body",], - "latex": ["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"; - } - 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"; - } - 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"; - } - 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"; - } - 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"; - } - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub)) { - document_section_keys_sequenced["scroll"] ~= "tail"; - document_section_keys_sequenced["seg"] ~= "tail"; - } - // segnames - string[] segnames_4 = segnames["html"].dup; - string[] segnames_lv1to4 = segnames["epub"].dup; - debug(segnames) { - writeln("segnames_lv4: ", segnames_4); - writeln("segnames_lv1to4: ", segnames_lv1to4); - } - // restart - destroy(the_document_head_section); - destroy(the_document_toc_section); - destroy(the_document_body_section); - destroy(the_document_endnotes_section); - destroy(the_document_glossary_section); - destroy(the_document_bibliography_section); - destroy(the_document_bookindex_section); - destroy(the_document_blurb_section); - destroy(the_document_xml_dom_tail_section); - destroy(segnames); - destroy(bookindex_unordered_hashes); - destroy(an_object); - obj_cite_digits = ocn_emit(eN.ocn.reset); - biblio_arr_json = []; - obj_cite_digit_ = 0; - html_segnames_ptr = 0; - html_segnames_ptr_cntr = 0; - content_non_header = "8"; - dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - lev_anchor_tag = ""; - anchor_tag = ""; - // identify parts - struct DocHas_ { - uint inline_links() { - return dochas["inline_links"]; - } - uint inline_notes_reg() { - return dochas["inline_notes"]; - } - uint inline_notes_star() { - return dochas["inline_notes_star"]; - } - uint codeblocks() { - return dochas["codeblock"]; - } - uint tables() { - return dochas["table"]; - } - uint blocks() { - return dochas["block"]; - } - uint groups() { - return dochas["group"]; - } - uint poems() { - return dochas["poem"]; - } - uint quotes() { - return dochas["quote"]; - } - ulong images() { // TODO not ideal rethink - return (image_list.to!string.strip("[","]").split(",").length); - } - auto imagelist() { - return image_list; - } - auto keys_seq() { - return docSectKeysSeq!()(document_section_keys_sequenced); - } - string[] segnames_lv4() { - return segnames_4; - } - string[] segnames_lv_0_to_4() { - return segnames_0_to_4; - } - string[string][string] tag_associations() { - return tag_assoc; - } - } - auto doc_has() { - return DocHas_(); - } - // the doc to be returned - struct ST_docAbstraction { - ObjGenericComposite[][string] document_the; - DocHas_ doc_has; - } - ST_docAbstraction ret; - { - ret.document_the = document_the; - ret.doc_has = doc_has; - } - return ret; - } // ← closed: abstract doc source -} diff --git a/src/doc_reform/meta/metadoc_from_src_functions.d b/src/doc_reform/meta/metadoc_from_src_functions.d deleted file mode 100644 index 56d5db5..0000000 --- a/src/doc_reform/meta/metadoc_from_src_functions.d +++ /dev/null @@ -1,5216 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -// document abstraction: -// abstraction of sisu markup for downstream processing -// metadoc_from_src.d -module doc_reform.meta.metadoc_from_src_functions; -@safe: -template docAbstractionFunctions() { - // ↓ abstraction imports - import - std.algorithm, - std.container, - std.file, - std.json, - std.path; - import - doc_reform.meta, - doc_reform.meta.defaults, - doc_reform.meta.rgx, - doc_reform.meta.metadoc_object_setter, - doc_reform.meta.rgx; - // ↓ abstraction mixins - mixin ObjectSetter; - mixin InternalMarkup; - mixin spineRgxIn; - static auto rgx = RgxI(); - // initialize - string[string] an_object, processing, object_notes; - string an_object_key; - string[] anchor_tags; - string anchor_tag; - string anchor_tag_; - string[string] tag_in_seg; - string lev_anchor_tag; - string[string][string] tag_assoc; - string[] lv0to3_tags; - // enum - // biblio variables - string biblio_tag_name, biblio_tag_entry, st; - string[] biblio_arr_json; - string biblio_entry_str_json; - JSONValue[] bib_arr_json; - int bib_entry; - // counters - int cntr, previous_count, previous_length; - bool reset_note_numbers = true; - int[string] line_occur; - int html_segnames_ptr = 0; - int html_segnames_ptr_cntr = 0; - int verse_line, heading_ptr; - // paragraph attributes - int[string] indent; - bool bullet = true; - string content_non_header = "8"; - // ocn - OCNset obj_cite_digits; - int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; - int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - static auto obj_im = ObjInlineMarkup(); - static auto obj_att = ObjAttributes(); - auto object_citation_number = OCNemitter(); - auto node_construct = NodeStructureMetadata(); - // ↓ abstraction function emitters - // ↓ - emitters - pure struct OCNemitter { - int ocn_digit, ocn_object_number, ocn_on_, ocn_off_, ocn_bkidx, ocn_bkidx_; - string object_identifier; - bool ocn_is_off; - auto ocn_emitter(int ocn_status_flag) { - OCNset ocn; - assert(ocn_status_flag <= eN.ocn.reset); - ocn_object_number = ocn_bkidx = 0; - object_identifier = ""; - ocn_is_off = false; - switch(ocn_status_flag) with (eN.ocn) { - case reset: - ocn_digit = ocn_on_ = 1; - object_identifier = "1"; - ocn_is_off = false; - ocn_off_ = ocn_bkidx_ = 0; - break; - case on: - ocn_digit = ocn_object_number = ++ocn_on_; - object_identifier = ocn_digit.to!string; - ocn_is_off = false; - break; - case off: - ocn_digit = 0; - ocn_off_ = ++ocn_off_; - object_identifier = "a" ~ ocn_off_.to!string; - ocn_is_off = true; - break; - case bkidx: - ocn_bkidx = ++ocn_bkidx_; - break; - case closing: // unused? - break; - default: - ocn_digit = 0; - } - assert(ocn_digit >= 0); - ocn.digit = ocn_digit; - ocn.object_number = ocn_object_number; // difference between .object_number and .digit? - ocn.identifier = object_identifier; - ocn.off = ocn_is_off; - ocn.bkidx = ocn_bkidx; - ocn.type = ocn_status_flag; - return ocn; - } - invariant() { - } - } - pure ObjGenericComposite obj_heading_ancestors()( - ObjGenericComposite obj, - string[] lv_ancestors_txt, - ) { - switch (obj.metainfo.heading_lev_markup) { - case 0: - lv_ancestors_txt[0] = obj.text.to!string; - foreach(k; 1..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 1: - lv_ancestors_txt[1] = obj.text.to!string; - foreach(k; 2..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 2: - lv_ancestors_txt[2] = obj.text.to!string; - foreach(k; 3..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 3: - lv_ancestors_txt[3] = obj.text.to!string; - foreach(k; 4..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 4: - lv_ancestors_txt[4] = obj.text.to!string; - foreach(k; 5..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 5: - lv_ancestors_txt[5] = obj.text.to!string; - foreach(k; 6..8) { lv_ancestors_txt[k] = ""; } - goto default; - case 6: - lv_ancestors_txt[6] = obj.text.to!string; - lv_ancestors_txt[7] = ""; - goto default; - case 7: - lv_ancestors_txt[7] = obj.text.to!string; - goto default; - default: - obj.tags.heading_ancestors_text = lv_ancestors_txt.dup; - } - return obj; - } - static OCNset ocn_emit(int ocn_status_flag) { - return object_citation_number.ocn_emitter(ocn_status_flag); - } - static uint[string] _check_ocn_status_()( - char[] line, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if (!(line.empty)) { - if (pith["no_ocn_multiple_objects"] == eN.bi.off) { - // not multi-line object, check whether object_number is on or turned off - if (line.matchFirst(rgx.object_number_block_marks)) { // switch off object_number - if (line.matchFirst(rgx.object_number_off_block)) { - pith["no_ocn_multiple_objects"] = eN.bi.on; - pith["ocn"] = eN.ocn.off; - debug(ocnoff) { writeln(line); } - } - if (line.matchFirst(rgx.object_number_off_block_dummy_heading)) { - pith["no_ocn_multiple_objects"] = eN.bi.on; - pith["dummy_heading_multiple_objects"] = eN.bi.on; - pith["ocn"] = eN.ocn.off; - debug(ocnoff) { writeln(line); } - } - } else if (pith["no_ocn_multiple_objects"] == eN.bi.off) { - pith["dummy_heading_status"] = eN.bi.off; - if (pith["dummy_heading_multiple_objects"]) { - pith["dummy_heading_status"] = eN.bi.on; - } - if (line.matchFirst(rgx.object_number_off)) { - pith["ocn"] = eN.ocn.off; - } else if (line.matchFirst(rgx.object_number_off_dummy_heading)) { - pith["ocn"] = eN.ocn.off; - pith["dummy_heading_status"] = eN.bi.on; - } else { - pith["ocn"] = eN.ocn.on; - pith["dummy_heading_status"] = eN.bi.off; - } - } else { - pith["ocn"] = pith["no_ocn_multiple_objects"]; - } - } else if (pith["no_ocn_multiple_objects"] == eN.bi.on) { - if (line.matchFirst(rgx.object_number_off_block_close)) { - pith["no_ocn_multiple_objects"] = eN.bi.off; - pith["ocn"] = eN.ocn.on; - pith["dummy_heading_status"] = eN.bi.off; - debug(ocnoff) { writeln(line); } - } - } - } - return pith; - } - // ↑ - emitters ↑ - // ↓ abstraction functions - // ↓ - reset text by line - @system ST_txt_by_line_common_reset txt_by_line_common_reset_()( - int[string] line_occur, - string[string] an_object, - uint[string] pith, - ) { - line_occur["heading"] = eN.bi.off; - line_occur["para"] = eN.bi.off; - pith["txt_is"] = eN.txt_is.off; - an_object = an_object.object_reset; - ST_txt_by_line_common_reset ret; - { - ret.line_occur = line_occur; - ret.this_object = an_object; - ret.pith = pith; - } - return ret; - } - // ↓ - reset object - static string[string] object_reset()(string[string] an_object) { - an_object.remove("body_nugget"); - an_object.remove("substantive"); - an_object.remove("is"); - an_object.remove("attrib"); - an_object.remove("bookindex_nugget"); - return an_object; - } - // ↑ - resets - // ↓ - markup text by line - char[] font_faces_line()(char[] textline) { - static auto rgx = RgxI(); - static auto mkup = InlineMarkup(); - if (textline.match(rgx.inline_faces_line)) { - textline = textline - .replaceFirst(rgx.inline_emphasis_line, - format(q"┃%s%s%s%s%s%s%s┃", - mkup.ff_i, mkup.emph, mkup.ff_o, "$1", mkup.ff_c, mkup.emph, "$2")) - .replaceFirst(rgx.inline_bold_line, - format(q"┃%s%s%s%s%s%s%s┃", - mkup.ff_i, mkup.bold, mkup.ff_o, "$1", mkup.ff_c, mkup.bold, "$2")) - .replaceFirst(rgx.inline_underscore_line, - format(q"┃%s%s%s%s%s%s%s┃", - mkup.ff_i, mkup.underscore, mkup.ff_o, "$1", mkup.ff_c, mkup.underscore, "$2")) - .replaceFirst(rgx.inline_italics_line, - format(q"┃%s%s%s%s%s%s%s┃", - mkup.ff_i, mkup.italic, mkup.ff_o, "$1", mkup.ff_c, mkup.italic, "$2")); - } - return textline; - } - auto inline_markup_faces(L)(L line) { - static auto rgx = RgxI(); - static auto mkup = InlineMarkup(); - line = replaceAll!(m => mkup.quote_o ~ m[1] ~ mkup.quote_c)(line, rgx.within_quotes); - line = replaceAll!(m => mkup.ff_i ~ mkup.mono ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.mono)(line, rgx.inline_mark_mono); - line = replaceAll!(m => mkup.ff_i ~ mkup.cite ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.cite)(line, rgx.inline_mark_cite); - foreach (regx; [rgx.inline_mark_emphasis, rgx.inline_mark_bold, rgx.inline_mark_underscore, rgx.inline_mark_italics, rgx.inline_mark_superscript, rgx.inline_mark_subscript, rgx.inline_mark_strike, rgx.inline_mark_insert]) { - line = replaceAll!(m => mkup.ff_i ~ m["mark"] ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ m["mark"])(line, regx); - } - return line; - } - static string links_and_images()(string obj_txt) { - static auto rgx = RgxI(); - static auto mkup = InlineMarkup(); - if (obj_txt.match(rgx.smid_inline_url_generic)) { - if ( - obj_txt.match(rgx.smid_inline_link_endnote_url_helper) - || obj_txt.match(rgx.smid_inline_link_endnote_url_helper_punctuated) - ) { - obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s%s", - mkup.lnk_o, m["content"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c, - mkup.en_a_o, - mkup.lnk_o, m["link"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c, - mkup.en_a_c, - m[3] - ))(obj_txt, rgx.smid_inline_link_endnote_url_helper_punctuated); - obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s", - mkup.lnk_o, m["content"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c, - mkup.en_a_o, - mkup.lnk_o, m["link"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c, - mkup.en_a_c - ))(obj_txt, rgx.smid_inline_link_endnote_url_helper); - } else { - obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s", - m["pre"], - mkup.lnk_o, m["content"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c - ))(obj_txt, rgx.smid_inline_link_markup_regular); - } - obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s", - m["pre"], - mkup.lnk_o, m["link"].strip, mkup.lnk_c, - mkup.url_o, m["link"], mkup.url_c - ))(obj_txt, rgx.smid_inline_link_naked_url); // - } - return obj_txt; - } - char[] _doc_header_and_make_substitutions_(CMM)( - char[] line, - CMM conf_make_meta, - ) { - enum Substitute { match, markup, } - if (conf_make_meta.make.substitute) { - foreach(substitution_pair; conf_make_meta.make.substitute) { - line = line.replaceAll( - regex("\b" ~ substitution_pair[Substitute.match]), - substitution_pair[Substitute.markup] - ); - } - } - return line; - } - char[] _doc_header_and_make_substitutions_fontface_(CMM)( - char[] line, - CMM conf_make_meta, - ) { - enum Substitute { match, markup, } - if ( conf_make_meta.make.bold) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.bold[Substitute.match]), - conf_make_meta.make.bold[Substitute.markup] - ); - } - if (conf_make_meta.make.emphasis) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.emphasis[Substitute.match]), - conf_make_meta.make.emphasis[Substitute.markup] - ); - } - if (conf_make_meta.make.italics) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.italics[Substitute.match]), - conf_make_meta.make.italics[Substitute.markup] - ); - } - return line; - } - // ↑ - markup by line - // ↓ - text by line (blocks etc.) - ST_txt_by_line_block_start txt_by_line_block_start()( - char[] line, - uint[string] pith, - uint[string] dochas, - string[string] object_number_poem - ) { - static auto rgx = RgxI(); - if (auto m = line.matchFirst(rgx.block_curly_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(codecurly) { writefln( "* [code curly] %s", line); } // code (curly) open - pith["block_is"] = eN.blk_is.code; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.curly; - } else if (auto m = line.matchFirst(rgx.block_curly_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 curly] %s", line); } // poem (curly) open - 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.curly; - pith["verse_new"] = eN.bi.on; - } else if (auto m = line.matchFirst(rgx.block_curly_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 curly] %s", line); } // group (curly) open - pith["block_is"] = eN.blk_is.group; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.curly; - } else if (auto m = line.matchFirst(rgx.block_curly_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 curly] %s", line); } - pith["block_is"] = eN.blk_is.block; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.curly; - } else if (auto m = line.matchFirst(rgx.block_curly_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 curly] %s", line); } - pith["block_is"] = eN.blk_is.quote; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.curly; - } else if (auto m = line.matchFirst(rgx.block_curly_table_open)) { // curly table open - debug(table) { writefln( "* [table curly] %s", line); } - dochas["table"] ++; - an_object["table_head"] = m["attrib"].to!string; - an_object["block_type"] = "curly"; - pith["block_is"] = eN.blk_is.table; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.curly; - } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { // table: special table block markup syntax! - dochas["table"]++; - an_object["table_head"] = m["attrib"].to!string; - an_object["block_type"] = "special"; - 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_tic_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(codetic) { writefln( "* [code tic] %s", line); } - pith["block_is"] = eN.blk_is.code; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.tic; - } else if (auto m = line.matchFirst(rgx.block_tic_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 tic] %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.tic; - pith["verse_new"] = eN.bi.on; - } else if (auto m = line.matchFirst(rgx.block_tic_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 tic] %s", line); } - pith["block_is"] = eN.blk_is.group; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.tic; - } else if (auto m = line.matchFirst(rgx.block_tic_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 tic] %s", line); } - pith["block_is"] = eN.blk_is.block; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.tic; - } else if (auto m = line.matchFirst(rgx.block_tic_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 tic] %s", line); // quote (tic) open - } - pith["block_is"] = eN.blk_is.quote; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.tic; - } else if (auto m = line.matchFirst(rgx.block_tic_table_open)) { // tic table open - debug(table) { writefln( "* [table tic] %s", line); } - dochas["table"] ++; - an_object["table_head"] = m["attrib"].to!string; - an_object["block_type"] = "tic"; - pith["block_is"] = eN.blk_is.table; - pith["block_state"] = eN.blk_state.on; - pith["block_delim"] = eN.blk_delim.tic; - } - ST_txt_by_line_block_start ret; - { - ret.pith = pith; - ret.dochas = dochas; - ret.object_number_poem = object_number_poem; - } - return ret; - } - ST_txt_by_line_block_generic txt_by_line_block_group()( - char[] line, - string[string] an_object, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if (pith["block_is"] == eN.blk_is.group) { - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_group_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); } - 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"; - } - } - } - ST_txt_by_line_block_generic ret; - { - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - ST_txt_by_line_block_generic txt_by_line_block_block()( - char[] line, - string[string] an_object, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if (pith["block_is"] == eN.blk_is.block) { - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_block_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); } - 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"; - } - } - } - ST_txt_by_line_block_generic ret; - { - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - ST_txt_by_line_block_poem txt_by_line_block_poem(CMM)( - char[] line, - string[string] an_object, - uint[string] pith, - int cntr, - string[string] object_number_poem, - CMM conf_make_meta, - string[string] tag_in_seg, - ) { - static auto rgx = RgxI(); - if (pith["block_is"] == eN.blk_is.poem) { - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_poem_close)) { - if (an_object_key in an_object - || processing.length > 0) { - an_object[an_object_key] = ""; - debug(poem) { writefln( "* [poem curly] %s", line); } - if (processing.length > 0) { - an_object[an_object_key] = processing["verse"]; - } - debug(poem) { - writeln(__LINE__); - writefln( "* %s %s", obj_cite_digits.object_number, line); - } - if (an_object.length > 0) { - debug(poem) { writeln( obj_cite_digits.object_number, an_object[an_object_key]); } - 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_reset(an_object); - processing.remove("verse"); - ++cntr; - } - object_number_poem["end"] = obj_cite_digits.object_number.to!string; - 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; - verse_line = eN.bi.off; - pith["verse_new"] = eN.bi.on; - } - if (pith["verse_new"] == eN.bi.on) { - verse_line = 1; - an_object[an_object_key] = processing["verse"]; - debug(poem) { writefln( - "* %s curly\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"; - debug(poem) { writefln( "* [poem tic] %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; - } - } - } - } - ST_txt_by_line_block_poem ret; - { - ret.cntr = cntr; - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - ST_txt_by_line_block_generic txt_by_line_block_code()( - char[] line, - string[string] an_object, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if ( pith["block_is"] == eN.blk_is.code) { - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_code_close)) { - debug(codecurly) { 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(codecurly) { 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); } - 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(codetic) { writeln(line); } - an_object[an_object_key] ~= line ~= "\n"; - } - } - } - ST_txt_by_line_block_generic ret; - { - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - @system auto txt_by_line_block_table(CMM)( - char[] line, - string[string] an_object, - uint[string] pith, - CMM conf_make_meta, - ) { - static auto rgx = RgxI(); - if (pith["block_is"] == eN.blk_is.table) { - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_table_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.curly_special) { - if (line.empty) { - pith["block_is"] = eN.blk_is.table; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - { - auto _get = line.flow_table_closed_make_special_notation_table_( - an_object, - the_document_body_section, - obj_cite_digits, - comp_obj_, - cntr, - pith, - conf_make_meta, - ); - { - an_object = _get.this_object; - the_document_body_section = _get.the_document_body_section; - obj_cite_digits = _get.obj_cite_digits; - comp_obj_ = _get.comp_obj_; - cntr = _get.cntr; - pith = _get.pith; - } - } - } 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); } - 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"; - } - } - } - struct ST_txt_by_line_block_table { - CMM conf_make_meta; - uint[string] pith; - string[string] this_object; - } - ST_txt_by_line_block_table ret; - { - ret.conf_make_meta = conf_make_meta, - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - ST_txt_by_line_block_generic txt_by_line_block_quote()( - char[] line, - string[string] an_object, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if (pith["block_is"] == eN.blk_is.quote){ - if (pith["block_delim"] == eN.blk_delim.curly) { - if (line.matchFirst(rgx.block_curly_quote_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); } - 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"; - } - } - } - ST_txt_by_line_block_generic ret; - { - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - @system ST_txt_by_line_block_biblio txt_by_line_block_biblio( - char[] line, - uint[string] pith, - int bib_entry, - string biblio_entry_str_json, - string[] biblio_arr_json, - ) { - mixin spineBiblio; - auto jsn = BibJsnStr(); - static auto rgx = RgxI(); - string biblio_tag_map()(string abr) { - auto btm = [ - "au" : "author_raw", - "ed" : "editor_raw", - "ti" : "fulltitle", - "lng" : "language", - "jo" : "journal", - "vol" : "volume", - "edn" : "edition", - "yr" : "year", - "pl" : "place", - "pb" : "publisher", - "pub" : "publisher", - "pg" : "pages", - "pgs" : "pages", - "sn" : "short_name" - ]; - return btm[abr]; - } - if (line.matchFirst(rgx.heading_biblio)) { - pith["section"] = eN.sect.bibliography; - } - if (line.empty) { - debug { - debug(biblioblock) { writeln("---"); } - debug(biblioblockinclude) { writeln(biblio_entry_str_json.length); } - } - if ((bib_entry == eN.bi.off) - && (biblio_entry_str_json.empty)) { - bib_entry = eN.bi.on; - biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; - } else if (!(biblio_entry_str_json.empty)) { - bib_entry = eN.bi.off; - if (!(biblio_entry_str_json == jsn.biblio_entry_tags_jsonstr)) { - auto biblio_entry = parseJSON(biblio_entry_str_json); - if (biblio_entry["fulltitle"].str.empty) { - writeln("check problem entry (Title missing): ", biblio_entry_str_json); - } else if ((biblio_entry["author_raw"].str.empty) && (biblio_entry["editor_raw"].str.empty)) { - writeln("check problem entry (No author and no editor): ", biblio_entry_str_json); - } else { - biblio_arr_json ~= biblio_entry_str_json; - } - biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; - } - } else { - writeln("?? 2. ERROR ", biblio_entry_str_json, "??"); - biblio_entry_str_json = ""; - } - } else if (line.matchFirst(rgx.biblio_tags)) { - debug(biblioblock) { writeln(line); } - auto bt = line.match(rgx.biblio_tags); - bib_entry = eN.bi.off; - st = bt.captures[1].to!string; - auto header_tag_value = (bt.captures[2]).to!string; - JSONValue j = parseJSON(biblio_entry_str_json); - biblio_tag_name = (st.match(rgx.biblio_abbreviations)) - ? (biblio_tag_map(st)) - : st; - j.object[biblio_tag_name] = header_tag_value; - debug(bibliounsortedcheckduplicates) { writeln(biblio_tag_name, ": ", header_tag_value); writeln("--"); } - switch (biblio_tag_name) { - case "author_raw": // author_arr author (fn sn) - j["author_arr"] - = header_tag_value.split(rgx.arr_delimiter); - string tmp; - biblioAuthorLoop: - foreach (au; j["author_arr"].array) { - if (auto x = au.str.match(rgx.name_delimiter)) { - tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; - } else { - tmp ~= au.str; - } - } - tmp = tmp.replace(rgx.trailing_comma, ""); - j["author"].str = tmp; - goto default; - case "editor_raw": // editor_arr editor (fn sn) - j["editor_arr"] - = header_tag_value.split(rgx.arr_delimiter); - string tmp; - biblioEditorLoop: - foreach (ed; j["editor_arr"].array) { - if (auto x = ed.str.match(rgx.name_delimiter)) { - tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; - } else { - tmp ~= ed.str; - } - } - tmp = tmp.replace(rgx.trailing_comma, ""); - j["editor"].str = tmp; - goto default; - case "fulltitle": // title & subtitle - goto default; - default: - break; - } - auto s = j.toString(); - debug(biblio1) { writefln( - "* %s: %s\n%s", - biblio_tag_name, - biblio_tag_entry, - j[biblio_tag_name] - ); - } - if (line.match(rgx.comment)) { - writeln("ERROR", line, "COMMENT"); - writeln("ERROR", s, "%%"); - } - if (!(match(line, rgx.comment))) { - debug(biblioblockinclude) { writeln(line); } - biblio_entry_str_json = s; - } else { - biblio_entry_str_json = ""; - } - header_tag_value = ""; - } - ST_txt_by_line_block_biblio ret; - { - ret.pith = pith; - ret.bib_entry = bib_entry; - ret.biblio_entry_str_json = biblio_entry_str_json; - ret.biblio_arr_json = biblio_arr_json; - } - return ret; - } - // ↑ - text by line - // ↓ - para - string[string][string] inline_para_link_anchor()( - string[string] an_object, - string[string] tag_in_seg, - string[string][string] tag_assoc - ) { - static auto rgx = RgxI(); - if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) { - if (m.captures[1] !in tag_assoc) { - tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"]; - tag_assoc[(m.captures[1])]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; - } else { - writeln("a tag named already exists, check text line\n ", an_object["substantive"]); - } - } - return tag_assoc; - } - ST_flow_para_match flow_para_match_()( - char[] line, - string[string] an_object, - string an_object_key, - int[string] indent, - bool bullet, - uint[string] pith, - int[string] line_occur, - ) { - static auto rgx = RgxI(); - if (line_occur["para"] == eN.bi.off) { - line = font_faces_line(line); - // para matches - pith["txt_is"] = eN.txt_is.para; - an_object[an_object_key] ~= line; - indent = [ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - if (auto m = line.matchFirst(rgx.para_indent)) { - debug(paraindent) { writeln(line); } - indent["hang_position"] = (m["indent"]).to!int; - indent["base_position"] = (m["indent"]).to!int; - } else if (line.matchFirst(rgx.para_bullet)) { - debug(parabullet) { writeln(line); } - bullet = true; - } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { - debug(paraindenthang) { writeln(line); } - indent = [ - "hang_position" : (m["hang"]).to!int, - "base_position" : (m["indent"]).to!int, - ]; - } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { - debug(parabulletindent) { writeln(line); } - indent = [ - "hang_position" : (m["indent"]).to!int, - "base_position" : (m["indent"]).to!int, - ]; - bullet = true; - } - ++line_occur["para"]; - } - ST_flow_para_match ret; - { - ret.pith = pith; - ret.this_object = an_object; - ret.this_object_key = an_object_key; - ret.indent = indent; - ret.bullet = bullet; - ret.line_occur = line_occur; - } - return ret; - } - // ↑ - para - // ↓ - heading - ST_flow_heading_found flow_heading_found_()( - char[] line, - string[string] heading_match_str, - string[] _make_unmarked_headings, - Regex!(char)[string] heading_match_rgx, - uint[string] pith, - ) { - static auto rgx = RgxI(); - if ((_make_unmarked_headings.length > 2) - && (pith["make_headings"] == eN.bi.off)) { // headings found - debug(headingsfound) { writeln(_make_unmarked_headings); } - debug(headingsfound) { - writeln(_make_unmarked_headings.length); - writeln(_make_unmarked_headings); - } - switch (_make_unmarked_headings.length) { - case 7 : - if (!empty(_make_unmarked_headings[6])) { - heading_match_str["h_4"] - = "^(" ~ _make_unmarked_headings[6].to!string ~ ")"; - heading_match_rgx["h_4"] - = regex(heading_match_str["h_4"]); - } - goto case; - case 6 : - if (!empty(_make_unmarked_headings[5])) { - heading_match_str["h_3"] - = "^(" ~ _make_unmarked_headings[5].to!string ~ ")"; - heading_match_rgx["h_3"] - = regex(heading_match_str["h_3"]); - } - goto case; - case 5 : - if (!empty(_make_unmarked_headings[4])) { - heading_match_str["h_2"] - = "^(" ~ _make_unmarked_headings[4].to!string ~ ")"; - heading_match_rgx["h_2"] - = regex(heading_match_str["h_2"]); - } - goto case; - case 4 : - if (!empty(_make_unmarked_headings[3])) { - heading_match_str["h_1"] - = "^(" ~ _make_unmarked_headings[3].to!string ~ ")"; - heading_match_rgx["h_1"] - = regex(heading_match_str["h_1"]); - } - goto case; - case 3 : - if (!empty(_make_unmarked_headings[2])) { - heading_match_str["h_D"] - = "^(" ~ _make_unmarked_headings[2].to!string ~ ")"; - heading_match_rgx["h_D"] - = regex(heading_match_str["h_D"]); - } - goto case; - case 2 : - if (!empty(_make_unmarked_headings[1])) { - heading_match_str["h_C"] - = "^(" ~ _make_unmarked_headings[1].to!string ~ ")"; - heading_match_rgx["h_C"] - = regex(heading_match_str["h_C"]); - } - goto case; - case 1 : - if (!empty(_make_unmarked_headings[0])) { - heading_match_str["h_B"] - = "^(" ~ _make_unmarked_headings[0].to!string ~ ")"; - heading_match_rgx["h_B"] - = regex(heading_match_str["h_B"]); - } - break; - default: - break; - } - pith["make_headings"] = eN.bi.on; - } - ST_flow_heading_found ret; - { - ret.heading_match_str = heading_match_str; - ret.heading_match_rgx = heading_match_rgx; - ret.pith = pith; - } - return ret; - } - ST_flow_heading_make_set flow_heading_make_set_()( - char[] line, - int[string] line_occur, - return ref Regex!(char)[string] heading_match_rgx, - return ref uint[string] pith, - ) { - if (pith["make_headings"] == eN.bi.on - && (line_occur["para"] == eN.bi.off - && line_occur["heading"] == eN.bi.off) - && pith["txt_is"] == eN.txt_is.off - ) { // heading make set - if (line.matchFirst(heading_match_rgx["h_B"])) { - line = "B~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_C"])) { - line = "C~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_D"])) { - line = "D~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_1"])) { - line = "1~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_2"])) { - line = "2~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_3"])) { - line = "3~ " ~ line; - debug(headingsfound) { writeln(line); } - } - if (line.matchFirst(heading_match_rgx["h_4"])) { - line = "4~ " ~ line; - debug(headingsfound) { writeln(line); } - } - } - ST_flow_heading_make_set ret; - { - ret.line = line; - ret.pith = pith; - ret.this_object = an_object; - } - return ret; - } - auto flow_heading_matched_(CMM)( - char[] line, - string[string] an_object, - int[string] line_occur, - string an_object_key, - int[string] lv, - int[string] collapsed_lev, - uint[string] pith, - CMM conf_make_meta, - ) { - static auto rgx = RgxI(); - static auto mkup = InlineMarkup(); - if (auto m = line.match(rgx.headings)) { // heading match - ++line_occur["heading"]; - pith["txt_is"] = eN.txt_is.heading; - if (line.match(rgx.heading_seg_and_above)) { - pith["section"] = eN.sect.unset; - } - an_object[an_object_key] ~= line ~= "\n"; - an_object["lev"] ~= m.captures[1]; - assertions_doc_structure(an_object, an_object_key, lv); // includes most of the logic for collapsed levels - switch (an_object["lev"]) { - case "A": // Title set - if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) - || (an_object[an_object_key].match(rgx.variable_doc_title) - && an_object[an_object_key].match(rgx.variable_doc_author) - && an_object[an_object_key].match(rgx.variable_doc_date))) { - an_object[an_object_key] = an_object[an_object_key] - .replaceFirst(rgx.variable_doc_title_author_date, - (conf_make_meta.meta.title_full - ~ mkup.br_line_inline - ~ conf_make_meta.meta.creator_author - ~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")")) - .replaceFirst(rgx.variable_doc_title, - (conf_make_meta.meta.title_full ~ mkup.br_line_inline)) - .replaceFirst(rgx.variable_doc_author, - conf_make_meta.meta.creator_author) - .replaceFirst(rgx.variable_doc_date, - " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"); - } else if ((an_object[an_object_key].match(rgx.variable_doc_title_author)) - || (an_object[an_object_key].match(rgx.variable_doc_title) - && an_object[an_object_key].match(rgx.variable_doc_author))) { - an_object[an_object_key] = an_object[an_object_key] - .replaceFirst(rgx.variable_doc_title_author_date, - (conf_make_meta.meta.title_full - ~ mkup.br_line_inline - ~ conf_make_meta.meta.creator_author)) - .replaceFirst(rgx.variable_doc_title, - (conf_make_meta.meta.title_full ~ mkup.br_line_inline)) - .replaceFirst(rgx.variable_doc_author, - conf_make_meta.meta.creator_author); - } else if (an_object[an_object_key].match(rgx.variable_doc_title)) { - an_object[an_object_key] = an_object[an_object_key] - .replaceFirst(rgx.variable_doc_title, - conf_make_meta.meta.title_full); - } - collapsed_lev["h0"] = 0; - an_object["lev_collapsed_number"] - = collapsed_lev["h0"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_A; - ++lv["h0"]; - lv["h1"] = eN.bi.off; - lv["h2"] = eN.bi.off; - lv["h3"] = eN.bi.off; - lv["h4"] = eN.bi.off; - lv["h5"] = eN.bi.off; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "B": - collapsed_lev["h1"] = collapsed_lev["h0"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h1"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_B; - ++lv["h1"]; - lv["h2"] = eN.bi.off; - lv["h3"] = eN.bi.off; - lv["h4"] = eN.bi.off; - lv["h5"] = eN.bi.off; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "C": - collapsed_lev["h2"] = collapsed_lev["h1"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h2"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_C; - ++lv["h2"]; - lv["h3"] = eN.bi.off; - lv["h4"] = eN.bi.off; - lv["h5"] = eN.bi.off; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "D": - collapsed_lev["h3"] = collapsed_lev["h2"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h3"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_D; - ++lv["h3"]; - lv["h4"] = eN.bi.off; - lv["h5"] = eN.bi.off; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "1": - if (lv["h3"] > eN.bi.off) { - collapsed_lev["h4"] = collapsed_lev["h3"] + 1; - } else if (lv["h2"] > eN.bi.off) { - collapsed_lev["h4"] = collapsed_lev["h2"] + 1; - } else if (lv["h1"] > eN.bi.off) { - collapsed_lev["h4"] = collapsed_lev["h1"] + 1; - } else if (lv["h0"] > eN.bi.off) { - collapsed_lev["h4"] = collapsed_lev["h0"] + 1; - } - an_object["lev_collapsed_number"] - = collapsed_lev["h4"].to!string; - lv["lv"] = DocStructMarkupHeading.h_text_1; - ++lv["h4"]; - lv["h5"] = eN.bi.off; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "2": - if (lv["h5"] > eN.bi.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h5"].to!string; - } else if (lv["h4"] > eN.bi.off) { - collapsed_lev["h5"] = collapsed_lev["h4"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h5"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_2; - ++lv["h5"]; - lv["h6"] = eN.bi.off; - lv["h7"] = eN.bi.off; - goto default; - case "3": - if (lv["h6"] > eN.bi.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h6"].to!string; - } else if (lv["h5"] > eN.bi.off) { - collapsed_lev["h6"] = collapsed_lev["h5"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h6"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_3; - ++lv["h6"]; - lv["h7"] = eN.bi.off; - goto default; - case "4": - if (lv["h7"] > eN.bi.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h7"].to!string; - } else if (lv["h6"] > eN.bi.off) { - collapsed_lev["h7"] = collapsed_lev["h6"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h7"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_4; - ++lv["h7"]; - goto default; - default: - an_object["lev_markup_number"] = lv["lv"].to!string; - } - an_object["dummy_heading_status"] = (pith["dummy_heading_status"] == eN.bi.off) ? "f" : "t"; - debug(heading) { writeln(line.strip); } - } - struct ST_flow_heading_matched { - string[string] this_object; - int[string] line_occur; - string an_object_key; - int[string] lv; - int[string] collapsed_lev; - uint[string] pith; - CMM conf_make_meta; - } - ST_flow_heading_matched ret; - { - ret.this_object = an_object; - ret.line_occur = line_occur; - ret.an_object_key = an_object_key; - ret.lv = lv; - ret.collapsed_lev = collapsed_lev; - ret.pith = pith; - ret.conf_make_meta = conf_make_meta; - } - return ret; - } - // ↑ - heading - // ↓ - table - ObjGenericComposite flow_table_instructions(H)( - ObjGenericComposite table_object, - H table_head, - ) { - static auto rgx = RgxI(); - table_object.metainfo.is_of_part = "body"; - table_object.metainfo.is_of_section = "body"; - table_object.metainfo.is_of_type = "block"; - table_object.metainfo.is_a = "table"; - table_object.has.inline_notes_reg = false; - table_object.has.inline_notes_star = false; - table_object.has.inline_links = false; - if (auto m = table_head.matchFirst(rgx.table_head_instructions)) { - table_object.table.heading - = ((m["c_heading"].length > 0) && (m["c_heading"] == "h")) ? true : false; - table_object.table.number_of_columns - = ((m["c_num"].length > 0) && (m["c_num"].to!int > 0)) ? m["c_num"].to!int : 0; - foreach (cw; m["c_widths"].matchAll(rgx.table_col_widths)) { - auto x = cw.hit.matchFirst(rgx.table_col_widths_and_alignment); - table_object.table.column_widths ~= x["width"].to!int; - table_object.table.column_aligns ~= (x["align"].empty) ? "" : x["align"]; - } - } - return table_object; - } - ST_flow_table_array_munge flow_table_array_munge()( - ObjGenericComposite table_object, - string[][] table_array, - ) { - static auto rgx = RgxI(); - static auto mng = InlineMarkup(); - string _table_substantive; - ulong col_num; - ulong col_num_; - ulong col_num_chk = 0; - foreach(idx_r, row; table_array) { - debug(table_dev) { writeln("row ", idx_r); } - col_num_ = 0; - if (col_num == 0 - || col_num < row.length) { - col_num = row.length; - } - if (col_num_chk == 0) { - col_num_chk = col_num; - } else if (col_num == 1) { - debug(table_dev) { writeln("table note: "); } - } else if (col_num_chk != col_num) { - debug(table_dev) { writeln("warning irregular number of columns: ", col_num_chk, " != ", col_num); } - } else { - } - foreach(idx_c, col; row) { - debug(table_dev) { write(idx_c, ", "); } - col_num_ = idx_c; - _table_substantive ~= col ~ mng.tc_s; - if (idx_r == 0 && table_object.table.heading) { - } else if (col.match(rgx.numeric_col) && idx_r == 1) { // conditions reversed to avoid: gdc compiled program run segfault - if ((table_object.table.column_aligns.length > idx_c) - && (table_object.table.column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { - table_object.table.column_aligns[idx_c] = table_object.table.column_aligns[idx_c]; - } else if (table_object.table.column_aligns.length > idx_c) { - table_object.table.column_aligns[idx_c] = "r"; - } else { - table_object.table.column_aligns ~= "r"; - } - } else if (idx_r == 1) { - if ((table_object.table.column_aligns.length > idx_c) - && (table_object.table.column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { - table_object.table.column_aligns[idx_c] = table_object.table.column_aligns[idx_c]; - } else if (table_object.table.column_aligns.length > idx_c) { - table_object.table.column_aligns[idx_c] = "l"; - } else { - table_object.table.column_aligns ~= "l"; - } - } - } - debug(table_dev) { writeln(""); } - if (col_num_chk > 0 && (col_num != col_num_chk)) { - } else if (col_num == col_num_chk){ - } else { - col_num_chk = col_num; - } - _table_substantive = _table_substantive.replaceFirst(rgx.table_col_separator_nl, "\n"); - } - if (table_object.table.number_of_columns != col_num) { - if (table_object.table.number_of_columns == 0) { - table_object.table.number_of_columns = (col_num).to!int; - } else { - debug(table_dev) { writeln(table_object.table.number_of_columns, " != ", col_num); } - } - } - if (table_object.table.number_of_columns == 0 - && table_object.table.column_widths.length > 0) { - writeln(__LINE__, " ERROR"); - } - if (table_object.table.number_of_columns > 0 - && table_object.table.column_widths.length == 0) { - double col_w = (100.00 / table_object.table.number_of_columns); - foreach (i; 0..table_object.table.number_of_columns) { - table_object.table.column_widths ~= col_w; - } - } else if (table_object.table.number_of_columns - != table_object.table.column_widths.length) { - debug(table_dev) { writeln(m.hit); } // further logic required - if (table_object.table.number_of_columns > table_object.table.column_widths.length) { - double col_w = (100.00 - (table_object.table.column_widths).sum) - / (table_object.table.number_of_columns - table_object.table.column_widths.length); - foreach (i; 0..table_object.table.column_widths.length) { - table_object.table.column_widths ~= col_w; - } - foreach (i; 0..(table_object.table.number_of_columns - table_object.table.column_widths.length)) { - table_object.table.column_widths ~= col_w; - } - } else if (table_object.table.number_of_columns < table_object.table.column_widths.length) { - writeln(__LINE__, " warning, ERROR"); - } - } - if (table_object.table.column_widths.sum > 101 - || table_object.table.column_widths.sum < 95 ) { - writeln("sum: ", table_object.table.column_widths.sum, - ", array: ", table_object.table.column_widths, - ", cols: ", table_object.table.number_of_columns); - writeln(_table_substantive); - } - debug(table_res) { - writeln("aligns: ", table_object.table.column_aligns, "\n", - "no. of columns: ", table_object.table.number_of_columns, "\n", - "col widths: ", table_object.table.column_widths, - " sum: ", table_object.table.column_widths.sum, "\n", - _table_substantive); - } - table_object.text = _table_substantive; - ST_flow_table_array_munge ret; - { - ret.table_object = table_object; - ret.table_array = table_array; - } - return ret; - } - @system ST_flow_table_substantive_munge flow_table_substantive_munge()( - ObjGenericComposite table_object, - string table_substantive, - ) { - static auto rgx = RgxI(); - static auto munge = ObjInlineMarkupMunge(); - string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter); - string[] _table_cols; - string[][] _table_array; - foreach(col; _table_rows) { - _table_cols = col.split(rgx.table_col_delimiter); - _table_array ~= _table_cols; - } - { - auto _get = table_object.flow_table_array_munge(_table_array); - { - table_object = _get.table_object; - _table_array = _get.table_array; // what do you do with this? how is this passed down? - } - } - ST_flow_table_substantive_munge ret; - { - ret.table_object = table_object; - ret.table_substantive = table_substantive; // has anything been changed here? - } - return ret; - } - @system ST_flow_table_substantive_munge flow_table_substantive_munge_special()( - ObjGenericComposite table_object, - string table_substantive, - ) { - static auto rgx = RgxI(); - static auto munge = ObjInlineMarkupMunge(); - string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter_special); - string[] _table_cols; - string[][] _table_array; - foreach(col; _table_rows) { - _table_cols = col.split(rgx.table_col_delimiter_special); - _table_array ~= _table_cols; - } - { - auto _get = table_object.flow_table_array_munge(_table_array); - { - table_object = _get.table_object; - _table_array = _get.table_array; - } - } - ST_flow_table_substantive_munge ret; - { - ret.table_object = table_object; - ret.table_substantive = table_substantive; - } - return ret; - } - @system ST_flow_table_closed_make_special_notation_table flow_table_closed_make_special_notation_table_(CMM)( - char[] line, - string[string] an_object, - ObjGenericComposite[] the_document_body_section, - OCNset obj_cite_digits, - ObjGenericComposite comp_obj_, - int cntr, - uint[string] pith, - CMM conf_make_meta - ) { - comp_obj_ = comp_obj_.init; - obj_cite_digits = ocn_emit(pith["ocn"]); - 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, - "table" - ); - an_object["is"] = "table"; - ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct - = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, No._new_doc); - an_object["substantive"] = substantive_obj_misc_struct.obj_txt; - comp_obj_.metainfo.ocn = 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_.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_.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]); - { - auto _get = comp_obj_.flow_table_substantive_munge_special(an_object["substantive"]); - { - comp_obj_ = _get.table_object; - an_object["substantive"] = _get.table_substantive; - } - } - the_document_body_section ~= comp_obj_; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - ST_flow_table_closed_make_special_notation_table ret; - { - ret.this_object = an_object; - ret.the_document_body_section = the_document_body_section; - ret.obj_cite_digits = obj_cite_digits; - ret.comp_obj_ = comp_obj_; - ret.cntr = cntr; - ret.pith = pith; - } - return ret; - } - // ↑ - table - - @system ST_flow_block_flag_line_empty flow_block_flag_line_empty_(B,CMM,Ts)( - char[] line, - string[string] an_object, - B bookindex_extract_hash, - ObjGenericComposite[] the_document_body_section, - string[][string][string] bookindex_unordered_hashes, - OCNset obj_cite_digits, - ObjGenericComposite comp_obj_, - int cntr, - uint[string] pith, - string[string] object_number_poem, - CMM conf_make_meta, - Ts tag_in_seg, - ) { - assert( - line.empty, - "\nline should be empty:\n \"" - ~ line ~ "\"" - ); - assert( - (pith["block_state"] == eN.blk_state.closing), - "code block status: closed" - ); - static auto rgx = RgxI(); - if (pith["block_state"] == eN.blk_state.closing) { - if (pith["block_is"] == eN.blk_is.quote) { - obj_cite_digits = ocn_emit(pith["ocn"]); - 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"] = "quote"; - 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", "quote", 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_digit_type; - comp_obj_.metainfo.lang = an_object["lang"]; - comp_obj_.metainfo.attrib = an_object["attrib"]; - 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); - pith["block_is"] = eN.blk_is.quote; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (pith["block_is"] == eN.blk_is.group) { - obj_cite_digits = ocn_emit(pith["ocn"]); - 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"] = "group"; - 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", "group", 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_.metainfo.lang = an_object["lang"]; - comp_obj_.metainfo.attrib = an_object["attrib"]; - 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); - pith["block_is"] = eN.blk_is.poem; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (pith["block_is"] == eN.blk_is.block) { - obj_cite_digits = ocn_emit(pith["ocn"]); - 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"] = "block"; - 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; // check - comp_obj_ = set_object_generic("body", "body", "block", "block", 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_digit_type; - comp_obj_.metainfo.lang = an_object["lang"]; - comp_obj_.metainfo.attrib = an_object["attrib"]; - 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_; - pith["block_is"] = eN.blk_is.block; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (pith["block_is"] == eN.blk_is.poem) { - 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"] = "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"] - ); - comp_obj_poem_ocn = set_object_generic("body", "body", "block", "poem", "", obj_cite_digits.object_number); - comp_obj_poem_ocn.metainfo.identifier = obj_cite_digits.identifier; - comp_obj_poem_ocn.metainfo.object_number_off = obj_cite_digits.off; - comp_obj_poem_ocn.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_poem_ocn.metainfo.object_number_type = obj_cite_digits.type; - the_document_body_section ~= comp_obj_poem_ocn; - pith["block_is"] = eN.blk_is.poem; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - } else if (pith["block_is"] == eN.blk_is.code) { - obj_cite_digits = ocn_emit(pith["ocn"]); - 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"] = "code"; - 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", "code", 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_.metainfo.syntax = an_object["syntax"]; - comp_obj_.metainfo.attrib = an_object["attrib"]; - comp_obj_.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false; - 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_; - pith["block_is"] = eN.blk_is.code; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (pith["block_is"] == eN.blk_is.table) { - comp_obj_ = comp_obj_.init; - obj_cite_digits = ocn_emit(pith["ocn"]); - 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"] = "table"; - 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; - comp_obj_ = comp_obj_.init; - comp_obj_.metainfo.ocn = 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_.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_.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]); - { - auto _get = comp_obj_.flow_table_substantive_munge(an_object["substantive"]); - { - comp_obj_ = _get.table_object; - an_object["substantive"] = _get.table_substantive; - } - } - the_document_body_section ~= comp_obj_; - pith["block_is"] = eN.blk_is.table; - pith["block_state"] = eN.blk_state.off; - pith["block_delim"] = eN.blk_delim.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - } - ST_flow_block_flag_line_empty ret; - { - ret.this_object = an_object; - ret.the_document_body_section = the_document_body_section; - ret.bookindex_unordered_hashes = bookindex_unordered_hashes; - ret.obj_cite_digits = obj_cite_digits; - ret.comp_obj_ = comp_obj_; // - ret.cntr = cntr; - ret.pith = pith; - } - return ret; - } - // ↓ - object set - ObjGenericComposite set_object_heading()( - string level, - string part, - string section, - string text, - ) { - ObjGenericComposite comp_obj; - { - comp_obj = comp_obj.init; - comp_obj.metainfo.is_of_part = part; - comp_obj.metainfo.is_of_section = section; - comp_obj.metainfo.is_of_type = "para"; - comp_obj.metainfo.is_a = "heading"; - comp_obj.text = text; - comp_obj.metainfo.ocn = 0; - if (level == "lev1") { - comp_obj.metainfo.heading_lev_markup = 1; - comp_obj.metainfo.heading_lev_collapsed = 1; - comp_obj.metainfo.parent_ocn = 1; - comp_obj.metainfo.parent_lev_markup = 0; - } else if (level == "lev4") { - comp_obj.metainfo.heading_lev_markup = 4; - comp_obj.metainfo.heading_lev_collapsed = 1; - comp_obj.metainfo.parent_ocn = 1; - comp_obj.metainfo.parent_lev_markup = 0; - comp_obj.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; - } - } - return comp_obj; - } - ObjGenericComposite set_object_generic()( - string part, - string section, - string type, - string is_a, - string text, - int ocn, - ) { - ObjGenericComposite comp_obj; - { - comp_obj = comp_obj.init; - comp_obj.metainfo.is_of_part = part; - comp_obj.metainfo.is_of_section = section; - comp_obj.metainfo.is_of_type = type; - comp_obj.metainfo.is_a = is_a; - comp_obj.text = text; - comp_obj.metainfo.ocn = ocn; - } - return comp_obj; - } - // ↑ - object set - // ↓ - object inline munge - static struct ObjInlineMarkupMunge { - string[string] obj_txt; - int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; - string asterisks_, plus_; - string obj_txt_out, tail, note; - static auto rgx = RgxI(); - static auto mkup = InlineMarkup(); - int stage_reset_note_numbers = true; - private auto initialize_note_numbers() { - n_foot = 0; - n_foot_reg = 0; - n_foot_sp_asterisk = 0; - n_foot_sp_plus = 0; - } - static auto images()(string obj_txt_in) { - static auto mng = InlineMarkup(); - // url matched - obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented - if (obj_txt_in.match(rgx.smid_image_generic)) { // images with and without links - debug(images) { writeln("Image: ", obj_txt_in); } - if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { - obj_txt_in = obj_txt_in - .replaceAll(rgx.smid_image_with_dimensions, ("$1" ~ mkup.img ~ "$2,w$3h$4 " ~ "$5")) - .replaceAll(rgx.smid_image_delimit, ("$1" - ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c - ~ mkup.url_o ~ mkup.url_c)); - debug(images) { writeln("IMAGE with size: ", obj_txt_in); } - } else if (obj_txt_in.match(rgx.smid_image)) { - obj_txt_in = obj_txt_in - .replaceAll(rgx.smid_image, ("$1" ~ mkup.img ~ "$2,w0h0" ~ "$3")) - .replaceAll(rgx.smid_image_delimit, ("$1" - ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c - ~ mkup.url_o ~ mkup.url_c)); - debug(images) { writeln("IMAGE: ", obj_txt_in); } // decide on representation - } - } - return obj_txt_in; - } - ST_txtPlusHasFootnotes footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) { - // endnotes (regular) - bool flg_notes_reg = false; - bool flg_notes_star = false; - bool flg_notes_plus = false; - obj_txt_in = obj_txt_in.replaceAll( - rgx.inline_notes_curly, - (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) - ); - if (!(stage_reset_note_numbers) && reset_note_numbers) { - stage_reset_note_numbers = true; - } - obj_txt_out = ""; - if (obj_txt_in.match(rgx.inline_notes_al_gen)) { - string[] _tmp_txt; - foreach (x; obj_txt_in.split("\n")) { - if (auto m = x.matchAll(rgx.inline_text_and_note_al_)) { - if (stage_reset_note_numbers) { - n_foot = 0; - n_foot_reg = 0; - n_foot_sp_asterisk = 0; - n_foot_sp_plus = 0; - } - stage_reset_note_numbers = false; - foreach(n; m) { - if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_star)) { - flg_notes_star = true; - ++n_foot_sp_asterisk; - asterisks_ = "*"; - n_foot = n_foot_sp_asterisk; - _tmp_txt ~= n.hit.to!string.replaceFirst( - rgx.inline_al_delimiter_open_symbol_star, - (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ") - ); - } else if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_plus)) { - flg_notes_plus = true; - ++n_foot_sp_plus; - plus_ = "*"; - n_foot = n_foot_sp_plus; - _tmp_txt ~= n.hit.to!string.replaceFirst( - rgx.inline_al_delimiter_open_symbol_plus, - (mkup.en_a_o ~ replicate(plus_, n_foot_sp_plus) ~ " ") - ); - } else if (n.hit.to!string.matchFirst(rgx.inline_al_delimiter_open_regular)) { - string _tmp_str = n.hit.to!string; - flg_notes_reg = true; - foreach (q; n.hit.to!string.matchAll(rgx.inline_al_delimiter_open_regular)) { - ++n_foot_reg; - n_foot = n_foot_reg; - _tmp_str = replaceFirst!(m => mkup.en_a_o ~ n_foot.to!string ~ " ") - (_tmp_str, rgx.inline_al_delimiter_open_regular); - } - _tmp_txt ~= _tmp_str; - } else { - _tmp_txt ~= n.hit.to!string; - } - } - obj_txt_out = _tmp_txt.join("\n"); - } - } - } else { - obj_txt_out = obj_txt_in; - } - ST_txtPlusHasFootnotes ret; - { - ret.obj_txt = obj_txt_out; - ret.has_notes_reg = flg_notes_reg; - ret.has_notes_star = flg_notes_star; - ret.has_notes_plus = flg_notes_plus; - } - return ret; - } - private ST_txtPlusHasFootnotesUrlsImages object_notes_and_links_()( - string obj_txt_in, - bool reset_note_numbers = false - ) { - obj_txt_out = ""; - bool urls = false; - bool images_without_dimensions = false; - tail = ""; - // special endnotes - obj_txt_in = obj_txt_in.replaceAll( - rgx.inline_notes_curly_sp_asterisk, - (mkup.en_a_o ~ "*" ~ " $1" ~ mkup.en_a_c) - ); - obj_txt_in - = obj_txt_in.replaceAll( - rgx.inline_notes_curly_sp_plus, - (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) - ); - // image matched - if (obj_txt_in.match(rgx.smid_image_generic)) { - obj_txt_in = images(obj_txt_in); - if (obj_txt_in.match(rgx.smid_mod_image_without_dimensions)) { - images_without_dimensions = true; - } - } - // url matched - if (obj_txt_in.match(rgx.smid_inline_url)) { - urls = true; - obj_txt_in = obj_txt_in.links_and_images; - } - if (auto m = obj_txt_in.match(rgx.para_inline_link_anchor)) { - obj_txt_in = obj_txt_in - .replaceAll(rgx.para_inline_link_anchor, "┃$1┃"); - } - ST_txtPlusHasFootnotes ftn = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); - obj_txt_out = ftn.obj_txt; - debug(footnotes) { writeln(obj_txt_out, tail); } - obj_txt_out = obj_txt_out ~ tail; - debug(footnotesdone) { - foreach(m; matchAll(obj_txt_out, (mkup.en_a_o ~ `\s*(.+?)` ~ mkup.en_a_c))) { - writeln(m[1]); - writeln(m.hit); - } - } - ST_txtPlusHasFootnotesUrlsImages ret; - { - ret.obj_txt = obj_txt_out; - ret.has_notes_reg = ftn.has_notes_reg; - ret.has_notes_star = ftn.has_notes_star; - ret.has_notes_plus = ftn.has_notes_plus; - ret.has_urls = urls; - ret.has_images_without_dimensions = images_without_dimensions; - } - return ret; - } - private ST_txtPlusHasFootnotesUrlsImages object_only_()( - string obj_txt_in, - bool reset_note_numbers = false - ) { - ST_txtPlusHasFootnotesUrlsImages ret; - { - ret.obj_txt = obj_txt_in; - ret.has_notes_reg = false; - ret.has_notes_star = false; - ret.has_notes_plus = false; - ret.has_urls = false; - ret.has_images_without_dimensions = false; - } - return ret; - } - ST_txtPlusHasFootnotesUrlsImages init() { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(""); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_heading()( - string obj_txt_in, - bool reset_note_numbers = false - ) { - obj_txt["munge"] = obj_txt_in - .replaceFirst(rgx.headings, "") - .replaceFirst(rgx.object_number_off_all, "") - .replaceFirst(rgx.markup_inline_linebreak, mkup.br_line_inline) - .strip; - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); - debug(munge) { writeln(__LINE__); writeln(obj_txt_in); writeln(__LINE__); writeln(obj_txt["munge"].to!string); } - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_para()(string obj_txt_in) { - obj_txt["munge"] = (obj_txt_in) - .replaceFirst(rgx.para_attribs, "") - .replaceFirst(rgx.object_number_off_all, "") - .replaceFirst(rgx.markup_inline_linebreak, mkup.br_line_inline); - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt["munge"]); - debug(munge) { writeln(__LINE__); writeln(obj_txt_in); - writeln(__LINE__); - writeln(obj_txt["munge"].to!string); - } - return ret; - } - ST_txtPlusHasFootnotesUrlsImages munge_quote()(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in.split("\n\n").join(" \\\\\n \\\\\n")); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_group(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in.split("\n\n").join("\n" ~ mkup.br_line_spaced ~ "\n")); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_block()(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); - return ret; - } - invariant() { - } - auto munge_verse()(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_code()(string obj_txt_in) { - obj_txt_in = obj_txt_in.replaceAll(rgx.space, mkup.nbsp); - ST_txtPlusHasFootnotesUrlsImages ret = object_only_(obj_txt_in); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_table()(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); - return ret; - } - invariant() { - } - ST_txtPlusHasFootnotesUrlsImages munge_comment()(string obj_txt_in) { - ST_txtPlusHasFootnotesUrlsImages ret = object_only_(obj_txt_in); - return ret; - } - invariant() { - } - } - // ↑ - object inline munge - // ↓ - object inline markup - static struct ObjInlineMarkup { - static auto rgx = RgxI(); - static auto munge = ObjInlineMarkupMunge(); - string[string] obj_txt; - string anchor_tag = ""; - ST_txtAndAnchorTagPlusHasFootnotesUrlsImages obj_inline_markup_and_anchor_tags_and_misc(CMM)( - string[string] obj_, - string obj_key_, - 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; - if (_new_doc) { - anchor_tag = ""; - } - auto x = munge.init; - ST_txtAndAnchorTagPlusHasFootnotesUrlsImages ret; - ret.obj_txt = ""; - ret.anchor_tag = ""; - ret.has_notes_reg = false; - ret.has_notes_star = false; - ret.has_notes_plus = false; - ret.has_links = false; - ret.has_images_without_dimensions = false; - if ((obj_["is"] == "para") - || (obj_["is"] == "heading") - || (obj_["is"] == "quote") - || (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; - } - switch (obj_["is"]) { - case "heading": - if (_new_doc) { - anchor_tag = ""; - } - obj_txt["munge"] = _configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc); - obj_txt["munge"] = _make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); - if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { - anchor_tag = m.captures[1]; - } else if (obj_["lev"] == "1") { - writeln("heading anchor tag missing: ", obj_txt["munge"]); - } - x = munge.munge_heading(obj_txt["munge"], reset_note_numbers); - reset_note_numbers = false; - goto default; - case "para": - x = munge.munge_para(obj_txt["munge"]); - goto default; - case "group": - x = munge.munge_group(obj_txt["munge"]); - goto default; - case "block": - x = munge.munge_block(obj_txt["munge"]); - goto default; - case "quote": - x = munge.munge_quote(obj_txt["munge"]); - goto default; - case "verse": - x = munge.munge_verse(obj_txt["munge"]); - goto default; - case "code": - x = munge.munge_code(obj_txt["munge"]); - goto default; - case "table": - x = munge.munge_table(obj_txt["munge"]); - goto default; - case "comment": - x = munge.munge_comment(obj_txt["munge"]); - goto default; - case "doc_end_reset": - munge.initialize_note_numbers(); - break; - default: - // para, heading, group, block, verse - ret.obj_txt = x.obj_txt; - ret.anchor_tag = anchor_tag; - ret.has_notes_reg = x.has_notes_reg; - ret.has_notes_star = x.has_notes_star; - ret.has_notes_plus = x.has_notes_plus; - ret.has_links = x.has_urls; - ret.has_images_without_dimensions = x.has_images_without_dimensions; - break; - } - anchor_tag = ""; - return ret; - } - invariant() { - } - auto _clean_heading_toc_()( - char[] heading_toc_, - ) { - auto m = (cast(char[]) heading_toc_).matchFirst(rgx.heading); - heading_toc_ = (m.post).replaceAll(rgx.inline_notes_curly_gen, ""); - return heading_toc_; - }; - ST_flow_table_of_contents_gather_headings flow_table_of_contents_gather_headings(CMM)( // - string[string] obj_, - CMM conf_make_meta, - string[string] tag_in_seg, - string _anchor_tag, - string[][string] lev4_subtoc, - ObjGenericComposite[] the_document_toc_section, - ) { - ObjGenericComposite comp_obj_; - mixin InternalMarkup; - static auto mkup = InlineMarkup(); - char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])) - .replaceAll(rgx.inline_notes_al, ""); - heading_toc_ = _clean_heading_toc_(heading_toc_); - auto attrib = ""; - string toc_txt_, subtoc_txt_; - int[string] indent; - if (obj_["lev_markup_number"].to!int > 0) { - indent = [ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - heading_toc_.strip, - mkup.lnk_c, - mkup.url_o, - _anchor_tag, - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", toc_txt_.to!string.strip, 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false; - comp_obj_.attrib.indent_hang = indent["hang_position"]; - comp_obj_.attrib.indent_base = indent["base_position"]; - comp_obj_.attrib.bullet = false; - comp_obj_.has.inline_links = true; - the_document_toc_section ~= comp_obj_; - } - comp_obj_ = comp_obj_.init; - comp_obj_.metainfo.is_of_part = "frontmatter"; - comp_obj_.metainfo.is_of_section = "toc"; - comp_obj_.metainfo.is_of_type = "para"; - comp_obj_.metainfo.is_a = "toc"; - comp_obj_.metainfo.ocn = 0; - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false; - comp_obj_.attrib.bullet = false; - comp_obj_.has.inline_links = true; - switch (obj_["lev_markup_number"].to!int) { - case 0: .. case 3: - break; - case 4: - lev4_subtoc[tag_in_seg["seg_lv4"]] = []; - break; - case 5: .. case 7: - subtoc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - heading_toc_.strip, - mkup.lnk_c, - mkup.url_o, - _anchor_tag, - mkup.url_c, - ); - lev4_subtoc[tag_in_seg["seg_lv4"]] - ~= links_and_images(obj_["lev_markup_number"] - ~ "~ " ~ subtoc_txt_.to!string.strip - ); - break; - default: - break; - } - ST_flow_table_of_contents_gather_headings ret; - { - ret.the_document_toc_section = the_document_toc_section; - ret.lev4_subtoc = lev4_subtoc; - } - return ret; - } - invariant() { - } - private: - static int[] heading_num = [ 0, 0, 0, 0 ]; - static string heading_number_auto_composite = ""; - static string heading_number_auto_composite_segname = ""; - static bool[] auto_heading_numbering = [ true, true, true, true]; - static string _configured_auto_heading_numbering_and_segment_anchor_tags(CMM)( - string munge_, - string[string] obj_, - CMM conf_make_meta, - bool _new_doc, - ) { - if (_new_doc) { - heading_num = [ 0, 0, 0, 0 ]; - heading_number_auto_composite = ""; - auto_heading_numbering = [ true, true, true, true]; - } - if (conf_make_meta.make.auto_num_top_lv) { - if (obj_["lev_markup_number"].to!int == 0) { - heading_num[0] = 0; - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - heading_number_auto_composite = ""; - } - // auto_num_depth minimum 0 - // (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement - if ( - conf_make_meta.make.auto_num_top_lv - > obj_["lev_markup_number"].to!uint - ) { - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == obj_["lev_markup_number"].to!uint - ) { - auto_heading_numbering[0] = - (munge_.match(rgx.auto_heading_numbering_off_lv1)) ? false : true; - if (auto_heading_numbering[0]) { - heading_num[0] ++; - } - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 1) - ) { - auto_heading_numbering[1] = - (munge_.match(rgx.auto_heading_numbering_off_lv2)) ? false : true; - if (auto_heading_numbering[0] - && auto_heading_numbering[1]) { - heading_num[1] ++; - } - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 2) - ) { - auto_heading_numbering[2] = - (munge_.match(rgx.auto_heading_numbering_off_lv3)) ? false : true; - if (auto_heading_numbering[0] - && auto_heading_numbering[1] - && auto_heading_numbering[2]) { - heading_num[2] ++; - } - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 3) - ) { - auto_heading_numbering[3] = - (munge_.match(rgx.auto_heading_numbering_off_lv4)) ? false : true; - if (auto_heading_numbering[0] - && auto_heading_numbering[1] - && auto_heading_numbering[2] - && auto_heading_numbering[3]) { - heading_num[3] ++; - } - } - if (auto_heading_numbering[0]) { - if (heading_num[3] > 0) { - heading_number_auto_composite - = (conf_make_meta.make.auto_num_depth.to!uint == 3 - && auto_heading_numbering[3]) - ? (format(q"┃%s.%s.%s.%s┃", - heading_num[0].to!string, - heading_num[1].to!string, - heading_num[2].to!string, - heading_num[3].to!string - )) - : ""; - } else if (heading_num[2] > 0) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 2) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3) - && auto_heading_numbering[2]) - ? (format(q"┃%s.%s.%s┃", - heading_num[0].to!string, - heading_num[1].to!string, - heading_num[2].to!string - )) - : ""; - } else if (heading_num[1] > 0) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 1) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3) - && auto_heading_numbering[1]) - ? (format(q"┃%s.%s┃", - heading_num[0].to!string, - heading_num[1].to!string - )) - : ""; - } else if (heading_num[0] > 0 - && munge_.match(rgx.auto_heading_numbering_lv1) - ) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 0) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3) - && auto_heading_numbering[0]) - ? (format(q"┃%s┃", - heading_num[0].to!string - )) - : ""; - } else { - heading_number_auto_composite = ""; - } - } - heading_number_auto_composite_segname = - (heading_number_auto_composite.empty) - ? "" - : "seg_" ~ heading_number_auto_composite; - debug(heading_number_auto) { writeln(heading_number_auto_composite); } - if ((!empty(heading_number_auto_composite)) - && (obj_["lev_markup_number"].to!uint >= conf_make_meta.make.auto_num_top_lv)) { - munge_ = munge_ - .replaceFirst(rgx.heading, - "$1~$2 " ~ heading_number_auto_composite ~ ". ") - .replaceFirst(rgx.heading_marker_missing_tag, - "$1~" ~ heading_number_auto_composite_segname ~ " "); - } - } - return munge_; - } - static int heading_num_lev1 = 0; - static string _make_segment_anchor_tags_if_none_provided()( - string munge_, - string lev_, - bool _new_doc - ) { - if (!(munge_.match(rgx.heading_anchor_tag))) { - if (lev_ == "A") { // (_new_doc) - heading_num_lev1 = 0; - } - if (munge_.match(rgx.heading_identify_anchor_tag)) { - if (auto m = munge_.match(rgx.heading_extract_named_anchor_tag)) { - munge_ = munge_.replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ m.captures[1].toLower ~ "_" ~ m.captures[2] ~ " "); - if (auto n = munge_.match(rgx.heading_anchor_tag_plus_colon)) { - auto tag_remunge_ = n.captures[2] - .replaceAll(rgx.heading_marker_tag_has_colon, ".."); - munge_ = munge_.replaceFirst(rgx.heading_anchor_tag_plus_colon, n.captures[1] ~ tag_remunge_ ~ " "); - } - } else if (auto m = munge_.match(rgx.heading_extract_unnamed_anchor_tag)) { - munge_ = munge_.replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ "s" ~ m.captures[1] ~ " "); - } - } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev == "1" - heading_num_lev1 ++; - munge_ = munge_.replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ "x" ~ heading_num_lev1.to!string ~ " "); - } - } - return munge_; - } - } - // ↑ - object inline markup - // ↓ - object attributes - struct ObjAttributes { - string[string] _obj_attrib; - string obj_attributes()( - string obj_is_, - string obj_raw, - ObjGenericComposite comp_obj_, - ) { - scope(exit) { - destroy(obj_is_); - destroy(obj_raw); - destroy(comp_obj_); - } - _obj_attrib["json"] ="{"; - switch (obj_is_) { - case "heading": - _obj_attrib["json"] ~= txt_heading(obj_raw); - break; - case "para": - _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) - ~ txt_para(obj_raw); - break; - case "code": - _obj_attrib["json"] ~= txt_code(obj_raw); - break; - case "group": - _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) - ~ txt_group(obj_raw); - break; - case "block": - _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) - ~ txt_block(obj_raw); - break; - case "verse": - _obj_attrib["json"] ~= txt_verse(obj_raw); - break; - case "quote": - _obj_attrib["json"] ~= txt_quote(obj_raw); - break; - case "table": - _obj_attrib["json"] ~= txt_table(obj_raw); - break; - case "comment": - _obj_attrib["json"] ~= txt_comment(obj_raw); - break; - default: - _obj_attrib["json"] ~= txt_para(obj_raw); - break; - } - _obj_attrib["json"] ~= " }"; - _obj_attrib["json"] = _set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, comp_obj_); - debug(structattrib) { - if (oa_j["is"].str() == "heading") { - writeln(_obj_attrib["json"]); - writeln( - "is: ", oa_j["is"].str(), - "; object_number: ", oa_j["object_number"].integer() - ); - } - } - return _obj_attrib["json"]; - } - invariant() { - } - private: - string _obj_attributes; - string txt_para_and_blocks()(string obj_txt_in) { - if (obj_txt_in.matchFirst(rgx.para_bullet)) { - _obj_attributes =" \"bullet\": \"true\"," - ~ " \"indent_hang\": 0," - ~ " \"indent_base\": 0,"; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_bullet_indent)) { - _obj_attributes =" \"bullet\": \"true\"," - ~ " \"indent_hang\": " ~ m["indent"].to!string ~ "," - ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent_hang)) { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": " ~ m["hang"].to!string ~ "," - ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent)) { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": " ~ m["indent"].to!string ~ "," - ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; - } else { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": 0," - ~ " \"indent_base\": 0,"; - } - return _obj_attributes; - } - string txt_heading()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"para\"," - ~ " \"is\": \"heading\""; - return _obj_attributes; - } - invariant() { - } - string txt_para()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"para\"," - ~ " \"is\": \"para\""; - return _obj_attributes; - } - invariant() { - } - string txt_quote()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"quote\""; - return _obj_attributes; - } - invariant() { - } - string txt_group()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"group\""; - return _obj_attributes; - } - invariant() { - } - string txt_block()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"block\""; - return _obj_attributes; - } - invariant() { - } - string txt_verse()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"verse\""; - return _obj_attributes; - } - invariant() { - } - string txt_code()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"code\""; - return _obj_attributes; - } - invariant() { - } - string txt_table()(string obj_txt_in) { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"table\""; - return _obj_attributes; - } - invariant() { - } - string txt_comment()(string obj_txt_in) { - _obj_attributes = " \"use\": \"comment\"," - ~ " \"of\": \"comment\"," - ~ " \"is\": \"comment\""; - return _obj_attributes; - } - invariant() { - } - string _set_additional_values_parse_as_json()( - string _obj_attrib, - string obj_is_, - ObjGenericComposite comp_obj_, - ) { - JSONValue oa_j = parseJSON(_obj_attrib); - assert( - (oa_j.type == JSON_TYPE.OBJECT) - ); - if (obj_is_ == "heading") { - oa_j.object["object_number"] = comp_obj_.metainfo.ocn; - oa_j.object["lev_markup_number"] = comp_obj_.metainfo.heading_lev_markup; - oa_j.object["lev_collapsed_number"] = comp_obj_.metainfo.heading_lev_collapsed; - oa_j.object["heading_ptr"] = comp_obj_.ptr.heading; - oa_j.object["doc_object_ptr"] = comp_obj_.ptr.doc_object; - } - oa_j.object["parent_object_number"] = comp_obj_.metainfo.parent_ocn; - oa_j.object["parent_lev_markup_number"] = comp_obj_.metainfo.parent_lev_markup; - _obj_attrib = oa_j.toString(); - return _obj_attrib; - } - } - // ↑ - object attributes - // ↓ - object tags - pure ObjGenericComposite obj_dom_structure_set_markup_tags()( - ObjGenericComposite obj, - int[] dom, - int lev - ) { - foreach (i; 0 .. 8) { - if (i < lev) { - if (dom[i] == DomTags.open - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.open_still; - } else if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } - } else if (i == lev) { - if (lev == 0 - && dom[i] == DomTags.open_still - ) { - dom[i] = DomTags.close; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close_and_open; - } else { - dom[i] = DomTags.open; - } - } else if (i > lev) { - if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close; - } - } - } - debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); } - obj.metainfo.dom_structure_markedup_tags_status = dom.dup; - return obj; - } - pure ObjGenericComposite obj_dom_set_collapsed_tags()( - ObjGenericComposite obj, - int[] dom, - int lev - ) { - foreach (i; 0 .. 8) { - if (i < lev) { - if (dom[i] == DomTags.open - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.open_still; - } else if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } - } else if (i == lev) { - if (lev == 0 - && dom[i] == DomTags.open_still - ) { - dom[i] = DomTags.close; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close_and_open; - } else { - dom[i] = DomTags.open; - } - } else if (i > lev) { - if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close; - } - } - } - debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); } - obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; - return obj; - } - // ↑ - object tags - // ↓ - table of contents - @system ObjGenericComposite[] backmatter_gather_table_of_contents( - ObjGenericComposite[] the_document_endnotes_section, - ObjGenericComposite[] the_document_glossary_section, - ObjGenericComposite[] the_document_bibliography_section, - ObjGenericComposite[] the_document_bookindex_section, - ObjGenericComposite[] the_document_blurb_section, - ) { - ObjGenericComposite[] toc_section_backmatter; - string toc_txt_; - static auto mkup = InlineMarkup(); - ObjGenericComposite comp_obj_; - int[string] indent = [ - "hang_position" : 1, - "base_position" : 1, - ]; - comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", "", 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.attrib.indent_hang = indent["hang_position"]; - comp_obj_.attrib.indent_base = indent["base_position"]; - comp_obj_.attrib.bullet = false; - if (the_document_endnotes_section.length > 1) { - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - "Endnotes", - mkup.lnk_c, - mkup.url_o, - "endnotes", - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_.text = toc_txt_.to!string.strip; - comp_obj_.has.inline_links = true; - toc_section_backmatter ~= comp_obj_; - } - if (the_document_glossary_section.length > 1) { - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - "Glossary", - mkup.lnk_c, - mkup.url_o, - "glossary", - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_.text = toc_txt_.to!string.strip; - comp_obj_.has.inline_links = true; - toc_section_backmatter ~= comp_obj_; - } - if (the_document_bibliography_section.length > 1){ - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - "Bibliography", - mkup.lnk_c, - mkup.url_o, - "bibliography", - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_.text = toc_txt_.to!string.strip; - comp_obj_.has.inline_links = true; - toc_section_backmatter ~= comp_obj_; - } - if (the_document_bookindex_section.length > 1) { - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - "Book Index", - mkup.lnk_c, - mkup.url_o, - "bookindex", - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_.text = toc_txt_.to!string.strip; - comp_obj_.has.inline_links = true; - toc_section_backmatter ~= comp_obj_; - } - if (the_document_blurb_section.length > 1) { - toc_txt_ = format("%s%s%s%s#%s%s", - mkup.lnk_o, - "Blurb", - mkup.lnk_c, - mkup.url_o, - "blurb", - mkup.url_c, - ); - toc_txt_= toc_txt_.links_and_images; - comp_obj_.has.inline_links = true; - comp_obj_.text = toc_txt_.to!string.strip; - toc_section_backmatter ~= comp_obj_; - } - debug(toc) { - writefln( "%s %s", __LINE__,); - foreach (toc_linked_heading; toc_section_backmatter) { - writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); - } - } - return toc_section_backmatter; - } - // ↑ - table of contents - // ↓ - endnotes - struct NotesSection { - string[string] object_notes; - int previous_count; - int mkn; - static auto rgx = RgxI(); - private auto gather_notes_for_endnote_section( - ObjGenericComposite[] contents_am, - string[string] tag_in_seg, - int cntr, - ) { - assert((contents_am[cntr].metainfo.is_a == "para") - || (contents_am[cntr].metainfo.is_a == "heading") - || (contents_am[cntr].metainfo.is_a == "quote") - || (contents_am[cntr].metainfo.is_a == "group") - || (contents_am[cntr].metainfo.is_a == "block") - || (contents_am[cntr].metainfo.is_a == "verse")); - assert(cntr >= previous_count); - assert( - (contents_am[cntr].text).match( - rgx.inline_notes_al_all_note) - ); - mixin InternalMarkup; - previous_count = cntr; - static auto mkup = InlineMarkup(); - static auto munge = ObjInlineMarkupMunge(); - foreach(m; - (contents_am[cntr].text).matchAll( - rgx.inline_notes_al_special_char_note) - ) { - debug(endnotes_build) { writeln( - "{", mkup.ff_i, mkup.superscript, mkup.ff_o, m["char"], ".", mkup.ff_c, mkup.superscript, "}" - ~ mkup.mark_internal_site_lnk, - tag_in_seg["seg_lv4"], - ".fnSuffix#noteref_\n ", m["char"], " ", - m["note"]); // sometimes need segment name (segmented html & epub) - } - // you need anchor for segments at this point -> - object_notes["anchor"] ~= "note_" ~ m["char"] ~ "』"; - object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) - ? (links_and_images( - "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["char"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}#noteref_" - ~ m["char"]) ~ " " - ~ m["note"] ~ "』" - ) - : (links_and_images( - "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["char"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}" - ~ mkup.mark_internal_site_lnk - ~ tag_in_seg["seg_lv4"] - ~ ".fnSuffix#noteref_" - ~ m["char"]) ~ " " - ~ m["note"] ~ "』" - ); - } - foreach(m; - (contents_am[cntr].text).matchAll( - rgx.inline_notes_al_regular_number_note) - ) { - debug(endnotes_build) { writeln( - "{", mkup.ff_i, mkup.superscipt, mkup.ff_o, m["num"], ".", mkup.ff_c, mkup.superscipt, "}" - ~ mkup.mark_internal_site_lnk, - tag_in_seg["seg_lv4"], - ".fnSuffix#noteref_\n ", m["num"], " ", - m["note"]); // sometimes need segment name (segmented html & epub) - } - // you need anchor for segments at this point -> - object_notes["anchor"] ~= "note_" ~ m["num"] ~ "』"; - object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) - ? (links_and_images( - "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["num"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}#noteref_" - ~ m["num"]) ~ " " - ~ m["note"] ~ "』" - ) - : (links_and_images( - "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["num"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}" - ~ mkup.mark_internal_site_lnk - ~ tag_in_seg["seg_lv4"] - ~ ".fnSuffix#noteref_" - ~ m["num"]) ~ " " - ~ m["note"] ~ "』" - ); - } - return object_notes; - } - private auto gathered_notes() { - string[][string] endnotes_; - if (object_notes.length > 1) { - endnotes_["notes"] = (object_notes["notes"].split(rgx.break_string))[0..$-1]; - endnotes_["anchor"] = (object_notes["anchor"].split(rgx.break_string))[0..$-1]; - } else { - endnotes_["notes"] = []; - endnotes_["anchor"] = []; - } - return endnotes_; - } - private ST_endnotes backmatter_endnote_objects(O)( - OCNset obj_cite_digits, - O opt_action, - ) { - mixin spineNode; - ObjGenericComposite[] the_document_endnotes_section; - auto endnotes_ = gathered_notes(); - string type_is; - string lev, lev_markup_number, lev_collapsed_number; - string attrib; - int[string] indent; - ObjGenericComposite comp_obj_; - if ((endnotes_["notes"].length > 0) - && (opt_action.backmatter && opt_action.section_endnotes)) { - { - comp_obj_ = set_object_heading("lev1", "backmatter", "endnotes", "Endnotes"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_endnotes"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "endnotes"; - comp_obj_.tags.anchor_tags = ["section_endnotes"]; - the_document_endnotes_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - ++mkn; - } - { - comp_obj_ = set_object_heading("lev4", "backmatter", "endnotes", "Endnotes"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "endnotes"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.tags.anchor_tags = ["endnotes"]; - the_document_endnotes_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - ++mkn; - } - } else { - comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there are no Endnotes"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - the_document_endnotes_section ~= comp_obj_; - } - if (opt_action.backmatter && opt_action.section_endnotes) { - ObjGenericComposite comp_obj_endnote_; - comp_obj_endnote_ = set_object_generic("backmatter", "endnotes", "para", "endnote", "", 0); - comp_obj_endnote_.metainfo.identifier = ""; - // comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_endnote_.attrib.indent_hang = 0; - comp_obj_endnote_.attrib.indent_base = 0; - comp_obj_endnote_.attrib.bullet = false; - foreach (i, endnote; endnotes_["notes"]) { - auto m = endnote.matchFirst(rgx.note_ref); - string notenumber = m["ref"].to!string; - string anchor_tag = "note_" ~ notenumber; - comp_obj_endnote_.tags.anchor_tags = [ endnotes_["anchor"][i] ]; - comp_obj_endnote_.has.inline_links = true; - comp_obj_endnote_.text = endnote.inline_markup_faces.strip; - the_document_endnotes_section ~= comp_obj_endnote_; - } - } - ST_endnotes ret; - { - ret.endnotes = the_document_endnotes_section; - ret.ocn = obj_cite_digits; - } - return ret; - } - } - // ↑ - endnotes - // ↓ - section book index - @system ST_flow_book_index flow_book_index_(B)( - char[] line, - string[string] an_object, - string book_idx_tmp, - uint[string] pith, - B opt_action, - ) { - static auto rgx = RgxI(); - if (auto m = line.match(rgx.book_index_item)) { // match book_index - debug(bookindexmatch) { writefln( - "* [bookindex] %s\n", - m["bookindex"].to!string, - ); - } - an_object["bookindex_nugget"] = m.captures[1].to!string; - } else if (auto m = line.match(rgx.book_index_item_open)) { // match open book_index - pith["section"] = eN.sect.book_index; - if (opt_action.backmatter && opt_action.section_bookindex) { - book_idx_tmp = m.captures[1].to!string; - debug(bookindexmatch) { writefln( "* [bookindex] %s\n", book_idx_tmp,); } - } - } else if (pith["section"] == eN.sect.book_index) { // book_index flag set - if (auto m = line.match(rgx.book_index_item_close)) { - pith["section"] = eN.sect.unset; - if (opt_action.backmatter - && opt_action.section_bookindex) { - an_object["bookindex_nugget"] = book_idx_tmp ~ m.captures[1].to!string; - debug(bookindexmatch) { writefln( "* [bookindex] %s\n", book_idx_tmp,); } - } - book_idx_tmp = ""; - } else { - if (opt_action.backmatter - && opt_action.section_bookindex) { - book_idx_tmp ~= line; - } - } - } - ST_flow_book_index ret; - { - ret.this_object = an_object; - ret.pith = pith; - ret.book_idx_tmp = book_idx_tmp; - } - return ret; - } - struct BookIndexNuggetHash { - string main_term, sub_term, sub_term_bits; - int object_number_offset, object_number_endpoint; - string[] object_numbers; - string[][string][string] bi_hash_nugget; - string[] bi_main_terms_split_arr; - string[][string][string] bookindex_nugget_hash(S)( - string bookindex_section, - OCNset obj_cite_digits, - S tag_in_seg, - ) { - debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } - debug(bookindexraw) { - if (!bookindex_section.empty) { - writeln( - "* [bookindex] ", - "[", obj_cite_digits.object_number.to!string, ": ", tag_in_seg["seg_lv4"], "] ", bookindex_section, - " - - - ", - "[", obj_cite_digits.object_number.to!string, "] ", bookindex_section - ); - } - } - static auto rgx = RgxI(); - if (!bookindex_section.empty) { - auto bi_main_terms_split_arr - = bookindex_section.split(rgx.bi_main_terms_split); - foreach (bi_main_terms_content; bi_main_terms_split_arr) { - auto bi_main_term_and_rest - = bi_main_terms_content.split(rgx.bi_main_term_plus_rest_split); - if (auto m = bi_main_term_and_rest[0].match( - rgx.bi_term_and_object_numbers_match) - ) { - main_term = m.captures[1].strip; - object_number_offset = m.captures[2].to!int; - object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); - object_numbers ~= (obj_cite_digits.object_number.to!string - ~ "-" ~ object_number_endpoint.to!string); - } else { - main_term = bi_main_term_and_rest[0].strip; - object_numbers ~= obj_cite_digits.object_number.to!string; - } - bi_hash_nugget[main_term]["_a"] ~= object_numbers; - object_numbers = null; - if (bi_main_term_and_rest.length > 1) { - auto bi_sub_terms_split_arr - = bi_main_term_and_rest[1].split( - rgx.bi_sub_terms_plus_object_number_offset_split - ); - foreach (sub_terms_bits; bi_sub_terms_split_arr) { - if (auto m = sub_terms_bits.match(rgx.bi_term_and_object_numbers_match)) { - sub_term = m.captures[1].strip; - object_number_offset = m.captures[2].to!int; - object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); - object_numbers ~= (obj_cite_digits.object_number.to!string - ~ " - " ~ object_number_endpoint.to!string); - } else { - sub_term = sub_terms_bits.strip; - object_numbers ~= obj_cite_digits.object_number.to!string; - } - if (!empty(sub_term)) { - bi_hash_nugget[main_term][sub_term] ~= object_numbers; - } - object_numbers = null; - } - } - } - } - return bi_hash_nugget; - } - invariant() { - } - } - struct BookIndexReportIndent { - int mkn, skn; - void bookindex_report_indented()( - string[][string][string] bookindex_unordered_hashes - ) { - auto mainkeys - = bookindex_unordered_hashes.byKey.array.sort().release; - foreach (mainkey; mainkeys) { - debug(bookindex1) { writeln(mainkey); } - auto subkeys - = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; - foreach (subkey; subkeys) { - debug(bookindex1) { - writeln(" ", subkey); - writeln(" ", to!string( - bookindex_unordered_hashes[mainkey][subkey] - )); - } - ++skn; - } - ++mkn; - } - } - } - struct BookIndexReportSection { - int mkn, skn; - static auto rgx = RgxI(); - static auto munge = ObjInlineMarkupMunge(); - void bookindex_write_section()( - string[][string][string] bookindex_unordered_hashes - ) { - auto mainkeys = - bookindex_unordered_hashes.byKey.array - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; - foreach (mainkey; mainkeys) { - write("_0_1 ⑆!┨", mainkey, "┣! "); - foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - auto go = ref_.replaceAll(rgx.book_index_go, "$1"); - write(" {", ref_, "}#", go, ", "); - } - writeln(" \\\\"); - bookindex_unordered_hashes[mainkey].remove("_a"); - auto subkeys = - bookindex_unordered_hashes[mainkey].byKey.array - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; - foreach (subkey; subkeys) { - write(" ", subkey, ", "); - foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - auto go = ref_.replaceAll(rgx.book_index_go, "$1"); - write(" {", ref_, "}#", go, ", "); - } - writeln(" \\\\"); - ++skn; - } - ++mkn; - } - } - @system ST_bookindex backmatter_bookindex_build_abstraction_section(B)( - string[][string][string] bookindex_unordered_hashes, - OCNset obj_cite_digits, - B opt_action, - ) { - debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } - mixin spineNode; - mixin InternalMarkup; - static auto mkup = InlineMarkup(); - string type_is; - string lev; - int heading_lev_markup, heading_lev_collapsed; - string attrib; - int[string] indent; - auto mainkeys = - bookindex_unordered_hashes.byKey.array - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; - ObjGenericComposite[] bookindex_section; - ObjGenericComposite comp_obj_; - auto node_para_int_ = node_metadata_para_int; - auto node_para_str_ = node_metadata_para_str; - if ((mainkeys.length > 0) - && (opt_action.backmatter - && opt_action.section_bookindex)) { - string bi_tmp; - string[] bi_tmp_tags; - { - comp_obj_ = set_object_heading("lev1", "backmatter", "bookindex", "Book Index"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_book_index"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "bookindex"; - comp_obj_.tags.anchor_tags = ["section_bookindex"]; - comp_obj_.has.inline_links = true; - bookindex_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - ++mkn; - } - { - comp_obj_ = set_object_heading("lev4", "backmatter", "bookindex", "Index"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "bookindex"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.metainfo.heading_lev_collapsed = 2; - comp_obj_.has.inline_links = false; - comp_obj_.tags.anchor_tags = ["bookindex"]; - bookindex_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - ++mkn; - } - import std.array : appender; - auto buffer = appender!(char[])(); - string[dchar] transTable = [' ' : "_"]; - foreach (mainkey; mainkeys) { - bi_tmp_tags = [""]; - bi_tmp = mkup.ff_i ~ mkup.bold ~ mkup.ff_o ~ mainkey ~ mkup.ff_c ~ mkup.bold ~ " "; - buffer.clear(); - bi_tmp_tags ~= translate(mainkey, transTable); - auto bkidx_lnk(string locs) { - string markup = ""; - if (auto m = locs.matchFirst(rgx.book_index_go)) { - markup - = links_and_images("{ " ~ m["link"] ~ " }" - ~ "#" ~ m["ocn"] ~ ", "); - } else { - writeln(__LINE__, ": ", locs); - } - return markup; - } - foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - bi_tmp ~= bkidx_lnk(ref_); - } - bi_tmp ~= " \\\\\n "; - bookindex_unordered_hashes[mainkey].remove("_a"); - auto subkeys = - bookindex_unordered_hashes[mainkey].byKey.array - .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; - foreach (subkey; subkeys) { - bi_tmp ~= subkey ~ ", "; - buffer.clear(); - bi_tmp_tags ~= translate(subkey, transTable); - foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - bi_tmp ~= bkidx_lnk(ref_); - } - bi_tmp ~= " \\\\\n "; - ++skn; - } - bi_tmp = bi_tmp.replaceFirst(rgx.trailing_linebreak, ""); - comp_obj_ = set_object_generic("backmatter", "bookindex", "para", "bookindex", bi_tmp.to!string.strip, 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.anchor_tags = bi_tmp_tags; - comp_obj_.attrib.indent_hang = 0; - comp_obj_.attrib.indent_base = 1; - comp_obj_.attrib.bullet = false; - comp_obj_.has.inline_links = true; - comp_obj_.text = bi_tmp.to!string.strip; - bookindex_section ~= comp_obj_; - ++mkn; - } - } else { // no book index, (figure out what to do here) - comp_obj_ = set_object_heading("lev1", "backmatter", "bookindex", "(skip) there is no Book Index"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - bookindex_section ~= comp_obj_; - } - ST_bookindex ret; - { - ret.bookindex = bookindex_section; - ret.ocn = obj_cite_digits; - } - return ret; - } - } - // ↑ - section book index - // ↓ - section glossary - // ↓ build - ST_the_section build_the_glossary_section( - char[] line, // line is immutable, not necessary to return unchanged - uint[string] pith, // double check, should not be necessary to pass pith - string[string][string] tag_assoc, // only for headings: html & epub - ) { - static auto rgx = RgxI(); - ObjGenericComposite comp_obj_; - ObjGenericComposite[] add_to_current_document_section; - indent = [ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - pith["txt_is"] = eN.txt_is.para; - line_occur["para"] = eN.bi.off; - an_object_key = "glossary_nugget"; - ST_the_section ret; - if (line.matchFirst(rgx.heading_glossary)) { - { - comp_obj_ = set_object_heading("lev1", "backmatter", "glossary", "Glossary"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_glossary"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "glossary"; - comp_obj_.tags.anchor_tags = ["section_glossary"]; - comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - add_to_current_document_section ~= comp_obj_; // - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } { - comp_obj_ = set_object_heading("lev4", "backmatter", "glossary", "Glossary"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "glossary"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.metainfo.heading_lev_collapsed = 2; - comp_obj_.tags.anchor_tags = ["glossary"]; - add_to_current_document_section ~= comp_obj_; // - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - pith["ocn"] = eN.ocn.on; - } - { - ret.comp_section_obj ~= add_to_current_document_section; - ret.pith = pith; - ret.tag_assoc = tag_assoc; // only for headings: html & epub - } - } else { // para - { - auto _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; - pith = _get.pith; - indent = _get.indent; - bullet = _get.bullet; - line_occur = _get.line_occur; - } - } - comp_obj_ = set_object_generic("backmatter", "glossary", "para", "glossary", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.attrib.indent_hang = indent["hang_position"]; - comp_obj_.attrib.indent_base = indent["base_position"]; - comp_obj_.attrib.bullet = bullet; - add_to_current_document_section ~= comp_obj_; // - pith["ocn"] = eN.ocn.on; - { - ret.comp_section_obj = add_to_current_document_section; - ret.pith = pith; - ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub - } - } - return ret; - } - // ↑ - section glossary - // ↓ - section bibliography - @system ST_biblio_section backmatter_make_the_bibliography_section()( - string[] biblio_unsorted_incomplete, - JSONValue[] bib_arr_json, - ) { - Bibliography biblio = Bibliography(); - ObjGenericComposite comp_obj_; - static auto mkup = InlineMarkup(); - ST_flow_bibliography _get = biblio.flow_bibliography_(biblio_unsorted_incomplete, bib_arr_json); - JSONValue[] biblio_ordered; - biblio_ordered = _get.biblio_sorted; - if (biblio_ordered.length > 0) { - { - comp_obj_ = set_object_heading("lev1", "backmatter", "bibliography", "Bibliography"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_bibliography"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "bibliography"; - comp_obj_.tags.anchor_tags = ["section_bibliography"]; - comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_document_bibliography_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } - { - comp_obj_ = set_object_heading("lev4", "backmatter", "bibliography", "Bibliography"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "bibliography"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.tags.anchor_tags = ["bibliography"]; - the_document_bibliography_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } - { - string out_; - foreach (entry; biblio_ordered) { - out_ = format("%s \"%s\"%s%s%s%s%s%s%s%s%s.", - ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str), - entry["fulltitle"].str, - ((entry["journal"].str.empty) ? "" : ", " ~ mkup.ff_i ~ mkup.italic ~ mkup.ff_o ~ entry["journal"].str ~ mkup.ff_c ~ mkup.italic), - ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str), - ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str), - ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""), - ", " ~ entry["year"].str, - ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str), - ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str), - ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str), - ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"), - ); - comp_obj_ = set_object_generic("backmatter", "bibliography", "para", "bibliography", out_.to!string.strip, 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.attrib.indent_hang = 0; - comp_obj_.attrib.indent_base = 1; - comp_obj_.attrib.bullet = bullet; - comp_obj_.tags.anchor_tags = [anchor_tag]; - the_document_bibliography_section ~= comp_obj_; - } - } - } else { - comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Bibliography"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - the_document_bibliography_section ~= comp_obj_; - } - debug(bibliosection) { foreach (o; the_document_bibliography_section) { writeln(o.text); } } - ST_biblio_section ret; - { - ret.bibliography_section = the_document_bibliography_section; - ret.tag_assoc = tag_assoc; // - } - return ret; - } - struct Bibliography { - @system ST_flow_bibliography flow_bibliography_()( - string[] biblio_unsorted_incomplete, - JSONValue[] bib_arr_json - ) { - JSONValue[] biblio_unsorted - = biblio_make_unsorted_array_of_json_objects(biblio_unsorted_incomplete, bib_arr_json); // TODO lookat returns - biblio_arr_json = []; - biblio_unsorted_incomplete = []; - JSONValue[] biblio_sorted__ = biblio_sort(biblio_unsorted); - debug(biblio0) { - biblio_debug(biblio_sorted__); - writeln("---"); - writeln("unsorted incomplete: ", biblio_unsorted_incomplete.length); - writeln("json: ", bib_arr_json.length); - writeln("unsorted: ", biblio_unsorted.length); - writeln("sorted: ", biblio_sorted__.length); - int cntr; - int[7] x; - while (cntr < x.length) { - writeln(cntr, ": ", biblio_sorted__[cntr]["fulltitle"]); - cntr++; - } - } - ST_flow_bibliography ret; - { - ret.biblio_sorted = biblio_sorted__; - ret.bib_arr_json = bib_arr_json; - ret.biblio_unsorted_incomplete = biblio_unsorted_incomplete; - } - return ret; - } - @system final private JSONValue[] biblio_make_unsorted_array_of_json_objects()( - string[] biblio_unordered, - JSONValue[] bib_arr_json - ) { - foreach (bibent; biblio_unordered) { - // update bib to include deemed_author, needed for: - // sort_bibliography_array_by_deemed_author_year_title - // either: sort on multiple fields, or; create such sort field - JSONValue j = parseJSON(bibent); - if (!empty(j["fulltitle"].str)) { - if (!empty(j["author_raw"].str)) { - j["deemed_author"] = j["author_arr"][0]; - } else if (!empty(j["editor_raw"].str)) { - j["deemed_author"] = j["editor_arr"][0]; - } - j["sortby_deemed_author_year_title"] = ( - j["deemed_author"].str ~ - "; " ~ - j["year"].str ~ - "; " ~ - j["fulltitle"].str - ); - } - bib_arr_json ~= j; - } - return bib_arr_json.dup; - } - @system final private JSONValue[] biblio_sort()(JSONValue[] biblio_unordered) { - JSONValue[] biblio_sorted_; - biblio_sorted_ - = sort!((a, b){ - return ((a["sortby_deemed_author_year_title"].str) < (b["sortby_deemed_author_year_title"].str)); - })(biblio_unordered).array; - debug(bibliosorted) { - foreach (j; biblio_sorted_) { - if (!empty(j["fulltitle"].str)) { writeln(j["sortby_deemed_author_year_title"]); } - } - } - return biblio_sorted_; - } - @system void biblio_debug()(JSONValue[] biblio_sorted) { - debug(biblio0) { - foreach (j; biblio_sorted) { - if (!empty(j["fulltitle"].str)) { writeln(j["sortby_deemed_author_year_title"]); } - } - } - } - } - // ↑ - section bibliography - // ↓ - section blurb - ST_the_section build_the_blurb_section(Opt) ( - char[] line, // line is immutable, not necessary to return unchanged - uint[string] pith, // double check, should not be necessary to pass pith - string[string][string] tag_assoc, // only for headings: html & epub - Opt opt_action, - ) { - static auto rgx = RgxI(); - ObjGenericComposite comp_obj_; - ObjGenericComposite[] add_to_current_document_section; - // assert (opt_action.backmatter && opt_action.section_blurb); - indent = [ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - if (auto m = line.matchFirst(rgx.para_indent)) { - debug(paraindent) { writeln(line); } - indent["hang_position"] = (m["indent"]).to!int; - indent["base_position"] = (m["indent"]).to!int; - } else if (line.matchFirst(rgx.para_bullet)) { - debug(parabullet) { writeln(line); } - bullet = true; - } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { - debug(paraindenthang) { writeln(line); } - indent = [ - "hang_position" : (m["hang"]).to!int, - "base_position" : (m["indent"]).to!int, - ]; - } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { - debug(parabulletindent) { writeln(line); } - indent = [ - "hang_position" : (m["indent"]).to!int, - "base_position" : (m["indent"]).to!int, - ]; - bullet = true; - } - pith["txt_is"] = eN.txt_is.para; - line_occur["para"] = eN.bi.off; - an_object_key = "blurb_nugget"; - ST_the_section ret; - if (line.matchFirst(rgx.heading_blurb) - && (opt_action.backmatter && opt_action.section_blurb)) { - { - comp_obj_ = set_object_heading("lev1", "backmatter", "blurb", "Blurb"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = false; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "_part_blurb"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = "blurb"; - comp_obj_.tags.anchor_tags = ["section_blurb"]; - comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - add_to_current_document_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } - { - comp_obj_ = set_object_heading("lev4", "backmatter", "blurb", "Blurb"); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = true; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "blurb"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.metainfo.heading_lev_collapsed = 2; - comp_obj_.tags.anchor_tags = ["blurb"]; - add_to_current_document_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - } - } else if (line.matchFirst(rgx.headings) - && (opt_action.backmatter && opt_action.section_blurb)) { - comp_obj_ = comp_obj_.init; - comp_obj_.metainfo.is_of_part = "backmatter"; - comp_obj_.metainfo.is_of_section = "blurb"; - comp_obj_.metainfo.is_of_type = "para"; - comp_obj_.metainfo.is_a = "heading"; - comp_obj_.text = line.to!string; - comp_obj_.metainfo.ocn = 0; - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.dummy_heading = false; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.tags.segment_anchor_tag_epub = "blurb"; - comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv - comp_obj_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv - comp_obj_.metainfo.parent_ocn = 1; - comp_obj_.metainfo.parent_lev_markup = 0; - add_to_current_document_section ~= comp_obj_; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - 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); - { - an_object = _get.this_object; - an_object_key = _get.this_object_key; - pith = _get.pith; - indent = _get.indent; - bullet = _get.bullet; - line_occur = _get.line_occur; - } - } - comp_obj_ = set_object_generic("backmatter", "blurb", "para", "blurb", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0); - comp_obj_.metainfo.identifier = ""; - comp_obj_.metainfo.object_number_off = true; - comp_obj_.metainfo.object_number_type = 0; - comp_obj_.attrib.indent_hang = indent["hang_position"]; - comp_obj_.attrib.indent_base = indent["base_position"]; - comp_obj_.has.inline_links = true; - comp_obj_.attrib.bullet = bullet; - add_to_current_document_section ~= comp_obj_; - } - pith["ocn"] = eN.ocn.on; - { - ret.comp_section_obj = add_to_current_document_section; - ret.pith = pith; - ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub - } - return ret; - } - // ↑ - section blurb - // ↓ - images - string[] extract_images()(string content_block) { - static auto rgx = RgxI(); - string[] images_; - if (auto m = content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1]; - } - return images_; - } - @system auto _image_dimensions(O,M)(O obj, M manifested) { - static auto rgx = RgxI(); - if (obj.has.image_without_dimensions) { - import std.math; - import imageformats; - int w, h, chans; - real _w, _h; - int max_width = 640; - foreach (img; obj.text.matchAll(rgx.inline_image_without_dimensions)) { - try { - read_image_info(manifested.src.image_dir_path ~ "/" ~ img["img"], w, h, chans); - } catch (Exception ex) { - writeln("WARNING, image not found: ", img["img"], "\n ", manifested.src.image_dir_path ~ "/" ~ img["img"]); - } - // calculate, decide max width and proportionally reduce to keep w & h within it - debug(images) { writeln("width: ", w, ", height: ", h); } - if (w > max_width) { - _w = max_width; - _h = round((max_width / w.to!real) * h.to!real); - } else { - _w = w; - _h = h; - } - obj.text = obj.text.replaceFirst( - rgx.inline_image_without_dimensions, - format(q"┃%s☼%s,w%sh%s %s┃", - "$1", - "$3", - _w.to!string, - _h.to!string, - "$6", - ) - ); - } - debug(images) { writeln("image without dimensions: ", obj.text); } - } - return obj; - } - // ↑ - images - // ↓ - links - auto _links(O)(O obj) { - static auto rgx = RgxI(); - if (auto m = obj.text.match(rgx.inline_link_stow_uri)) { - debug(links) { - writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count); - writeln("links to stow: ", (obj.text.match(rgx.inline_link_stow_uri))); - } - int _n_matches = (obj.text.match(rgx.inline_link_stow_uri)).count.to!int; - for(int i = 0; i < _n_matches; ++i) { - if (obj.text.match(rgx.inline_link_stow_uri)) { - obj.stow.link ~= obj.text.matchFirst(rgx.inline_link_stow_uri)[2]; - obj.text = obj.text.replaceFirst( - rgx.inline_link_stow_uri, - format(q"┃┥%s┝┤%s├┃", "$1", i) - ); - } - } - } - return obj; - } - // ↑ - links - // ↓ - segnames - @system ST_segnames after_doc_determine_segnames( - ObjGenericComposite[] the_document_body_section, - ObjGenericComposite[] the_document_endnotes_section, - ObjGenericComposite[] the_document_glossary_section, - ObjGenericComposite[] the_document_bibliography_section, - ObjGenericComposite[] the_document_bookindex_section, - ObjGenericComposite[] the_document_blurb_section, - string[][string] segnames, - int html_segnames_ptr_cntr, - int html_segnames_ptr, - ) { - 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) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_document_glossary_section.length > 1) { - segnames["html"] ~= "glossary"; - segnames["epub"] ~= "glossary"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_document_glossary_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_document_bibliography_section.length > 1) { - segnames["html"] ~= "bibliography"; - segnames["epub"] ~= "bibliography"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_document_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_document_bookindex_section.length > 1) { - segnames["html"] ~= "bookindex"; - segnames["epub"] ~= "bookindex"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_document_bookindex_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_document_blurb_section.length > 1) { - segnames["html"] ~= "blurb"; - segnames["epub"] ~= "blurb"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_document_blurb_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - ST_segnames ret; - ret.segnames = segnames; - ret.html_segnames_ptr_cntr = html_segnames_ptr_cntr; - ret.html_segnames_ptr = html_segnames_ptr; - return ret; - } - // ↑ - segnames - // ↓ - ancestors descendants - struct NodeStructureMetadata { - int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; - int obj_cite_digit; - int[string] p_; // p_ parent_ - static auto rgx = RgxI(); - ObjGenericComposite node_location_emitter(La,Ta)( - string lev_markup_number, - string[string] tag_in_seg, - La lev_anchor_tag, - Ta tag_assoc, - OCNset obj_cite_digits, - int cntr_, - int ptr_, - string is_ - ) { - debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } - assert(is_ != "heading"); - assert(obj_cite_digits.object_number.to!int >= 0); - assert(is_ != "heading"); // should not be necessary - assert(obj_cite_digits.object_number.to!int >= 0); // should not be necessary - if (lv7 > eN.bi.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_4; - p_["object_number"] = lv7; - } else if (lv6 > eN.bi.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_3; - p_["object_number"] = lv6; - } else if (lv5 > eN.bi.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_2; - p_["object_number"] = lv5; - } else { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; - p_["object_number"] = lv4; - } - ObjGenericComposite comp_obj_location; - comp_obj_location = comp_obj_location.init; - comp_obj_location.metainfo.is_a = is_; - comp_obj_location.metainfo.ocn = obj_cite_digits.object_number; - comp_obj_location.metainfo.identifier = obj_cite_digits.identifier; - comp_obj_location.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; - comp_obj_location.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"]; - comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; - comp_obj_location.metainfo.parent_ocn = p_["object_number"]; - comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; - debug(_node) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); - } else { writeln("- ", _node.to!string); } - } - assert(comp_obj_location.metainfo.parent_lev_markup >= 4); - assert(comp_obj_location.metainfo.parent_lev_markup <= 7); - assert(comp_obj_location.metainfo.parent_ocn >= 0); - return comp_obj_location; - } - invariant() { - } - ObjGenericComposite node_emitter_heading(O,TaL,TA,SOAT)( - O an_object, - string[string] tag_in_seg, - TaL lev_anchor_tag, - TA tag_assoc, - OCNset obj_cite_digits, - int cntr_, - int ptr_, - string[] lv_ancestors_txt, - int html_segnames_ptr, - SOAT substantive_object_and_anchor_tags_struct, - ) { - string _text = an_object["substantive"]; - string lev_markup_number = an_object["lev_markup_number"]; - string lev_collapsed_number = an_object["lev_collapsed_number"]; - string dummy_heading_status = an_object["dummy_heading_status"]; - string is_ = an_object["is"]; - debug(asserts) { - static assert(is(typeof(lev) == string)); - static assert(is(typeof(obj_cite_digits.object_number) == int)); - } - assert(is_ == "heading"); - assert((obj_cite_digits.object_number).to!int >= 0); - assert( - lev_markup_number.match(rgx.levels_numbered), - ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ obj_cite_digits.object_number.to!string) - ); - if (lev_markup_number.match(rgx.levels_numbered)) { - if (lev_markup_number.to!int == 0) { - // TODO first hit (of two) with this assertion failure, check, fix & reinstate - // assert(obj_cite_digits.object_number.to!int == 1, - // "ERROR header lev markup number is: " ~ - // lev_markup_number.to!string ~ - // " obj_cite_digits.object_number.to!int should == 1 but is: " ~ - // obj_cite_digits.object_number.to!string ~ - // "\n" ~ _text); - } - } - switch (lev_markup_number.to!int) { - case 0: - lv = DocStructMarkupHeading.h_sect_A; - lv0 = obj_cite_digit; - lv1 = 0; lv2 = 0; lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; - p_["lev_markup_number"] = 0; - p_["object_number"] = 0; - break; - case 1: - lv = DocStructMarkupHeading.h_sect_B; - lv1 = obj_cite_digit; - lv2 = 0; lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_A; - p_["object_number"] = lv0; - break; - case 2: - lv = DocStructMarkupHeading.h_sect_C; - lv2 = obj_cite_digit; - lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_B; - p_["object_number"] = lv1; - break; - case 3: - lv = DocStructMarkupHeading.h_sect_D; - lv3 = obj_cite_digit; - lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_C; - p_["object_number"] = lv2; - break; - case 4: - lv = DocStructMarkupHeading.h_text_1; - lv4 = obj_cite_digit; - lv5 = 0; lv6 = 0; lv7 = 0; - if (lv3 > eN.bi.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_D; - p_["object_number"] = lv3; - } else if (lv2 > eN.bi.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_C; - p_["object_number"] = lv2; - } else if (lv1 > eN.bi.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_B; - p_["object_number"] = lv1; - } else { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_A; - p_["object_number"] = lv0; - } - break; - case 5: - lv = DocStructMarkupHeading.h_text_2; - lv5 = obj_cite_digit; - lv6 = 0; lv7 = 0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_1; - p_["object_number"] = lv4; - break; - case 6: - lv = DocStructMarkupHeading.h_text_3; - lv6 = obj_cite_digit; - lv7 = 0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_2; - p_["object_number"] = lv5; - break; - case 7: - lv = DocStructMarkupHeading.h_text_4; - lv7 = obj_cite_digit; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_3; - p_["object_number"] = lv6; - break; - default: - break; - } - ObjGenericComposite comp_obj_; - comp_obj_ = comp_obj_.init; - comp_obj_.metainfo.is_of_part = "body"; - comp_obj_.metainfo.is_of_section = "body"; - comp_obj_.metainfo.is_of_type = "para"; - comp_obj_.metainfo.is_a = "heading"; - comp_obj_.text = _text.to!string.strip; - comp_obj_.metainfo.ocn = obj_cite_digits.object_number; - comp_obj_.metainfo.identifier = obj_cite_digits.identifier; - comp_obj_.metainfo.dummy_heading = (dummy_heading_status == "t") ? true: false; - 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.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"]; - comp_obj_.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; - comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; - comp_obj_.tags.heading_lev_anchor_tag = lev_anchor_tag; - 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_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); - comp_obj_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); - comp_obj_.metainfo.parent_ocn = p_["object_number"]; - comp_obj_.metainfo.parent_lev_markup = p_["lev_markup_number"]; - comp_obj_.tags.heading_ancestors_text = lv_ancestors_txt; - comp_obj_.ptr.doc_object = cntr_; - comp_obj_.ptr.html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0); - comp_obj_.ptr.heading = ptr_; - comp_obj_.has.inline_notes_reg = substantive_object_and_anchor_tags_struct.has_notes_reg; - comp_obj_.has.inline_notes_star = substantive_object_and_anchor_tags_struct.has_notes_star; - comp_obj_.has.inline_links = substantive_object_and_anchor_tags_struct.has_links; - tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; - tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; - debug(_node) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } - } - debug(nodeheading) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } - } - assert(comp_obj_.metainfo.parent_lev_markup <= 7); - assert(comp_obj_.metainfo.parent_ocn >= 0); - if (lev_markup_number.match(rgx.levels_numbered_headings)) { - assert(comp_obj_.metainfo.heading_lev_markup <= 7); - assert(comp_obj_.metainfo.ocn >= 0); - if (comp_obj_.metainfo.parent_lev_markup > 0) { - assert(comp_obj_.metainfo.parent_lev_markup < comp_obj_.metainfo.heading_lev_markup); - if (comp_obj_.metainfo.ocn != 0) { - assert(comp_obj_.metainfo.parent_ocn < comp_obj_.metainfo.ocn); - } - } - if (comp_obj_.metainfo.heading_lev_markup == 0) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_B) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_C) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_B); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_D) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_C); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_1) { - assert(comp_obj_.metainfo.parent_lev_markup <= DocStructMarkupHeading.h_sect_D); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_2) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_1); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_3) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_2); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_4) { - assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_3); - } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_5) { - } - } - return comp_obj_; - } - invariant() { - } - } - @system ST_ancestors after_doc_determine_ancestors( - ObjGenericComposite[] the_document_body_section, - ObjGenericComposite[] the_document_endnotes_section, - ObjGenericComposite[] the_document_glossary_section, - ObjGenericComposite[] the_document_bibliography_section, - ObjGenericComposite[] the_document_bookindex_section, - ObjGenericComposite[] the_document_blurb_section, - ) { - int[] _get_ancestors_markup(ObjGenericComposite obj, int[] _ancestors_markup) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { writeln(obj.text); } - if (obj.metainfo.heading_lev_markup == 1) { - _ancestors_markup = [ - _ancestors_markup[0], - 0,0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 2) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - 0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 3) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - 0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 4) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - 0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 5) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - 0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 6) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - 0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 7) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - _ancestors_markup[6], - 0 - ]; - } - if (obj.metainfo.heading_lev_markup == 8) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - _ancestors_markup[6], - _ancestors_markup[7] - ]; - } - _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; - } - debug(ancestor_markup) { writeln("marked up: ", _ancestors_markup); } - return _ancestors_markup; - } - int[] _get_ancestors_collapsed(ObjGenericComposite obj, int[] _ancestors_collapsed) { - if (obj.metainfo.is_a == "heading") { - if (obj.metainfo.heading_lev_collapsed == 1) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - 0,0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 2) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - 0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 3) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - 0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 4) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - 0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 5) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - 0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 6) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - 0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 7) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - _ancestors_collapsed[6], - 0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 8) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - _ancestors_collapsed[6], - _ancestors_collapsed[7] - ]; - } - _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; - } - debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); } - return _ancestors_collapsed; - } - // multiple 1~ levels, loop through document body - if (the_document_body_section.length > 1) { - int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; - int[][] _ancestors_markup_; - _ancestors_markup = [1,0,0,0,0,0,0,0]; - _ancestors_markup_ ~= _ancestors_markup; - int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; - int[][] _ancestors_collapsed_; - _ancestors_collapsed = [1,0,0,0,0,0,0,0]; - _ancestors_collapsed_ ~= _ancestors_collapsed; - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); - obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed); - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - } - debug(ancestors) { - writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); - writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); - } - } - ST_ancestors ret; - ret.the_document_body_section = the_document_body_section; - ret.the_document_endnotes_section = the_document_endnotes_section; - ret.the_document_glossary_section = the_document_glossary_section; - ret.the_document_bibliography_section = the_document_bibliography_section; - ret.the_document_bookindex_section = the_document_bookindex_section; - ret.the_document_blurb_section = the_document_blurb_section; - return ret; - } - // ↑ - ancestors - // ↓ - descendants - // descendants - auto after_doc_get_descendants()(ObjGenericComposite[] document_sections) { - int[string] _heading_ocn_descendants; - string[] _ocn_open_key = ["","","","","","","",""]; - auto _doc_sect_length = document_sections.length - 1; - int _last_ocn; - foreach (_lg, ref obj; document_sections) { - if (obj.metainfo.is_a == "heading") { - foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) { - switch (dom_tag_status) with (DomTags) { - case none: break; - case open: - _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; - _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; - break; - case close: - if (_ocn_open_key[_dts_lv].empty) { - _ocn_open_key[_dts_lv] = "0"; - } - _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; - _ocn_open_key[_dts_lv] = (0).to!string; - break; - case close_and_open: - if (_ocn_open_key[_dts_lv].empty) { - _ocn_open_key[_dts_lv] = "0"; - } - _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; - _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; - _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; - break; - case open_still: break; - default: break; - } - } - } - if (obj.metainfo.ocn > 0) { - _last_ocn = obj.metainfo.ocn; - } - if (_lg == _doc_sect_length) { - _heading_ocn_descendants["1"] = _last_ocn; // close existing o_n key - } - } - Tuple!(int, int)[] pairs; - foreach (pair; _heading_ocn_descendants.byPair) { - pairs ~= tuple(pair[0].to!int, pair[1]); - } - return pairs.sort; - } - // ↑ - descendants - // ↓ - assertions - pure void assertions_doc_structure()( - string[string] an_object, - string an_object_key, - int[string] lv - ) { - string msg_error_doc_struct = "\nERROR in document structure, check markup (heading level relationships):\n"; - if (lv["h3"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h2"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h2"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h1"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h0"] > eN.bi.off) { - assert(lv["h1"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else { - assert(lv["h0"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h1"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h7"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h6"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h6"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h5"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else if (lv["h4"] > eN.bi.off) { - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } else { - assert(lv["h4"] == eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h4"] == eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h1"] == eN.bi.off) { - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h2"] == eN.bi.off) { - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h3"] == eN.bi.off) { - } - if (lv["h4"] == eN.bi.off) { - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h5"] == eN.bi.off) { - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h6"] == eN.bi.off) { - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ an_object[an_object_key] - ); - } - if (lv["h7"] == eN.bi.off) { - } - switch ((an_object["lev"]).to!string) { - case "A": - if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] == eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~\n" - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h0"] > eN.bi.off) - assert(lv["h0"] == eN.bi.off, - msg_error_doc_struct - ~ "should not enter level A a second time\n" - ~ "at level A~\n" - ~ an_object[an_object_key] - ); - } - break; - case "B": - if (lv["h1"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level B~\n" - ~ an_object[an_object_key] - ); - assert(lv["h2"] == eN.bi.off, - msg_error_doc_struct - ~ "at level B~\n" - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ "at level B~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h1"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level B~\n" - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ "at level B~\n" - ~ an_object[an_object_key] - ); - } - break; - case "C": - if (lv["h2"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ "level C should not follow level A\n" - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - assert(lv["h3"] == eN.bi.off, - msg_error_doc_struct - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h2"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - assert(lv["h2"] > eN.bi.off, - msg_error_doc_struct - ~ "at level C~\n" - ~ an_object[an_object_key] - ); - } - break; - case "D": - if (lv["h3"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ "level D should not follow level A\n" - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - assert(lv["h2"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h3"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - assert(lv["h1"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - assert(lv["h2"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - assert(lv["h3"] > eN.bi.off, - msg_error_doc_struct - ~ "at level D~\n" - ~ an_object[an_object_key] - ); - } - break; - case "1": - if (lv["h4"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h4"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 1~\n" - ~ an_object[an_object_key] - ); - } - break; - case "2": - if (lv["h5"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h5"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 2~\n" - ~ an_object[an_object_key] - ); - } - break; - case "3": - if (lv["h6"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 2~ ?\n" - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h7"] == eN.bi.off, - msg_error_doc_struct - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h6"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 3~\n" - ~ an_object[an_object_key] - ); - } - break; - case "4": - if (lv["h7"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 2~ ?\n" - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 3~ ?\n" - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - } else { // (lv["h7"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h4"] > eN.bi.off, - msg_error_doc_struct - ~ "missing segment level 1~ ?\n" - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h5"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h6"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - assert(lv["h7"] > eN.bi.off, - msg_error_doc_struct - ~ "at level 4~\n" - ~ an_object[an_object_key] - ); - } - break; - default: - break; - } - } - // ↑ - assertions -} -template docSectKeysSeq() { - auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { - struct doc_sect_keys_seq { - string[] scroll() { - return document_section_keys_sequenced["scroll"]; - } - string[] seg() { - return document_section_keys_sequenced["seg"]; - } - string[] sql() { - return document_section_keys_sequenced["sql"]; - } - string[] latex() { - return document_section_keys_sequenced["latex"]; - } - } - return doc_sect_keys_seq(); - } -} diff --git a/src/doc_reform/meta/metadoc_object_setter.d b/src/doc_reform/meta/metadoc_object_setter.d deleted file mode 100644 index 7bfaebf..0000000 --- a/src/doc_reform/meta/metadoc_object_setter.d +++ /dev/null @@ -1,426 +0,0 @@ -/+ -- Name: 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 - 2024 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.doc_reform.org] - [https://www.sisudoc.org] - - - Git - [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] - -+/ -/++ - object setter: - setting of sisu objects for downstream processing - metadoc_object_setter.d -+/ -module doc_reform.meta.metadoc_object_setter; -@safe: -template ObjectSetter() { - /+ structs +/ - struct DocObj_TxtAttrib_ { - 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; - } - struct DocObj_Table_ { - 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; - } - struct DocObj_Stow_ { - string[] link = []; - } - struct DocObj_Pointer_ { - 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 = []; - } - 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 - /+ 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; - string object_number_substantive() const @property { - return (o_n_substantive == 0) ? "" : o_n_substantive.to!string; - } - string object_number_non_substantive() const @property { - return (o_n_non_substantive == 0) ? "" : o_n_non_substantive.to!string; - } - string object_number_glossary() const @property { - return (o_n_glossary == 0) ? "" : o_n_glossary.to!string; - } - string object_number_bibliography() const @property { - return (o_n_bibliography == 0) ? "" : o_n_bibliography.to!string; - } - string object_number_book_index() const @property { - return (o_n_book_index == 0) ? "" : o_n_book_index.to!string; - } - string object_number_blurb() const @property { - return (o_n_blurb == 0) ? "" : o_n_blurb.to!string; - } - string marked_up_level() const @property { - string _out; - switch (heading_lev_markup) { - case 0 : _out = "A"; break; - case 1 : _out = "B"; break; - case 2 : _out = "C"; break; - case 3 : _out = "D"; break; - case 4 : _out = "1"; break; - case 5 : _out = "2"; break; - case 6 : _out = "3"; break; - case 7 : _out = "4"; break; - default : _out = ""; break; // "9"; - } - return _out; - } - string object_number() const @property { - return (ocn == 0) ? "" : ocn.to!string; - } - bool object_number_off = false; - bool visible_object_number = false; - int object_number_type = 0; // { ocn, non, bkidx } - /+ node +/ - string[string][string] node; - int ocn = 0; - string identifier = ""; - int o_n_type = 0; - int heading_lev_markup = 9; - int heading_lev_collapsed = 9; - bool dummy_heading = false; - int[] markedup_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] collapsed_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int parent_lev_markup = 0; - int parent_ocn = 0; - int last_descendant_ocn = 0; - } - struct ObjGenericComposite { - string text = ""; - DocObj_MetaInfo_ metainfo; - DocObj_TxtAttrib_ attrib; - DocObj_Tags_ tags; - DocObj_Has_ has; - DocObj_Table_ table; - DocObj_CodeBlock_ code_block; - DocObj_Stow_ stow; - DocObj_Pointer_ ptr; - } - struct _theDoc { - ObjGenericComposite[] toc; - ObjGenericComposite[] head; - ObjGenericComposite[] body; - ObjGenericComposite[] bibliography; - ObjGenericComposite[] glossary; - ObjGenericComposite[] bookindex; - ObjGenericComposite[] blurb; - ObjGenericComposite[] endnotes; - } - struct TheObjects { - ObjGenericComposite[] oca; - } - ObjGenericComposite comp_obj_, comp_obj_location, comp_obj_poem_ocn, comp_obj_comment; - ObjGenericComposite[] the_document_toc_section, the_document_head_section, the_document_body_section, the_document_endnotes_section, the_document_bibliography_section, the_document_bookindex_section, the_document_glossary_section, the_document_blurb_section, the_document_xml_dom_tail_section; - struct OCNset { - int digit; - int object_number; - bool off; - string identifier; - int bkidx; - int type; - } - struct ST_endnotes { - ObjGenericComposite[] endnotes; - OCNset ocn; - } - struct ST_bookindex { - ObjGenericComposite[] bookindex; - OCNset ocn; - } - struct ST_biblio_section { - ObjGenericComposite[] bibliography_section; - string[string][string] tag_assoc; - } - struct ST_ancestors { - ObjGenericComposite[] the_document_body_section; - ObjGenericComposite[] the_document_endnotes_section; - ObjGenericComposite[] the_document_glossary_section; - ObjGenericComposite[] the_document_bibliography_section; - ObjGenericComposite[] the_document_bookindex_section; - ObjGenericComposite[] the_document_blurb_section; - } - struct ST_segnames { - string[][string] segnames; - int html_segnames_ptr_cntr; - int html_segnames_ptr; - } - struct ST_txtPlusHasFootnotes { - string obj_txt; - bool has_notes_reg; - bool has_notes_star; - bool has_notes_plus; - } - struct ST_txtPlusHasFootnotesUrlsImages { - string obj_txt; - bool has_notes_reg; - bool has_notes_star; - bool has_notes_plus; - bool has_urls; - bool has_images_without_dimensions; - } - struct ST_txtAndAnchorTagPlusHasFootnotesUrlsImages { - string obj_txt; - string anchor_tag; - bool has_notes_reg; - bool has_notes_star; - bool has_notes_plus; - bool has_links; // use same name - bool has_images_without_dimensions; - } - struct ST_the_section { - ObjGenericComposite[] comp_section_obj; // array: the heading has 2 members inserted, paras just 1 - uint[string] pith; - string[string][string] tag_assoc; // only for headings: html & epub - } - // book index variables - string book_idx_tmp; - string[][string][string] bookindex_unordered_hashes; - // node - struct ST_txt_by_line_common_reset { - int[string] line_occur; - string[string] this_object; - uint[string] pith; - } - struct ST_txt_by_line_block_start { - uint[string] pith; - uint[string] dochas; - string[string] object_number_poem; - } - struct ST_txt_by_line_block_generic { - uint[string] pith; - string[string] this_object; - } - struct ST_txt_by_line_block_poem { - int cntr; - uint[string] pith; - string[string] this_object; - } - struct ST_txt_by_line_block_biblio { - uint[string] pith; - int bib_entry; - string biblio_entry_str_json; - string[] biblio_arr_json; - } - struct ST_flow_book_index { - string[string] this_object; - uint[string] pith; - string book_idx_tmp; - } - struct ST_flow_heading_found { - string[string] heading_match_str; - Regex!(char)[string] heading_match_rgx; - uint[string] pith; - } - struct ST_flow_heading_make_set { - char[] line; - uint[string] pith; - string[string] this_object; - } - struct ST_flow_para_match { - uint[string] pith; - string[string] this_object; - string this_object_key; - int[string] indent; - bool bullet; - int[string] line_occur; - } - struct ST_flow_table_array_munge { - ObjGenericComposite table_object; - string[][] table_array; - } - struct ST_flow_table_of_contents_gather_headings { - ObjGenericComposite[] the_document_toc_section; - string[][string] lev4_subtoc; - } - struct ST_flow_bibliography { - JSONValue[] biblio_sorted; - JSONValue[] bib_arr_json; - string[] biblio_unsorted_incomplete; - } - struct ST_flow_table_closed_make_special_notation_table { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - OCNset obj_cite_digits; - ObjGenericComposite comp_obj_; - int cntr; - uint[string] pith; - } - struct ST_flow_block_flag_line_empty { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - string[][string][string] bookindex_unordered_hashes; - OCNset obj_cite_digits; - ObjGenericComposite comp_obj_; - int cntr; - uint[string] pith; - } - struct ST_flow_table_substantive_munge { - ObjGenericComposite table_object; - string table_substantive; - } - struct _loopMarkupSrcByLineStruct { - ObjGenericComposite[] toc; - ObjGenericComposite[] body; - ObjGenericComposite[] glossary; - ObjGenericComposite[] blurb; - string[string] object_notes; - string[][string] segnames; - } - enum DocStructMarkupHeading { - h_sect_A, - h_sect_B, - h_sect_C, - h_sect_D, - h_text_1, - h_text_2, - h_text_3, - h_text_4, - h_text_5, // extra level, drop - content_non_header - } // header section A-D; header text 1-4 - enum Status { off, on, } - enum OCNtype { ocn, non, bkidx, } - enum DomTags { none, open, close, close_and_open, open_still, } - enum Substitute { match, markup, } - static auto eN() { - struct _e { - enum bi { - off, - on, - } - enum ocn { - off, - on, - closing, - bkidx, - reset, - } - enum sect { - unset, - head, - toc, - substantive, - bibliography, - glossary, - book_index, - blurb, - } - enum txt_is { - off, - para, - heading, - } - enum blk_is { - off, - code, - poem, - block, - group, - table, - quote, - } - enum blk_state { - off, - on, - closing, - } - enum blk_delim { - off, - curly, - tic, - curly_special, - tic_special, - } - } - return _e(); - } -} diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d deleted file mode 100644 index 16307e8..0000000 --- a/src/doc_reform/meta/metadoc_show_config.d +++ /dev/null @@ -1,232 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta.metadoc_show_config; -@safe: -template spineShowSiteConfig() { - void spineShowSiteConfig(O,T)( - O opt_action, - T config, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - auto char_repeat_number = 66; - if (opt_action.show_config) { - writefln( - "\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", - markup.repeat_character_by_number_provided("-", char_repeat_number), - "- webserv host name:", - config.conf.w_srv_host, - "- webserv doc root (part):", - config.conf.w_srv_data_root_part, - "- webserv doc path:", - config.conf.w_srv_data_root_path, - "- webserv images (location):", - config.conf.w_srv_images_root_part, - "- webserv doc root url:", - config.conf.w_srv_data_root_url, - "- webserv cgi host (host):", - config.conf.w_srv_cgi_host, - "- webserv cgi host path:", - config.conf.w_srv_cgi_bin_path, - "- webserv cgi host (part):", - config.conf.w_srv_cgi_bin_subpath, - "- webserv cgi search script:", - config.conf.w_srv_cgi_search_script, - "- webserv cgi search script in d:", - config.conf.w_srv_cgi_search_script_raw_fn_d, - "- webserv cgi port:", - config.conf.w_srv_cgi_port, - "- webserv cgi user:", - config.conf.w_srv_cgi_user, - "- webserv cgi url:", - config.conf.w_srv_cgi_bin_url, - "- webserv cgi action:", - config.conf.w_srv_cgi_action, - "- webserv cgi title:", - config.conf.w_srv_cgi_search_form_title, - // "- webserv cgi file links:", - // config.conf.w_srv_cgi_file_links, - "- webserv sqlite db:", - config.conf.w_srv_db_sqlite_filename, - "- output path:", - config.conf.output_path, - "- processing concordance max:", - config.conf.processing_concord_max, - // "- flag act0:", - // config.conf.flag_act0, - "- default papersize:", - config.conf.set_papersize, - "- default text wrap:", - config.conf.set_text_wrap, - "- default emphasis markup symbol:", - config.conf.set_emphasis, - "- default language:", - config.conf.set_language, - "- default hash digest:", - config.conf.set_digest, - "- search flag:", - config.conf.search_flag, - "- search action:", - config.conf.search_action, - "- search db:", - config.conf.search_db, - "- search title:", - config.conf.search_title, - ); - } - } -} -template spineShowConfig() { - void spineShowConfig(T)( - T doc_matters, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - auto min_repeat_number = 66; - auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length - + doc_matters.conf_make_meta.meta.creator_author.length + 4); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - if (doc_matters.opt.action.show_config - && doc_matters.opt.action.debug_do - ) { - writeln(doc_matters.conf_make_meta.conf); - } - if (doc_matters.opt.action.show_config) { - writefln( - "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", - markup.repeat_character_by_number_provided("-", char_repeat_number), - doc_matters.conf_make_meta.meta.title_full, - doc_matters.conf_make_meta.meta.creator_author, - doc_matters.src.filename, - markup.repeat_character_by_number_provided("-", char_repeat_number), - "- webserv host name:", - doc_matters.conf_make_meta.conf.w_srv_host, - "- webserv doc root (part):", - doc_matters.conf_make_meta.conf.w_srv_data_root_part, - "- webserv doc path:", - doc_matters.conf_make_meta.conf.w_srv_data_root_path, - "- webserv images (location):", - doc_matters.conf_make_meta.conf.w_srv_images_root_part, - "- webserv doc root url:", - doc_matters.conf_make_meta.conf.w_srv_data_root_url, - "- webserv cgi host (host):", - doc_matters.conf_make_meta.conf.w_srv_cgi_host, - "- webserv cgi host path:", - doc_matters.conf_make_meta.conf.w_srv_cgi_bin_path, - "- webserv cgi host (part):", - doc_matters.conf_make_meta.conf.w_srv_cgi_bin_subpath, - "- webserv cgi search script:", - doc_matters.conf_make_meta.conf.w_srv_cgi_search_script, - "- webserv cgi search script in d:", - doc_matters.conf_make_meta.conf.w_srv_cgi_search_script_raw_fn_d, - "- webserv cgi url:", - doc_matters.conf_make_meta.conf.w_srv_cgi_bin_url, - "- webserv cgi action:", - doc_matters.conf_make_meta.conf.w_srv_cgi_action, - // "- webserv cgi file links:", - // doc_matters.conf_make_meta.conf.w_srv_cgi_file_links, - "- webserv sqlite db:", - doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename, - "- output path:", - doc_matters.conf_make_meta.conf.output_path, - "- processing concordance max:", - doc_matters.conf_make_meta.conf.processing_concord_max, - // "- flag act0:", - // doc_matters.conf_make_meta.conf.flag_act0, - "- default papersize:", - doc_matters.conf_make_meta.conf.set_papersize, - "- default text wrap:", - doc_matters.conf_make_meta.conf.set_text_wrap, - "- default emphasis markup symbol:", - doc_matters.conf_make_meta.conf.set_emphasis, - "- default language:", - doc_matters.conf_make_meta.conf.set_language, - "- default hash digest:", - doc_matters.conf_make_meta.conf.set_digest, - "- search flag:", - doc_matters.conf_make_meta.conf.search_flag, - "- search action:", - doc_matters.conf_make_meta.conf.search_action, - "- search db:", - doc_matters.conf_make_meta.conf.search_db, - "- search title:", - doc_matters.conf_make_meta.conf.search_title, - ); - } - } -} diff --git a/src/doc_reform/meta/metadoc_show_make.d b/src/doc_reform/meta/metadoc_show_make.d deleted file mode 100644 index 16a175d..0000000 --- a/src/doc_reform/meta/metadoc_show_make.d +++ /dev/null @@ -1,123 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta.metadoc_show_make; -@safe: -template spineShowMake() { - void spineShowMake(T)( - T doc_matters, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - auto min_repeat_number = 66; - auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length - + doc_matters.conf_make_meta.meta.creator_author.length + 4); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - if (doc_matters.opt.action.show_make - && doc_matters.opt.action.debug_do - ) { - writeln(doc_matters.conf_make_meta.make); - } - if (doc_matters.opt.action.show_make) { - writefln( - "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", - markup.repeat_character_by_number_provided("-", char_repeat_number), - doc_matters.conf_make_meta.meta.title_full, - doc_matters.conf_make_meta.meta.creator_author, - doc_matters.src.filename, - markup.repeat_character_by_number_provided("-", char_repeat_number), - "- bold:", - doc_matters.conf_make_meta.make.bold, - "- breaks:", - doc_matters.conf_make_meta.make.breaks, - "- cover image:", - doc_matters.conf_make_meta.make.cover_image, - "- css:", - doc_matters.conf_make_meta.make.css, - "- emphasis:", - doc_matters.conf_make_meta.make.emphasis, - "- css:", - doc_matters.conf_make_meta.make.css, - "- footer:", - doc_matters.conf_make_meta.make.footer, - "- headings:", - doc_matters.conf_make_meta.make.headings, - "- home button image:", - doc_matters.conf_make_meta.make.home_button_image, - "- home button text:", - doc_matters.conf_make_meta.make.home_button_text, - "- italics:", - doc_matters.conf_make_meta.make.italics, - "- auto num top at level:", - doc_matters.conf_make_meta.make.auto_num_top_at_level, - "- auto num top level:", - doc_matters.conf_make_meta.make.auto_num_top_lv, - "- auto num depth:", - doc_matters.conf_make_meta.make.auto_num_depth, - "- texpdf font:", - doc_matters.conf_make_meta.make.texpdf_font, - ); - } - } -} diff --git a/src/doc_reform/meta/metadoc_show_metadata.d b/src/doc_reform/meta/metadoc_show_metadata.d deleted file mode 100644 index b8296cc..0000000 --- a/src/doc_reform/meta/metadoc_show_metadata.d +++ /dev/null @@ -1,171 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta.metadoc_show_metadata; -@safe: -template spineShowMetaData() { - void spineShowMetaData(T)( - T doc_matters, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - auto min_repeat_number = 66; - auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length - + doc_matters.conf_make_meta.meta.creator_author.length + 4); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - if (doc_matters.opt.action.show_metadata - && doc_matters.opt.action.debug_do - ) { - writeln(doc_matters.conf_make_meta.meta); - } - if (doc_matters.opt.action.show_metadata) { - writefln( - "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", - markup.repeat_character_by_number_provided("-", char_repeat_number), - doc_matters.conf_make_meta.meta.title_full, - doc_matters.conf_make_meta.meta.creator_author, - doc_matters.src.filename, - markup.repeat_character_by_number_provided("-", char_repeat_number), - "- author:", - doc_matters.conf_make_meta.meta.creator_author, - "- author array:", - doc_matters.conf_make_meta.meta.creator_author_arr, - "- author surname:", - doc_matters.conf_make_meta.meta.creator_author_surname, - "- author email:", - doc_matters.conf_make_meta.meta.creator_author_email, - "- illustrator:", - doc_matters.conf_make_meta.meta.creator_illustrator, - "- translator:", - doc_matters.conf_make_meta.meta.creator_translator, - "- title full:", - doc_matters.conf_make_meta.meta.title_full, - "- title main:", - doc_matters.conf_make_meta.meta.title_main, - "- title sub:", - doc_matters.conf_make_meta.meta.title_subtitle, - "- title edition:", - doc_matters.conf_make_meta.meta.title_edition, - "- title language:", - doc_matters.conf_make_meta.meta.title_language, - "- title note:", - doc_matters.conf_make_meta.meta.title_note, - "- classify dewey:", - doc_matters.conf_make_meta.meta.classify_dewey, - "- classify library of congress:", - doc_matters.conf_make_meta.meta.classify_loc, - "- classify keywords:", - doc_matters.conf_make_meta.meta.classify_keywords, - "- classify topic register:", - doc_matters.conf_make_meta.meta.classify_topic_register, - "- date added to site:", - doc_matters.conf_make_meta.meta.date_added_to_site, - "- date available:", - doc_matters.conf_make_meta.meta.date_available, - "- date created:", - doc_matters.conf_make_meta.meta.date_created, - "- date issued:", - doc_matters.conf_make_meta.meta.date_issued, - "- date modified:", - doc_matters.conf_make_meta.meta.date_modified, - "- date published:", - doc_matters.conf_make_meta.meta.date_published, - "- date valid:", - doc_matters.conf_make_meta.meta.date_valid, - // links - "- notes abstract:", - doc_matters.conf_make_meta.meta.notes_abstract, - "- notes description:", - doc_matters.conf_make_meta.meta.notes_description, - "- original language:", - doc_matters.conf_make_meta.meta.original_language, - "- original language character:", - doc_matters.conf_make_meta.meta.original_language_char, - "- original source:", - doc_matters.conf_make_meta.meta.original_source, - "- original title:", - doc_matters.conf_make_meta.meta.original_title, - // publisher - "- rights copyright:", - doc_matters.conf_make_meta.meta.rights_copyright, - "- rights copyright text:", - doc_matters.conf_make_meta.meta.rights_copyright_text, - "- rights copyright audio:", - doc_matters.conf_make_meta.meta.rights_copyright_audio, - "- rights copyright cover:", - doc_matters.conf_make_meta.meta.rights_copyright_cover, - "- rights copyright illustrations:", - doc_matters.conf_make_meta.meta.rights_copyright_illustrations, - "- rights copyright photographs:", - doc_matters.conf_make_meta.meta.rights_copyright_photographs, - "- rights copyright translation:", - doc_matters.conf_make_meta.meta.rights_copyright_translation, - "- rights copyright video:", - doc_matters.conf_make_meta.meta.rights_copyright_video, - "- rights license:", - doc_matters.conf_make_meta.meta.rights_license, - ); - } - } -} diff --git a/src/doc_reform/meta/metadoc_show_summary.d b/src/doc_reform/meta/metadoc_show_summary.d deleted file mode 100644 index 770aa8d..0000000 --- a/src/doc_reform/meta/metadoc_show_summary.d +++ /dev/null @@ -1,162 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta.metadoc_show_summary; -@safe: -template spineMetaDocSummary() { - void spineMetaDocSummary(S,T)( - const S doc_abstraction, - T doc_matters, - ) { - import - doc_reform.meta.defaults, - doc_reform.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - auto min_repeat_number = 66; - auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length - + doc_matters.conf_make_meta.meta.creator_author.length + 4); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - if (doc_matters.opt.action.vox_gt1 - || doc_matters.opt.action.show_summary) { - string[string] check = [ - "last_object_number" : "NA [debug \"checkdoc\" not run]", - "last_object_number_body" : "0", - "last_object_number_book_index" : "0", - ]; - foreach (k; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[k]) { - if (obj.metainfo.is_of_part != "empty") { - if (!empty(obj.metainfo.object_number)) { - if (k == "body") { - check["last_object_number_body"] = obj.metainfo.object_number; - } - if (!(obj.metainfo.object_number.empty)) { - check["last_object_number"] = obj.metainfo.object_number; - } - } - if (k == "bookindex") { - if (obj.metainfo.object_number_type == 2) { - check["last_object_number_book_index"] = obj.metainfo.object_number_book_index; - } - } - } - } - } - writefln( - "%s\n\"%s\", %s\n%s [%s]\n%s\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%s", - markup.repeat_character_by_number_provided("-", char_repeat_number), - doc_matters.conf_make_meta.meta.title_full, - doc_matters.conf_make_meta.meta.creator_author, - doc_matters.src.filename, - 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), - " doc body last obj on.#:", - to!int(check["last_object_number_body"]), - " - number of tables:", - doc_matters.has.tables, - " - number of codeblocks:", - doc_matters.has.codeblocks, - " - number of poems:", - doc_matters.has.poems, - " - number of blocks:", - doc_matters.has.blocks, - " - number of groups:", - doc_matters.has.groups, - " - number of images:", - doc_matters.has.images, - "- endnotes length:", // subtract headings - (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)) - : 0, - "- biblio 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)) - : 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)) - : 0, - "* last obj on.#:", - to!int(check["last_object_number"]), - "number of segments:", - (doc_matters.has.segnames_lv4.length > 1) - ? (to!int(doc_matters.has.segnames_lv4.length)) - : 0, - markup.repeat_character_by_number_provided("-", min_repeat_number), - ); - } - } -} diff --git a/src/doc_reform/meta/package.d b/src/doc_reform/meta/package.d deleted file mode 100644 index 2baf3e9..0000000 --- a/src/doc_reform/meta/package.d +++ /dev/null @@ -1,64 +0,0 @@ -/+ -- Name: 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 - 2024 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 doc_reform.meta; -public import - doc_reform.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; diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d deleted file mode 100644 index de09d19..0000000 --- a/src/doc_reform/meta/rgx.d +++ /dev/null @@ -1,270 +0,0 @@ -/+ -- Name: 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 - 2024 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/] - -+/ -/++ - regex: regular expressions used in sisu document parser -+/ -module doc_reform.meta.rgx; -@safe: -static template spineRgxIn() { - static struct RgxI { - /+ misc +/ - static flag_action = ctRegex!(`^(--[a-z][a-z0-9-]+)$`); - static within_quotes = ctRegex!(`"(.+?)"`, "m"); - static make_heading_delimiter = ctRegex!(`[;][ ]*`); - static arr_delimiter = ctRegex!(`[ ]*[;][ ]*`); - static name_delimiter = ctRegex!(`^([^,]+)[ ]*,[ ]+(.+?)$`); - static book_index_go = ctRegex!("(?P(?P[0-9]+)(?:-[0-9]+)?)"); - static trailing_comma = ctRegex!(",[ ]*$"); - static trailing_linebreak = ctRegex!(",[ ]{1,2}\\\\\\\\\n[ ]{4}$","m"); - static newline_eol_strip_preceding = ctRegex!("[ ]*\n"); - static newline_eol_delimiter_only = ctRegex!("^\n"); - static markup_inline_linebreak = ctRegex!(`\s*\\\\s*`, "m"); - static para_delimiter = ctRegex!("\n[ ]*\n+"); - static table_col_delimiter = ctRegex!("[ ]*\n+", "mg"); - static table_row_delimiter = ctRegex!("\n[ ]*\n+", "mg"); - static table_row_delimiter_special = ctRegex!("[ ]*\n", "mg"); - static table_col_delimiter_special = ctRegex!("[ ]*[|][ ]*", "mg"); - static levels_numbered = ctRegex!(`^[0-9]$`); - static levels_numbered_headings = ctRegex!(`^[0-7]$`); - static numeric_col = ctRegex!(`^[ 0-9,.%$£₤Є€€¥()-]+$`); - /+ comments +/ - static comment = ctRegex!(`^%+ `); - /+ header +/ - /+ header +/ - static variable_doc_title_author_date = ctRegex!(`@title-author-date`); - static variable_doc_title_author = ctRegex!(`@title-author`); - static variable_doc_title = ctRegex!(`@title`); - static variable_doc_author = ctRegex!(`@author|@creator`); - static variable_doc_date = ctRegex!(`@date`); - static raw_author_munge = ctRegex!(`(?P\S.+?),\s+(?P.+)`,"i"); - static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); - /+ heading operators +/ - static heading_a = ctRegex!(`^:?[A][~] `, "m"); - static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); - static headings = ctRegex!(`^:?(?P[A-D1-4])[~](?:[a-z0-9_.-]*[?]?|[!](?:glossary|bibliogrphy|biblio|references?|blurb))(?:\s|$)`,"i"); - static heading_seg_and_above = ctRegex!(`^:?([A-D1])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); - static heading_anchor_tag = ctRegex!(`^:?[A-D1-4][~](?P[a-z0-9_.-]+) `,"i"); - static heading_identify_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(?:(?:(?:chapter|article|section|clause)\s+[0-9.]+)|(?:[0-9]+))`,"i"); - static heading_extract_named_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(chapter|article|section|clause)\s+((?:[0-9]+[.:])*[0-9]+)(?=[.:;, ]|$)`,"i"); - static heading_extract_unnamed_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+((?:[0-9]+.)*[0-9]+)(?=[.:;, ]|$)`); - static heading_marker_missing_tag = ctRegex!(`^:?([A-D1-4])[~] `); - static heading_anchor_tag_plus_colon = ctRegex!(`^:?([A-D1-4][~])([a-z0-9_.:-]+) `,"i"); - static heading_marker_tag_has_colon = ctRegex!(`([:])`); - static heading_biblio = ctRegex!(`^1[~][!](biblio(?:graphy)?|references?)`); - static heading_glossary = ctRegex!(`^1[~][!](glossary)`); - static heading_blurb = ctRegex!(`^1[~][!](blurb)`); - /+ paragraph operators +/ - static para_bullet = ctRegex!(`^_[*] `); - static para_bullet_indent = ctRegex!(`^_(?P[1-9])[*] `); - static para_indent = ctRegex!(`^_(?P[1-9])[ ]`); - static para_indent_hang = ctRegex!(`^_(?P[0-9])_(?P[0-9])[ ]`); - static para_attribs = ctRegex!(`^_(?:(?:[0-9])(?:_([0-9]))?|(?:[1-9])?[*]) `); - static para_inline_link_anchor = ctRegex!(`\*[~](?P[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(?:[ ,]+[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[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_poem_open = ctRegex!("^`{3} poem(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_group_open = ctRegex!("^`{3} group(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_block_open = ctRegex!("^`{3} block(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_quote_open = ctRegex!("^`{3} quote(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_table_open = ctRegex!("^`{3} table(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); // ctRegex!("^`{3} table(?:\(.*?\))?"); - static block_tic_close = ctRegex!("^(`{3})$","m"); - /+ blocked markup curly +/ - static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_code_close = ctRegex!(`^([}]code)`); - static block_curly_poem_open = ctRegex!(`^(poem(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_poem_close = ctRegex!(`^([}]poem)`); - static block_curly_group_open = ctRegex!(`^(group(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_group_close = ctRegex!(`^([}]group)`); - static block_curly_block_open = ctRegex!(`^(block(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_block_close = ctRegex!(`^([}]block)`); - static block_curly_quote_open = ctRegex!(`^(quote(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_quote_close = ctRegex!(`^([}]quote)`); - static block_curly_table_open = ctRegex!(`^table(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$`); - static block_curly_table_close = ctRegex!(`^([}]table)`); - static block_curly_table_special_markup = ctRegex!(`^[{]table[(](?P(?:(h);)?(?P(?:[, ]+[0-9]+)+))[)][}]`, "mg"); - static code_numbering = ctRegex!(`(?P\blinenumber\b|\bnumber\b|\blnr\b)`); - static table_head_instructions = ctRegex!(`(?:(?Ph);)?(?:[ ]+c(?P[0-9]):)?(?P(?:[, ]+[0-9]+[lr]?)+)`); - static table_col_widths_and_alignment = ctRegex!(`(?P[0-9]+)(?P[lr]?)`); - static table_col_widths = ctRegex!(`(?P[0-9]+)`); - static table_col_align_match = ctRegex!(`(?P[lr])`); - 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 note_ref = ctRegex!(`^\S+?noteref_(?P[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
^|[ (\[])(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?=[.,;:?!'"]?([ )\]]|$))`, "mg");
-    static smid_inline_link_markup_regular                = ctRegex!(`(?P
^|[ (\[])\{\s*(?P.+?)\s*\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg");
-    static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg");
-    static smid_inline_link_endnote_url_helper            = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg");
-    static image                                    = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg");
-    static smid_image                               = ctRegex!(`(?P
(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg");
-    static smid_image_generic                       = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg");
-    static smid_image_with_dimensions               = ctRegex!(`(?P
(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))\s+(?P\d+)x(?P\d+)\s*(?P(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg");
-    static smid_mod_image_without_dimensions        = ctRegex!(`[{┥](?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0.*[}┝](?:image|┤.*?├|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg");
-    static smid_image_delimit                       = ctRegex!(`(?P
^|[ ])\{\s*(?P.+?)\s*\}(?:image)(?=[;:!,?.]?([ )\]]|$))`, "mg");
-    /+ inline markup book index +/
-    static book_index_item                          = ctRegex!(`^=\{\s*(?P.+?)\}$`, "m");
-    static book_index_item_open                     = ctRegex!(`^=\{\s*([^}]*?)$`);
-    static book_index_item_close                    = ctRegex!(`^(.*?)\}$`, "m");
-    static auto_heading_numbering_lv1               = ctRegex!(`^1~`, "m");
-    static auto_heading_numbering_off_lv1           = ctRegex!(`^1~\S*?-\s`, "m");
-    static auto_heading_numbering_off_lv2           = ctRegex!(`^2~\S*?-\s`, "m");
-    static auto_heading_numbering_off_lv3           = ctRegex!(`^3~\S*?-\s`, "m");
-    static auto_heading_numbering_off_lv4           = ctRegex!(`^4~\S*?-\s`, "m");
-    /+ no object_number object +/
-    static object_number_off                        = ctRegex!(`~#[ ]*$`, "m");
-    static object_number_off_dummy_heading          = ctRegex!(`-#$`, "m");
-    static object_number_off_all                    = ctRegex!(`[~-]#$`, "m");
-    static repeated_character_line_separator        = ctRegex!(`^(?:[ ]*(?:(?:[.][ ]*){4,}|(?:[-][ ]*|[~][ ]*|[*][ ]*|[$][ ]*|[#][ ]*|[\\][ ]*|[/][ ]*){2,})\s*?)+$`);
-    /+ no object_number block +/
-    static object_number_off_block                  = ctRegex!(`^--~#$`);
-    static object_number_off_block_dummy_heading    = ctRegex!(`^---#$`);
-    static object_number_off_block_close            = ctRegex!(`^--\+#$`);
-    static object_number_block_marks                = ctRegex!(`^--[+~-]#$`);
-    /+ ignore outside code blocks +/
-    static skip_from_regular_parse                  = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`);
-    /+ line & page breaks +/
-    static break_string                             = ctRegex!(`』`);
-    /+ biblio tags +/
-    static biblio_tags                              = ctRegex!(`^(is|au|author_raw|author|author_arr|editor_raw|ed|editor_arr|ti|title|subtitle|fulltitle|lng|language|trans|src|jo|journal|in|vol|volume|edn|edition|yr|year|pl|place|pb|pub|publisher|url|pg|pages|note|short_name|id):\s+(.+)`);
-    static biblio_abbreviations                     = ctRegex!(`^(au|ed|ti|lng|jo|vol|edn|yr|pl|pb|pub|pg|pgs|sn)$`);
-    /+ bookindex split +/
-    static bi_main_terms_split                            = ctRegex!(`\s*;\s*`);
-    static bi_main_term_plus_rest_split                   = ctRegex!(`\s*:\s*`);
-    static bi_sub_terms_plus_object_number_offset_split   = ctRegex!(`\s*\|\s*`);
-    static bi_term_and_object_numbers_match               = ctRegex!(`^(.+?)\+(\d+)`);
-    static topic_register_main_terms_split          = ctRegex!(`\s*;\s*`);
-    static topic_register_main_term_plus_rest_split = ctRegex!(`\s*:\s*`);
-    static topic_register_sub_terms_split           = ctRegex!(`\s*\|\s*`);
-    static topic_register_multiple_sub_terms_split  = ctRegex!(`␣([^|␣]+(?:\|[^|␣]+)+)`);
-    static newline                                  = ctRegex!("\n", "mg");
-    static space                                    = ctRegex!(`[ ]`, "mg");
-    static spaces_keep                              = ctRegex!(`(?P^[ ]+|[ ]{2,})`, "mg"); // code, verse, block
-    static spaces_line_start                        = ctRegex!(`^(?P[ ]+)`, "mg");
-    static nbsp_char                                = ctRegex!(`░`, "mg");
-    static nbsp_chars                               = ctRegex!(`[░]+`, "mg");
-    static middle_dot                               = ctRegex!(`·`, "mg");
-    static src_pth_sst_or_ssm                       = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.](?Pss[tm]))$`);
-    static src_pth_pod_sst_or_ssm                   = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`);
-    static src_pth_contents                         = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`);
-    static src_pth_zip                              = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]zip)$`);
-    static src_pth_types                            = ctRegex!(`^(?P[/]?[a-zA-Z0-9._-]+/)*(?P(?P[a-zA-Z0-9._-]+[.]ss[tm])|(?P[a-zA-Z0-9._-]+/pod[.]manifest)|(?P[a-zA-Z0-9._-]+[.]zip))$`);
-    static src_fn                                   = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P(?P[a-zA-Z0-9._-]+)[.](?Pss[tm]))$`);
-    static src_fn_master                            = ctRegex!(`^(?P/?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ssm)$`);
-    static src_fn_find_inserts                      = ctRegex!(`^(?P/?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[im])$`);
-    static insert_src_fn_ssi_or_sst                 = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`);
-    static src_base_parent_dir_name                 = ctRegex!(`[/](?P(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure
-    static src_formalised_file_path_parts           = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure
-    /+ line breaks +/
-    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");
-    /+ 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
-    static inline_notes_al_gen                      = ctRegex!(`【.+?】`, "m");
-    static inline_notes_al_gen_text                 = ctRegex!(`【(?P.+?)】`, "m");
-    static inline_notes_al_all_note                 = ctRegex!(`【(?P\d+|(?:[*]|[+])+)\s+(?P.+?)\s*】`, "mg");
-    static inline_notes_al_regular_number_note      = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*】`, "mg");
-    static inline_notes_al_special_char_note        = ctRegex!(`【(?P(?:[*]|[+])+)\s+(?P.+?)】`, "mg");
-    static inline_al_delimiter_open_regular         = ctRegex!(`【\s`, "m");
-    static inline_al_delimiter_open_symbol_star     = ctRegex!(`【[*]\s`, "m");
-    static inline_al_delimiter_open_symbol_plus     = ctRegex!(`【[+]\s`, "m");
-    static inline_text_and_note_al_                 = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|.+))`, "mg");
-    /+ inline markup links +/
-    static inline_image                             = ctRegex!(`(?P
┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+))\s*(?P.*?┝┤.*?├)`, "mg");
-    static inline_image_without_dimensions          = ctRegex!(`(?P
┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P0)h(?P0))\s*(?P.*?┝┤.*?├)`, "mg");
-    static inline_image_info                        = ctRegex!(`☼?(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+)`, "mg");
-    static inline_link_anchor                       = ctRegex!(`┃(?P\S+?)┃`, "mg"); // TODO *~text_link_anchor
-    static inline_link                              = ctRegex!(`┥(?P.+?)┝┤(?P#?(\S+?))├`, "mg");
-    static inline_link_empty                        = ctRegex!(`┥(?P.+?)┝┤├`, "mg");
-    static inline_link_number                       = ctRegex!(`┥(?P.+?)┝┤(?P[0-9]+)├`, "mg"); // not used
-    static inline_link_number_only                  = ctRegex!(`(?P┥.+?┝)┤(?P[0-9]+)├`, "mg");
-    static inline_link_stow_uri                     = ctRegex!(`┥(?P.+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links
-    static inline_link_hash                         = ctRegex!(`┥(?P.+?)┝┤(?P#(?P\S+?))├`, "mg");
-    static inline_link_seg_and_hash                 = ctRegex!(`┥(?P.+?)┝┤(?P(?P[^/#├]*)#(?P.+?))├`, "mg");
-    static inline_link_clean                        = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
-    static inline_link_toc_to_backmatter            = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg");
-    static url                                      = ctRegex!(`https?://`, "mg");
-    static uri                                      = ctRegex!(`(?:https?|git)://`, "mg");
-    static uri_identify_components                  = ctRegex!(`(?P(?:https?|git)://)(?P\S+?/)(?P[^/]+)$`, "mg");
-    static inline_link_subtoc                       = ctRegex!(`^(?P[5-7])~ ┥(?P.+?)┝┤(?P.+?)├`, "mg");
-    static inline_link_fn_suffix                    = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg");
-    static inline_seg_link                          = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg");
-    static mark_internal_site_lnk                   = ctRegex!(`¤`, "mg");
-    static quotation_mark_sql_insert_delimiter      = ctRegex!("[']", "mg");
-    /+ inline markup font face mod +/
-    static inline_mark_emphasis                     = ctRegex!(`(?P[*])\{(?P.+?)\}[*]`, "mg");
-    static inline_mark_bold                         = ctRegex!(`(?P[!])\{(?P.+?)\}[!]`, "mg");
-    static inline_mark_underscore                   = ctRegex!(`(?P[_])\{(?P.+?)\}[_]`, "mg");
-    static inline_mark_italics                      = ctRegex!(`(?P[/])\{(?P.+?)\}[/]`, "mg");
-    static inline_mark_superscript                  = ctRegex!(`(?P\^)\{(?P.+?)\}\^`, "mg");
-    static inline_mark_subscript                    = ctRegex!(`(?P[,])\{(?P.+?)\}[,]`, "mg");
-    static inline_mark_strike                       = ctRegex!(`(?P[-])\{(?P.+?)\}[-]`, "mg");
-    static inline_mark_insert                       = ctRegex!(`(?P[+])\{(?P.+?)\}[+]`, "mg");
-    static inline_mark_mono                         = ctRegex!(`(?P[#])\{(?P.+?)\}[#]`, "mg");
-    static inline_mark_cite                         = ctRegex!(`(?P["])\{(?P.+?)\}["]`, "mg");
-    static inline_faces_line                        = ctRegex!(`^[*!/_]_ (?P.+?)((?: [\\]{2}|[~]#){0,2}$)`);
-    static inline_emphasis_line                     = ctRegex!(`^\*_ (?P.+?)(?P(?: [\\]{2}|[~]#){0,2}$)`);
-    static inline_bold_line                         = ctRegex!(`^!_ (?P.+?)(?P(?: [\\]{2}|[~]#){0,2}$)`);
-    static inline_italics_line                      = ctRegex!(`^/_ (?P.+?)(?P(?: [\\]{2}|[~]#){0,2}$)`);
-    static inline_underscore_line                   = ctRegex!(`^__ (?P.+?)(?P(?: [\\]{2}|[~]#){0,2}$)`);
-  }
-}
diff --git a/src/doc_reform/meta/rgx_files.d b/src/doc_reform/meta/rgx_files.d
deleted file mode 100644
index 0ffdf3b..0000000
--- a/src/doc_reform/meta/rgx_files.d
+++ /dev/null
@@ -1,72 +0,0 @@
-/+
-- Name: 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 - 2024 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/]
-
-+/
-/++
-  regex: regular expressions used in sisu document parser
-+/
-module doc_reform.meta.rgx_files;
-@safe:
-static template spineRgxFiles() {
-  static struct RgxFiles {
-    static src_pth_sst_or_ssm                       = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.](?Pss[tm]))$`);
-    static src_pth_pod_sst_or_ssm                   = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`);
-    static src_pth_contents                         = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`);
-    static src_pth_zip                              = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]zip)$`);
-    static src_pth_types                            = ctRegex!(`^(?P[/]?[a-zA-Z0-9._-]+/)*(?P(?P[a-zA-Z0-9._-]+[.]ss[tm])|(?P[a-zA-Z0-9._-]+/pod[.]manifest)|(?P[a-zA-Z0-9._-]+[.]zip))$`);
-    static src_fn                                   = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P(?P[a-zA-Z0-9._-]+)[.](?Pss[tm]))$`);
-    static src_fn_master                            = ctRegex!(`^(?P/?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ssm)$`);
-    static src_fn_find_inserts                      = ctRegex!(`^(?P/?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[im])$`);
-    static insert_src_fn_ssi_or_sst                 = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`);
-    static src_base_parent_dir_name                 = ctRegex!(`[/](?P(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure
-    static src_formalised_file_path_parts           = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure
-    /+ language codes +/
-    auto language_code_and_filename                                    =
-       ctRegex!("(?:^|[/])(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$");
-  }
-}
diff --git a/src/doc_reform/meta/rgx_yaml_tags.d b/src/doc_reform/meta/rgx_yaml_tags.d
deleted file mode 100644
index 953ea05..0000000
--- a/src/doc_reform/meta/rgx_yaml_tags.d
+++ /dev/null
@@ -1,62 +0,0 @@
-/+
-- Name: 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 - 2024 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/]
-
-+/
-/++
-  regex: regular expressions used in sisu document parser
-+/
-module doc_reform.meta.rgx_yaml;
-@safe:
-static template spineRgxYamlTags() {
-  static struct RgxYaml {
-    static yaml_tag_is_str                          = ctRegex!(`:str$`);
-    static yaml_tag_is_int                          = ctRegex!(`:int$`);
-    static yaml_tag_is_map                          = ctRegex!(`:map$`);
-    static yaml_tag_is_seq                          = ctRegex!(`:seq$`);
-  }
-}
-- 
cgit v1.2.3