From db3dd3c3a5f4c5cde9a736cb688f05af9f79d718 Mon Sep 17 00:00:00 2001
From: Ralph Amissah A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
-┃",
- _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"┃ A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
- "%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 - %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 - %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 - %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"┃
- Title: " ~ doc_matters.conf_make_meta.meta.title_full ~ " Author: "
- ~ doc_matters.conf_make_meta.meta.creator_author ~ " Author: "
- ~ doc_matters.conf_make_meta.meta.creator_author ~ " Published: " ~ doc_matters.conf_make_meta.meta.date_published ~ " Copyright: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright) ~ " License: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_license) ~ " Summary: " ~ special_characters_text(doc_matters.conf_make_meta.meta.notes_summary) ~ " ● outputs: [ html: "
- ~ " ▤ scroll "
- ~ "|"
- ~ " ※ seg ] "
- ~ "["
- ~ " ◆ epub ] ";
- if ((doc_matters.opt.action.html_link_pdf) || (doc_matters.opt.action.html_link_pdf_a4)) {
- metadata_ ~= "[ pdf: "
- ~ " □ a4  "
- ~ "|"
- ~ " □ U.S. letter ] ";
- } else if (doc_matters.opt.action.html_link_pdf_a4) {
- metadata_ ~= "["
- ~ " □ pdf (a4) ] ";
- } else if (doc_matters.opt.action.html_link_pdf_letter) {
- metadata_ ~= "["
- ~ " □ pdf (U.S. letter) ] ";
- }
- if (doc_matters.opt.action.html_link_text) {
- metadata_ ~= " ["
- ~ " □ txt ] ";
- }
- metadata_ ~= " source: " ~ doc_matters.src.filename_base ~ " ● markup source: the pod ["
- ~ " 🫛 zipped | "
- ~ ""
- ~ " 🫛 tree ] ";
- metadata_ ~= " ● source digests:"
- ~ " [ "
- ~ " # digests ] ";
- auto data = (cast(byte[]) (fn_pod).read); // prevents code from being safe
- metadata_ ~= "" ~ data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename_base ~ ".zip";
- metadata_ ~= " Topics: " ~ subject_tree[0] ~ " " ~ subject_tree[1] ~ " " ~ subject_tree[2] ~ " " ~ subject_tree[3] ~ " " ~ subject_tree[4] ~ "
- - read config files
- meta_config_files.d
-+/
-module sisudoc.io_in.paths_source;
-@safe:
-import std.array;
-import std.file;
-import std.path;
-import std.regex;
-import std.stdio;
-import std.conv : to;
-import sisudoc.meta.defaults;
-import sisudoc.meta.rgx_files;
-template PodManifest() {
- mixin spineRgxFiles;
- static auto rgx_files = RgxFiles();
- auto PodManifest(O)(
- O _opt_action,
- string _pth=""
- ) {
- struct ManifestFile_ {
- string pod_manifest_filename() {
- return "pod.manifest";
- }
- string pod_manifest_path() {
- string _manifest_path;
- if ((isValidPath(_pth) && exists(_pth) != 0 && _pth.isDir)
- && (exists(_pth.chainPath(pod_manifest_filename).array) != 0
- && (_pth.chainPath(pod_manifest_filename).array).isFile)) {
- _manifest_path = _pth;
- } else if (_pth.match(rgx_files.src_pth_contents)
- && exists(_pth) != 0 && _pth.isFile) {
- _manifest_path = _pth.dirName;
- } else if (_pth.match(rgx_files.src_pth_pod_sst_or_ssm)
- && exists(_pth) != 0 && (_pth.isFile)) {
- if (auto m = _pth.match(rgx_files.src_pth_pod_sst_or_ssm)) {
- _manifest_path = m.captures["podpath"];
- }
- } else {
- if (_opt_action.vox_gt_3 || _opt_action.debug_do) {
- if (exists(_pth) == 0 && (_pth.isFile)) {
- writeln("WARNING, src file is not .sst or .ssm (nor is it a pod directory): ", _pth); // remove? unless can distinguish pod
- }
- }
- _manifest_path = "";
- }
- return _manifest_path;
- }
- string pods_collection_root_path() {
- return (pod_manifest_path.length > 0) ? ((chainPath(pod_manifest_path, "..")).asNormalizedPath).array.to!string : "";
- }
- string pod_manifest_file_with_path() {
- string _k;
- if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) {
- _k = pod_manifest_path.chainPath(pod_manifest_filename).array;
- } else if (exists(pod_manifest_path)!=0) {
- _k = pod_manifest_path;
- }
- if (exists(_k)==0) {
- // writeln("ERROR >> Processing Skipped! Manifest not found: ", _k);
- _k = null;
- }
- return _k;
- }
- }
- return ManifestFile_();
- }
-}
-template PathMatters() {
- mixin InternalMarkup;
- mixin spineRgxFiles;
- static auto rgx_files = RgxFiles();
- static auto mkup = InlineMarkup();
- auto PathMatters(O,E)(
- O _opt_action,
- E _env,
- string _pth,
- string _fns = "",
- char[][] _manifest_fn_list = [[]],
- ) {
- auto _manifested = PodManifest!()(_opt_action, _pth);
- struct ManifestMatters_ {
- auto env() {
- auto _env = _env;
- struct Env_ {
- auto pwd() {
- return _env["pwd"];
- }
- auto home() {
- return _env["home"];
- }
- }
- return Env_();
- }
- auto opt() {
- struct Opt_ {
- auto action() {
- return _opt_action;
- }
- }
- return Opt_();
- }
- bool src_is_pod() {
- return (_manifested.pod_manifest_path.length > 0) ? true : false;
- }
- auto pod() {
- struct Pod_ {
- bool src_is_pod() {
- return (_manifested.pod_manifest_path.length > 0) ? true : false;
- }
- string collection_root() {
- return _manifested.pods_collection_root_path;
- }
- string manifest_filename() {
- return _manifested.pod_manifest_filename;
- }
- string manifest_path() {
- return _manifested.pod_manifest_path;
- }
- string pod_name_with_path() {
- return _manifested.pod_manifest_path.baseName;
- }
- string manifest_file_with_path() {
- return _manifested.pod_manifest_file_with_path;
- }
- string[] config_dr_document_make_dirs() {
- string[] _config_dirs;
- return _config_dirs;
- }
- string[] config_local_site_dirs() {
- string[] _config_dirs;
- return _config_dirs;
- }
- string[] image_dirs() {
- string[] _image_dirs;
- return _image_dirs;
- }
- auto manifest_list_of_filenames() {
- return _manifest_fn_list;
- }
- string[] manifest_list_of_languages() {
- string[] _lngs;
- foreach (filename_; manifest_list_of_filenames) {
- string _k = "en";
- if (auto m = (filename_).match(rgx_files.language_code_and_filename)) {
- _k = m.captures[1].to!string;
- }
- _lngs ~= _k; // all the languages from the manifest list of filenames with paths
- }
- return _lngs;
- }
- }
- return Pod_();
- }
- auto src() {
- string _fns = _fns; // required here by dmd & not by ldc (for D:2078)
- auto _opt_action = _opt_action;
- auto _env = _env;
- struct SRC_ {
- bool is_pod() {
- return (_manifested.pod_manifest_path.length > 0) ? true : false;
- }
- string path_and_fn() {
- return _fns;
- }
- string pod_name_with_path() {
- return (is_pod) ? _manifested.pod_manifest_path : "";
- }
- string pods_collection_root_path() {
- return (is_pod) ? _manifested.pods_collection_root_path : "";
- }
- string pod_name() {
- return pod_name_with_path.baseName;
- }
- string filename() {
- return path_and_fn.baseName;
- }
- string filename_base() {
- return filename.stripExtension;
- }
- string filename_extension() {
- return filename.match(rgx_files.src_pth_sst_or_ssm).captures["extension"];
- }
- string lng() {
- string _k;
- if (auto m = path_and_fn.match(rgx_files.language_code_and_filename)) {
- _k = m.captures[1];
- } else {_k = "en"; }
- return _k;
- }
- string doc_uid() {
- string _uid;
- if (is_pod && !(pod_name_with_path.empty)) {
- if (pod_name_with_path.baseName == filename_base) {
- _uid = filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
- } else {
- _uid = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
- }
- } else {
- _uid = mkup.uid_sep ~ filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
- }
- return _uid;
- }
- string doc_uid_out() {
- string _uid;
- if (is_pod && !(pod_name_with_path.empty)) {
- if (pod_name_with_path.baseName == filename_base) {
- _uid = filename_base ~ "." ~ lng;
- } else {
- _uid = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ "." ~ lng;
- }
- } else {
- _uid = "_" ~ filename_base ~ "." ~ lng;
- }
- return _uid;
- }
- string docname_composite_unique_per_src_doc() {
- string _fn;
- if (pod_name_with_path.baseName == filename_base) {
- _fn = filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
- } else if (!(pod_name_with_path.empty)) {
- _fn = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
- } else {
- _fn = "_" ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
- }
- return _fn;
- }
- string docname_composite_unique_per_src_pod() {
- /+
- z pod name if any + src filename (without lng code)
- filename ~ mkup.uid_sep ~ lng
- * unique per src pod
- used by
- - pod (multilingual collection)
- - sqlite discrete index (multilingual collection)
- +/
- string _fn;
- if (pod_name_with_path.baseName == filename_base) {
- _fn = filename_base ~ mkup.uid_sep ~ filename_extension;
- } else if (!(pod_name_with_path.empty)) {
- _fn = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension;
- } else {
- _fn = "_" ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension;
- }
- return _fn;
- }
- string language() {
- return lng();
- }
- string file_with_absolute_path() {
- return _env["pwd"].chainPath(path_and_fn).array;
- }
- string absolute_path_to_src() {
- return (_env["pwd"].chainPath(path_and_fn)).dirName.array;
- }
- string path_to_doc_root_path_to_lang_and_filename() {
- return _env["pwd"].chainPath(path_and_fn).array;
- }
- string base_dir() {
- string _dir;
- if (
- auto m = (absolute_path_to_src)
- .match(regex(r"[/](?P
- - read config files
- meta_config_files.d
-+/
-module sisudoc.io_in.read_config_files;
-@safe:
-import std.file;
-import std.path;
-import sisudoc.meta;
-import sisudoc.io_in.paths_source;
-import sisudoc.meta.rgx_files;
-import sisudoc.meta.rgx;
-template readConfigSite() {
- @system final auto readConfigSite(Cf,O,Cfg)(Cf _conf_file_details, O _opt_action, Cfg _cfg) {
- mixin spineRgxIn;
- static auto rgx = RgxI();
- string conf_filename = "NONE";
- string config_file_str;
- string default_config_file_str = format(q"┃
-flag:
- act0: "--html"
- act1: "--html --epub"
-output:
- path: "%s"
-default:
- language: "en"
- papersize: "a4"
- text_wrap: "80"
- digest: "sha256"
-webserv:
- http: "%s"
- host: "%s"
- data_http: "%s"
- data_host: "%s"
- data_root_url: "%s"
- data_root_path: "%s"
- data_root_part: ""
- images_root_part: "image"
- cgi_search_form_title: "%s"
- cgi_http: "%s"
- cgi_host: "%s"
- cgi_bin_url: "%s"
- cgi_bin_subpath: "%s"
- cgi_bin_path: "%s"
- cgi_search_script: "%s"
- cgi_port: ""
- cgi_user: ""
- cgi_action: "%s"
- db_sqlite_path: "%s"
- db_sqlite_filename: "%s"
- db_pg_table: ""
- db_pg_user: ""
-┃",
- _cfg.processing_path_doc_root, // doc root
- _cfg.http_request_type, // http
- _cfg.http_host, // host / domain
- _cfg.http_request_type, // data "http" or "https"
- _cfg.http_host, // data domain "localhost"
- _cfg.www_url_doc_root, // data root url "http://locahost" "https://sisudoc.org"
- _cfg.processing_path_doc_root, // data root path
- _cfg.cgi_search_form_title, // cgi title // e.g. "≅ SiSU Spine search"
- _cfg.http_request_type, // cgi http
- _cfg.http_host, // cgi host
- _cfg.cgi_url_root, // cgi bin url
- _cfg.cgi_bin_subpath, // cgi bin path
- _cfg.cgi_bin_root, // cgi bin path
- _cfg.cgi_filename, // cgi filename
- _cfg.cgi_url_action, // cgi action
- _cfg.db_sqlite_path, // sqlite db path
- _cfg.db_sqlite_filename, // sqlite db filename
-);
- foreach(conf_fn; [_conf_file_details.config_filename_site]) {
- foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) {
- char[] conf_file;
- conf_filename = conf_fn;
- if (exists(pth)) {
- auto f_attrib = pth.getLinkAttributes;
- if (
- _conf_file_details.possible_config_path_locations.config_local_site.length == 1
- && f_attrib.attrIsFile
- ) {
- conf_file = pth.to!(char[]);
- conf_filename = pth.baseName;
- } else if (f_attrib.attrIsDir) {
- conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array;
- conf_filename = conf_fn;
- }
- try {
- if (exists(conf_file)) {
- if (conf_file.getLinkAttributes.attrIsFile) {
- if (_opt_action.vox_gt_2 || _opt_action.debug_do) {
- writeln("config file used: \"", conf_file, "\" (cli flag settings override config file's individual settings)");
- }
- config_file_str = conf_file.readText;
- break;
- }
- }
- } catch (ErrnoException ex) {
- } catch (FileException ex) {
- }
- }
- }
- if (config_file_str.length > 0) { break; }
- }
- if (config_file_str.length > 0) {
- import dyaml;
- Node yaml_root;
- try {
- yaml_root = Loader.fromString(config_file_str).load();
- } catch (Throwable) {
- import std.stdio;
- writeln("ERROR failed to read config file content, not parsed as yaml, program default used");
- conf_filename = "VIRTUAL";
- config_file_str = default_config_file_str;
- }
- }
- if (config_file_str.length == 0) { /+ use dummy default config file +/
- // writeln("WARNING config file NOT found, default provided");
- conf_filename = "VIRTUAL";
- config_file_str = default_config_file_str;
- }
- struct _ConfContent {
- string filename() {
- return conf_filename;
- }
- string filetype() {
- string _ft = "";
- if (content.match(rgx.yaml_config)) {
- _ft = "yaml";
- }
- return _ft;
- }
- string content() {
- return config_file_str;
- }
- }
- return _ConfContent();
- }
-}
-static template readConfigDoc() {
- import std.file;
- import std.path;
- import sisudoc.meta;
- import sisudoc.io_in.paths_source;
- import sisudoc.meta.rgx_files;
- import sisudoc.meta.rgx;
- @system final auto readConfigDoc(M,E)(M _manifested, E _env) {
- mixin spineRgxIn;
- static auto rgx = RgxI();
- mixin spineRgxFiles;
- static auto rgx_files = RgxFiles();
- string config_file_str;
- string conf_filename = "NONE";
- auto _conf_file_details = configFilePaths!()(_manifested, _env);
- string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.dr_document_make;
- foreach(conf_fn; [_conf_file_details.config_filename_document]) {
- foreach(pth; possible_config_path_locations) {
- char[] conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array;
- conf_filename = conf_fn;
- if (config_file_str.length > 0) {
- break;
- }
- try {
- if (exists(conf_file)) {
- if (conf_file.getLinkAttributes.attrIsFile) {
- config_file_str = conf_file.readText;
- break;
- }
- }
- } catch (ErrnoException ex) {
- } catch (FileException ex) {
- }
- }
- if (config_file_str.length > 0) { break; }
- }
- struct _ConfContent {
- string filename() {
- return conf_filename;
- }
- string content() {
- return config_file_str;
- }
- string filetype() {
- string _ft = "";
- if (content.match(rgx.yaml_config)) {
- _ft = "yaml";
- }
- return _ft;
- }
- }
- return _ConfContent();
- }
-}
-static template configReadSiteYAML() {
- import std.file;
- import std.path;
- import sisudoc.meta;
- import sisudoc.io_in.paths_source;
- import sisudoc.meta.rgx_files;
- import sisudoc.meta.rgx;
- final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) {
- string _configuration = configReadInSiteYAML!()(_manifested, _env);
- auto _conf_file_details = configFilePaths!()(_manifested, _env);
- string _conf_yaml_fn = _conf_file_details.config_filename_site;
- YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
- return _yaml_conf;
- }
-}
-static template configReadDocYAML() {
- import std.file;
- import std.path;
- import sisudoc.meta;
- import sisudoc.io_in.paths_source;
- final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) {
- string _configuration = configReadInDocYAML!()(_manifested, _env);
- auto _conf_file_details = configFilePaths!()(_manifested, _env);
- string _conf_yaml_fn = _conf_file_details.config_filename_document;
- YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
- return _yaml_conf;
- }
-}
diff --git a/src/sisudoc/io_in/read_source_files.d b/src/sisudoc/io_in/read_source_files.d
deleted file mode 100644
index 31cbd37..0000000
--- a/src/sisudoc/io_in/read_source_files.d
+++ /dev/null
@@ -1,435 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 source_read_source_files;
- - open markup files
- - if master file scan for addional files to import/insert
-+/
-module sisudoc.io_in.read_source_files;
-@safe:
-template spineRawMarkupContent() {
- import std.digest.sha;
- import std.file;
- import std.path;
- import sisudoc.meta;
- import sisudoc.io_in.paths_source;
- import sisudoc.meta.rgx_files;
- import sisudoc.meta.rgx;
- mixin spineRgxIn;
- static auto rgx = RgxI();
- mixin spineRgxFiles;
- static auto rgx_files = RgxFiles();
- string[] _images=[];
- string[] _extract_images(S)(S content_block) {
- string[] images_;
- string _content_block = content_block.to!string;
- if (auto m = _content_block.matchAll(rgx.image)) {
- images_ ~= m.captures[1].to!string;
- }
- return images_;
- }
- auto rawsrc = RawMarkupContent();
- struct ST_contents_inserts_images {
- char[][] contents;
- string[] insert_files;
- string[] images;
- }
- struct ST_header_content_inserts_images {
- char[] header;
- char[][] src_txt;
- string[] insert_files;
- string[] images;
- }
- struct ST_doc_digest {
- ubyte[32] markup_doc;
- ubyte[32] header;
- ubyte[32] text;
- }
- struct ST_doc_parts {
- char[] header_raw;
- char[][] sourcefile_body_content;
- string[] insert_file_list;
- string[] images_list;
- ST_doc_digest doc_digest;
- }
- ST_doc_parts spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
- ST_doc_parts _0_header_1_body_content_2_insert_filelist_struct
- = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
- return _0_header_1_body_content_2_insert_filelist_struct;
- }
- struct RawMarkupContent {
- final sourceContent(in string fn_src) {
- auto raw = MarkupRawUnit();
- string source_txt_str
- = raw.markupSourceReadIn(fn_src);
- return source_txt_str;
- }
- final ST_doc_parts sourceContentSplitIntoHeaderAndBody(O)(
- O _opt_action,
- in string source_txt_str,
- in string fn_src=""
- ) {
- auto raw = MarkupRawUnit();
- string[] insert_file_list_get;
- string[] images_list_get;
- ST_header_content_inserts_images st
- = raw.markupSourceHeaderContentRawLineStructArray(source_txt_str);
- char[] header_raw = st.header;
- char[][] sourcefile_body_content = st.src_txt;
- if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
- auto ins = Inserts();
- ST_contents_inserts_images _cii
- = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- sourcefile_body_content = _cii.contents;
- insert_file_list_get = _cii.insert_files.dup;
- images_list_get = _cii.images.dup;
- } else if (_opt_action.source_or_pod) {
- auto ins = Inserts();
- ST_contents_inserts_images _cii
- = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- images_list_get = _cii.images.dup;
- } // image_list, if path could take sha256 digests already here?
- string header_type = "";
- ST_doc_digest dig;
- {
- dig.markup_doc = source_txt_str.sha256Of;
- dig.header = st.header.sha256Of;
- dig.text = sourcefile_body_content.sha256Of;
- }
- ST_doc_parts ret;
- {
- ret.header_raw = st.header;
- ret.sourcefile_body_content = sourcefile_body_content;
- ret.insert_file_list = insert_file_list_get;
- ret.images_list = images_list_get;
- ret.doc_digest = dig;
- }
- return ret;
- }
- }
- struct MarkupRawUnit {
- import std.digest.sha;
- import std.file;
- final private string readInMarkupSource(in char[] fn_src) {
- enforce(
- exists(fn_src) != 0,
- "file not found: «" ~
- fn_src ~ "»"
- );
- string source_txt_str;
- try {
- if (exists(fn_src)) {
- if (fn_src.getLinkAttributes.attrIsFile) {
- source_txt_str = fn_src.readText;
- } else {
- }
- }
- } catch (ErrnoException ex) {
- } catch (UTFException ex) {
- // Handle validation errors
- } catch (FileException ex) {
- // Handle errors
- }
- std.utf.validate(source_txt_str);
- return source_txt_str;
- }
- @trusted final private char[][] header0Content1(in string src_text) { // cast(char[])
- /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/
- char[][] header_and_content;
- auto m = (cast(char[]) src_text).matchFirst(rgx.heading_a);
- header_and_content ~= m.pre;
- header_and_content ~= m.hit ~ m.post;
- assert(header_and_content.length == 2,
- "document markup is broken, header body split == "
- ~ header_and_content.length.to!string
- ~ "; (header / body array split should == 2 (split is on level A~))"
- );
- return header_and_content;
- }
- @trusted final private char[][] markupSourceLineArray(in char[] src_text) { // cast(char[])
- char[][] source_line_arr
- = (cast(char[]) src_text).split(rgx.newline_eol_strip_preceding);
- return source_line_arr;
- }
- string markupSourceReadIn(in string fn_src) {
- static auto rgx_files = RgxFiles();
- enforce(
- fn_src.match(rgx_files.src_pth_sst_or_ssm),
- "not a dr markup filename: «" ~
- fn_src ~ "»"
- );
- string source_txt_str = readInMarkupSource(fn_src);
- return source_txt_str;
- }
- ST_header_content_inserts_images markupSourceHeaderContentRawLineStructArray(in string source_txt_str) {
- string[] file_insert_list = [];
- string[] images_list = [];
- char[][] hc = header0Content1(source_txt_str);
- char[] header = hc[0];
- char[] source_txt = hc[1];
- char[][] source_line_arr = markupSourceLineArray(source_txt);
- ST_header_content_inserts_images ret;
- {
- ret.header = header;
- ret.src_txt = source_line_arr;
- ret.insert_files = file_insert_list;
- ret.images = images_list;
- }
- return ret;
- }
- final char[][] getInsertMarkupSourceContentRawLineArray(
- in char[] fn_src_insert,
- Regex!(char) rgx_file
- ) {
- enforce(
- fn_src_insert.match(rgx_file),
- "not a dr markup filename: «" ~
- fn_src_insert ~ "»"
- );
- string source_txt_str = readInMarkupSource(fn_src_insert);
- char[][] source_line_arr = markupSourceLineArray(source_txt_str);
- return source_line_arr;
- }
- }
- struct Inserts {
- struct ST_contents_and_images {
- char[][] insert_contents;
- string[] images;
- }
- ST_contents_and_images scan_subdoc_source(O)(
- O _opt_action,
- char[][] markup_sourcefile_insert_content,
- string fn_src
- ) {
- char[][] contents_insert;
- int code_block_status = 0;
- enum codeBlock { off, curly, tic, quotemarks }
- auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm);
- auto markup_src_file_path = fn_pth_full.captures[1];
- foreach (line; markup_sourcefile_insert_content) {
- if (code_block_status == codeBlock.curly) {
- if (line.matchFirst(rgx.block_curly_code_close)) {
- code_block_status = codeBlock.off;
- }
- contents_insert ~= line;
- } else if (line.matchFirst(rgx.block_curly_code_open)) {
- code_block_status = codeBlock.curly;
- contents_insert ~= line;
- } else if (code_block_status == codeBlock.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- code_block_status = codeBlock.off;
- }
- contents_insert ~= line;
- } else if (code_block_status == codeBlock.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- code_block_status = codeBlock.off;
- }
- contents_insert ~= line;
- } else if (line.matchFirst(rgx.block_quotemarks_code_open)) {
- code_block_status = codeBlock.quotemarks;
- contents_insert ~= line;
- } else if (line.matchFirst(rgx.block_tic_code_open)) {
- code_block_status = codeBlock.tic;
- contents_insert ~= line;
- } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) {
- auto insert_fn = m.captures[2];
- auto insert_sub_pth = m.captures[1];
- auto fn_src_insert
- = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
- auto raw = MarkupRawUnit();
- auto markup_sourcesubfile_insert_content
- = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts);
- debug(insert_file) {
- writeln(line);
- writeln(fn_src_insert);
- writeln(
- " length contents insert array: ",
- markup_sourcesubfile_insert_content.length
- );
- }
- if (_opt_action.source_or_pod) {
- _images ~= _extract_images(markup_sourcesubfile_insert_content);
- }
- auto ins = Inserts();
- /+
- - 1. load file
- - 2. read lines
- - 3. scan lines
- - a. if filename insert, and insert filename
- - repeat 1
- - b. else
- - add line to new array;
- - build image list, search for any image files to add to image list
- +/
- } else {
- contents_insert ~= line; // images to extract for image list?
- if (_opt_action.source_or_pod) {
- string[] _image_linelist = _extract_images(line);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- }
- } // end src subdoc (inserts) loop
- ST_contents_and_images ret;
- {
- ret.insert_contents = contents_insert;
- ret.images = _images;
- }
- return ret;
- }
- ST_contents_inserts_images scan_master_src_for_insert_files_and_import_content(O)(
- O _opt_action,
- char[][] sourcefile_body_content,
- string fn_src
- ) {
- import std.algorithm;
- char[][] contents;
- int code_block_status = 0;
- enum codeBlock { off, curly, tic, quotemarks }
- auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm);
- auto markup_src_file_path = fn_pth_full.captures[1];
- char[][] contents_insert;
- string[] _images =[];
- string[] insert_file_list =[];
- foreach (line; sourcefile_body_content) {
- if (code_block_status == codeBlock.curly) {
- if (line.matchFirst(rgx.block_curly_code_close)) {
- code_block_status = codeBlock.off;
- }
- contents ~= line;
- } else if (line.matchFirst(rgx.block_curly_code_open)) {
- code_block_status = codeBlock.curly;
- contents ~= line;
- } else if (code_block_status == codeBlock.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- code_block_status = codeBlock.off;
- }
- contents ~= line;
- } else if (code_block_status == codeBlock.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- code_block_status = codeBlock.off;
- }
- contents ~= line;
- } else if (line.matchFirst(rgx.block_quotemarks_code_open)) {
- code_block_status = codeBlock.quotemarks;
- contents ~= line;
- } else if (line.matchFirst(rgx.block_tic_code_open)) {
- code_block_status = codeBlock.tic;
- contents ~= line;
- } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) {
- auto insert_fn = m.captures[2];
- auto insert_sub_pth = m.captures[1];
- auto fn_src_insert
- = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
- insert_file_list ~= fn_src_insert.to!string;
- auto raw = MarkupRawUnit();
- /+ TODO +/
- auto markup_sourcefile_insert_content
- = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts);
- debug(insert_file) {
- writeln(line);
- writeln(fn_src_insert);
- writeln(
- " length contents insert array: ",
- markup_sourcefile_insert_content.length
- );
- }
- auto ins = Inserts();
- ST_contents_and_images contents_insert_st = ins.scan_subdoc_source(
- _opt_action,
- markup_sourcefile_insert_content,
- fn_src_insert.to!string
- );
- contents ~= contents_insert_st.insert_contents;
- if (_opt_action.source_or_pod) {
- string[] _image_linelist = _extract_images(contents_insert_st.images);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- /+
- - 1. load file
- - 2. read lines
- - 3. scan lines
- - a. if filename insert, and insert filename
- - repeat 1
- - b. else
- - add line to new array;
- - build image list, search for any image files to add to image list
- +/
- } else {
- contents ~= line;
- if (_opt_action.source_or_pod) {
- string[] _image_linelist = _extract_images(line);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- }
- } // end src doc loop
- string[] images = [];
- foreach(i; uniq(_images.sort())) {
- images ~= i;
- }
- debug(insert_file) {
- writeln(__LINE__);
- writeln(contents.length);
- }
- ST_contents_inserts_images ret;
- {
- ret.contents = contents;
- ret.insert_files = insert_file_list;
- ret.images = images;
- }
- return ret;
- }
- }
-}
diff --git a/src/sisudoc/io_in/read_zip_pod.d b/src/sisudoc/io_in/read_zip_pod.d
deleted file mode 100644
index d228f4e..0000000
--- a/src/sisudoc/io_in/read_zip_pod.d
+++ /dev/null
@@ -1,401 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 read_zip_pod;
- - extract pod zip archives to temp directory for processing
- - validate zip entries for security (path traversal, size limits)
-+/
-module sisudoc.io_in.read_zip_pod;
-@safe:
-template spineExtractZipPod() {
- import std.algorithm : canFind;
- import std.array : array;
- import std.conv : to;
- import std.file;
- import std.path;
- import std.regex;
- import std.stdio;
- import std.string : indexOf;
-
- /+ security limits for zip extraction +/
- enum size_t MAX_ENTRY_SIZE = 50 * 1024 * 1024; /+ 50 MB per entry +/
- enum size_t MAX_TOTAL_SIZE = 500 * 1024 * 1024; /+ 500 MB total +/
- enum size_t MAX_ENTRY_COUNT = 500; /+ max entries in archive +/
- enum size_t MAX_PATH_DEPTH = 10; /+ max path components +/
-
- /+ allowed entry name pattern: alphanumeric, dots, dashes, underscores, forward slashes +/
- static auto rgx_safe_entry_name = ctRegex!(`^[a-zA-Z0-9._/ -]+$`);
-
- struct ZipPodResult {
- string tmp_dir; /+ temp directory containing extracted pod +/
- string pod_dir; /+ path to pod directory within tmp_dir +/
- bool ok; /+ extraction succeeded +/
- string error_msg; /+ error description if !ok +/
- }
-
- /+ ↓ validate a single zip entry name for security +/
- string validateEntryName(string name) {
- /+ reject empty names +/
- if (name.length == 0)
- return "empty entry name";
- /+ reject absolute paths +/
- if (name[0] == '/')
- return "absolute path in zip entry: " ~ name;
- /+ reject path traversal +/
- if (name.canFind(".."))
- return "path traversal in zip entry: " ~ name;
- /+ reject null bytes +/
- if (name.indexOf('\0') >= 0)
- return "null byte in zip entry name: " ~ name;
- /+ reject backslashes (windows path separator tricks) +/
- if (name.canFind("\\"))
- return "backslash in zip entry: " ~ name;
- /+ check path depth +/
- size_t depth = 0;
- foreach (c; name) {
- if (c == '/') depth++;
- }
- if (depth > MAX_PATH_DEPTH)
- return "path too deep in zip entry: " ~ name;
- /+ check allowed characters +/
- if (!(name.matchFirst(rgx_safe_entry_name)))
- return "disallowed characters in zip entry: " ~ name;
- return ""; /+ empty string means valid +/
- }
-
- /+ ↓ extract zip pod to temp directory, returns ZipPodResult +/
- @trusted ZipPodResult extractZipPod(string zip_path) {
- import std.zip;
- ZipPodResult result;
- result.ok = false;
- /+ ↓ verify zip file exists +/
- if (!exists(zip_path) || !zip_path.isFile) {
- result.error_msg = "zip file not found: " ~ zip_path;
- return result;
- }
- /+ ↓ derive pod name from zip filename +/
- string zip_basename = zip_path.baseName.stripExtension;
- /+ ↓ read and parse zip archive +/
- ZipArchive zip;
- try {
- zip = new ZipArchive(read(zip_path));
- } catch (ZipException ex) {
- result.error_msg = "failed to read zip archive: " ~ zip_path ~ " - " ~ ex.msg;
- return result;
- } catch (Exception ex) {
- result.error_msg = "error reading zip file: " ~ zip_path ~ " - " ~ ex.msg;
- return result;
- }
- /+ ↓ validate entry count +/
- if (zip.directory.length > MAX_ENTRY_COUNT) {
- result.error_msg = "zip archive has too many entries ("
- ~ zip.directory.length.to!string ~ " > " ~ MAX_ENTRY_COUNT.to!string ~ "): " ~ zip_path;
- return result;
- }
- /+ ↓ validate all entries before extracting any +/
- size_t total_size = 0;
- foreach (name, member; zip.directory) {
- /+ validate entry name +/
- string name_err = validateEntryName(name);
- if (name_err.length > 0) {
- result.error_msg = name_err;
- return result;
- }
- /+ check per-entry size +/
- if (member.expandedSize > MAX_ENTRY_SIZE) {
- result.error_msg = "zip entry too large ("
- ~ member.expandedSize.to!string ~ " bytes): " ~ name;
- return result;
- }
- /+ check total size +/
- total_size += member.expandedSize;
- if (total_size > MAX_TOTAL_SIZE) {
- result.error_msg = "zip archive total size exceeds limit ("
- ~ MAX_TOTAL_SIZE.to!string ~ " bytes): " ~ zip_path;
- return result;
- }
- }
- /+ ↓ create temp directory +/
- string tmp_base = tempDir.buildPath("spine-zip-pod");
- try {
- if (!exists(tmp_base))
- mkdirRecurse(tmp_base);
- } catch (FileException ex) {
- result.error_msg = "failed to create temp base directory: " ~ ex.msg;
- return result;
- }
- /+ pod directory inside temp: tmp_base/pod_name/ +/
- string pod_dir = tmp_base.buildPath(zip_basename);
- try {
- if (exists(pod_dir))
- rmdirRecurse(pod_dir);
- mkdirRecurse(pod_dir);
- } catch (FileException ex) {
- result.error_msg = "failed to create temp pod directory: " ~ ex.msg;
- return result;
- }
- /+ ↓ extract entries +/
- /+ zip internal structure uses paths like:
- pod.manifest, conf/dr_document_make,
- pod/media/text/en/filename.sst, image/filename.png
- but the extracted pod directory needs to look like a normal pod:
- pod.manifest, conf/dr_document_make,
- media/text/en/filename.sst, image/filename.png
- The "pod/" prefix in zip entries for text files maps to the pod root.
- +/
- /+ ↓ pre-compute canonical pod path for containment checks +/
- auto canonical_pod = (pod_dir.asNormalizedPath).array.to!string ~ "/";
- foreach (name, member; zip.directory) {
- /+ skip directory entries +/
- if (name.length > 0 && name[$-1] == '/')
- continue;
- /+ ↓ map zip internal path to filesystem path +/
- /+ entries with "pod/" prefix: strip it so media/text/en/file.sst ends up at pod_dir/media/text/en/file.sst +/
- string entry_path = name;
- if (entry_path.length > 4 && entry_path[0..4] == "pod/") {
- entry_path = entry_path[4..$];
- }
- string out_path = pod_dir.buildPath(entry_path);
- /+ ↓ verify resolved path is within pod_dir (defense in depth) +/
- auto canonical_out = (out_path.asNormalizedPath).array.to!string;
- if (canonical_out.length < canonical_pod.length
- || canonical_out[0..canonical_pod.length] != canonical_pod)
- {
- result.error_msg = "zip entry escapes extraction directory: " ~ name;
- try { rmdirRecurse(pod_dir); } catch (FileException) {}
- return result;
- }
- /+ ↓ create parent directories +/
- string parent = out_path.dirName;
- try {
- if (!exists(parent))
- mkdirRecurse(parent);
- } catch (FileException ex) {
- result.error_msg = "failed to create directory for: " ~ name ~ " - " ~ ex.msg;
- try { rmdirRecurse(pod_dir); } catch (FileException) {}
- return result;
- }
- /+ ↓ decompress and write file +/
- try {
- auto data = zip.expand(member);
- std.file.write(out_path, data);
- } catch (Exception ex) {
- result.error_msg = "failed to extract: " ~ name ~ " - " ~ ex.msg;
- try { rmdirRecurse(pod_dir); } catch (FileException) {}
- return result;
- }
- }
- /+ ↓ verify no symlinks were created (defense in depth) +/
- string symlink_err = checkForSymlinks(pod_dir);
- if (symlink_err.length > 0) {
- result.error_msg = symlink_err;
- try { rmdirRecurse(pod_dir); } catch (FileException) {}
- return result;
- }
- /+ ↓ verify pod.manifest exists in extracted content +/
- if (!exists(pod_dir.buildPath("pod.manifest"))) {
- result.error_msg = "zip archive does not contain pod.manifest: " ~ zip_path;
- try { rmdirRecurse(pod_dir); } catch (FileException) {}
- return result;
- }
- result.tmp_dir = tmp_base;
- result.pod_dir = pod_dir;
- result.ok = true;
- return result;
- }
-
- /+ ↓ recursively check for symlinks in extracted directory +/
- @trusted string checkForSymlinks(string dir_path) {
- try {
- foreach (entry; dirEntries(dir_path, SpanMode.depth)) {
- if (entry.isSymlink) {
- return "symlink found in zip extraction: " ~ entry.name;
- }
- }
- } catch (FileException ex) {
- return "error checking for symlinks: " ~ ex.msg;
- }
- return "";
- }
-
- /+ ↓ download a zip pod from a URL to a temp file +/
- enum size_t MAX_DOWNLOAD_SIZE = 200 * 1024 * 1024; /+ 200 MB download limit +/
- enum int DOWNLOAD_TIMEOUT = 120; /+ seconds +/
-
- static auto rgx_url_zip = ctRegex!(`^https?://[a-zA-Z0-9._:/-]+[.]zip$`);
-
- struct DownloadResult {
- string local_path; /+ path to downloaded temp file +/
- bool ok;
- string error_msg;
- }
-
- bool isUrl(string arg) {
- return arg.length > 8
- && (arg[0..8] == "https://" || arg[0..7] == "http://");
- }
-
- @trusted DownloadResult downloadZipUrl(string url) {
- import std.process : execute, environment;
- DownloadResult result;
- result.ok = false;
- /+ ↓ validate URL scheme +/
- if (url.length < 8 || (url[0..8] != "https://" && url[0..7] != "http://")) {
- result.error_msg = "only http/https URLs are supported: " ~ url;
- return result;
- }
- if (url[0..7] == "http://" && url[0..8] != "https://") {
- stderr.writeln("WARNING: downloading over insecure http: ", url);
- }
- /+ ↓ validate URL format +/
- if (!(url.matchFirst(rgx_url_zip))) {
- result.error_msg = "URL does not match expected zip URL pattern: " ~ url;
- return result;
- }
- /+ ↓ reject URLs that could target internal services +/
- {
- import std.uni : toLower;
- string url_lower = url.toLower;
- /+ strip scheme to get host portion +/
- string after_scheme = (url_lower[0..8] == "https://")
- ? url_lower[8..$]
- : url_lower[7..$];
- /+ extract host (up to first / or :) +/
- string host;
- foreach (i, c; after_scheme) {
- if (c == '/' || c == ':') {
- host = after_scheme[0..i];
- break;
- }
- }
- if (host.length == 0) host = after_scheme;
- if (host == "localhost"
- || host == "127.0.0.1"
- || host == "::1"
- || host == "[::1]"
- || host == "0.0.0.0"
- || host.canFind("169.254.")
- || host.canFind("10.")
- || host.canFind("192.168.")
- ) {
- result.error_msg = "URL targets a local/private address: " ~ url;
- return result;
- }
- }
- /+ ↓ derive filename from URL +/
- string url_basename = url.baseName;
- if (url_basename.length == 0 || url_basename.indexOf('.') < 0) {
- result.error_msg = "cannot determine filename from URL: " ~ url;
- return result;
- }
- /+ ↓ create temp directory for download +/
- string tmp_base = tempDir.buildPath("spine-zip-pod");
- try {
- if (!exists(tmp_base))
- mkdirRecurse(tmp_base);
- } catch (FileException ex) {
- result.error_msg = "failed to create temp directory: " ~ ex.msg;
- return result;
- }
- string tmp_file = tmp_base.buildPath(url_basename);
- /+ ↓ download using curl +/
- auto curl_result = execute([
- "curl",
- "--silent", "--show-error",
- "--fail", /+ fail on HTTP errors +/
- "--location", /+ follow redirects +/
- "--max-redirs", "5", /+ limit redirects +/
- "--max-time", DOWNLOAD_TIMEOUT.to!string,
- "--max-filesize", MAX_DOWNLOAD_SIZE.to!string,
- "--proto", "=https,http", /+ restrict protocols +/
- "--output", tmp_file,
- url
- ]);
- if (curl_result.status != 0) {
- result.error_msg = "download failed: " ~ url;
- if (curl_result.output.length > 0)
- result.error_msg ~= " - " ~ curl_result.output;
- /+ clean up partial download +/
- try { if (exists(tmp_file)) remove(tmp_file); } catch (FileException) {}
- return result;
- }
- if (!exists(tmp_file) || !tmp_file.isFile) {
- result.error_msg = "download produced no file: " ~ url;
- return result;
- }
- result.local_path = tmp_file;
- result.ok = true;
- return result;
- }
-
- /+ ↓ clean up a downloaded temp file +/
- void cleanupDownload(ref DownloadResult dlr) {
- if (dlr.local_path.length > 0 && exists(dlr.local_path)) {
- try {
- remove(dlr.local_path);
- } catch (FileException ex) {
- stderr.writeln("WARNING: failed to clean up downloaded file: ", dlr.local_path);
- }
- }
- dlr.ok = false;
- }
-
- /+ ↓ clean up extracted temp directory +/
- void cleanupZipPod(ref ZipPodResult zpr) {
- if (zpr.pod_dir.length > 0 && exists(zpr.pod_dir)) {
- try {
- rmdirRecurse(zpr.pod_dir);
- } catch (FileException ex) {
- stderr.writeln("WARNING: failed to clean up temp zip extraction: ", zpr.pod_dir);
- }
- }
- zpr.ok = false;
- }
-}
diff --git a/src/sisudoc/io_out/create_abstraction_db.d b/src/sisudoc/io_out/create_abstraction_db.d
deleted file mode 100644
index 20ca074..0000000
--- a/src/sisudoc/io_out/create_abstraction_db.d
+++ /dev/null
@@ -1,355 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.create_abstraction_db;
-
-/+ ↓ write document abstraction as per-document sqlite3 database +/
-template spineAbstractionDb() {
- import std.conv : to;
- import std.file;
- import std.path;
- import std.stdio;
- import std.string;
- import std.array;
- import d2sqlite3;
- import sisudoc.io_out.paths_output;
-
- void spineAbstractionDb(D)(D doc) {
- auto doc_abstraction = doc.abstraction;
- auto doc_matters = doc.matters;
-
- /+ ↓ determine output path +/
- auto out_pth = spineOutPaths!()(doc_matters.output_path, doc_matters.src.language);
- string base_dir = "abstraction";
- string base_pth = ((out_pth.output_base.chainPath(base_dir)).asNormalizedPath).array;
- try {
- if (!exists(base_pth)) {
- base_pth.mkdirRecurse;
- }
- } catch (Exception ex) {
- }
- string db_file = ((base_pth.chainPath(
- doc_matters.src.doc_uid_out ~ ".abstraction.db")).asNormalizedPath).array;
-
- /+ ↓ remove existing file to start fresh +/
- try {
- if (exists(db_file)) {
- remove(db_file);
- }
- } catch (Exception ex) {
- }
-
- if (doc_matters.opt.action.vox_gt_1) {
- writeln(" ", db_file);
- }
-
- /+ ↓ open database and create schema +/
- auto db = Database(db_file);
- db.run("PRAGMA journal_mode=WAL");
- db.run("PRAGMA synchronous=NORMAL");
-
- db.run("
- CREATE TABLE metadata (
- key TEXT PRIMARY KEY,
- value TEXT NOT NULL
- );
-
- CREATE TABLE objects (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- section TEXT NOT NULL,
- seq INTEGER NOT NULL,
- ocn INTEGER DEFAULT 0,
- is_a TEXT NOT NULL,
- is_of_part TEXT,
- is_of_type TEXT,
- heading_level INTEGER,
- identifier TEXT,
- parent_ocn INTEGER DEFAULT 0,
- last_descendant_ocn INTEGER DEFAULT 0,
- ancestors TEXT,
- dummy_heading INTEGER DEFAULT 0,
- object_number_off INTEGER DEFAULT 0,
- indent_base INTEGER DEFAULT 0,
- indent_hang INTEGER DEFAULT 0,
- bullet INTEGER DEFAULT 0,
- lang TEXT,
- has_links INTEGER DEFAULT 0,
- has_notes_reg INTEGER DEFAULT 0,
- has_notes_star INTEGER DEFAULT 0,
- has_images INTEGER DEFAULT 0,
- segment TEXT,
- segment_prev TEXT,
- segment_next TEXT,
- anchor TEXT,
- table_cols INTEGER,
- table_widths TEXT,
- table_header INTEGER,
- code_syntax TEXT,
- code_linenumbers INTEGER DEFAULT 0,
- text TEXT
- );
-
- CREATE INDEX idx_objects_section ON objects(section);
- CREATE INDEX idx_objects_ocn ON objects(ocn);
- CREATE INDEX idx_objects_parent ON objects(parent_ocn);
- CREATE INDEX idx_objects_is_a ON objects(is_a);
- CREATE INDEX idx_objects_heading ON objects(heading_level)
- WHERE heading_level IS NOT NULL;
- ");
-
- /+ ↓ populate metadata +/
- db.run("BEGIN TRANSACTION");
-
- auto meta_stmt = db.prepare(
- "INSERT INTO metadata (key, value) VALUES (:key, :value)"
- );
- auto meta = doc_matters.conf_make_meta.meta;
-
- void insertMeta(string key, string value) {
- if (value.length > 0) {
- meta_stmt.bind(":key", key);
- meta_stmt.bind(":value", value);
- meta_stmt.execute();
- meta_stmt.reset();
- }
- }
-
- insertMeta("title.main", meta.title_main);
- insertMeta("title.subtitle", meta.title_subtitle);
- insertMeta("title.full", meta.title_full);
- insertMeta("title.language", meta.title_language);
- insertMeta("creator.author", meta.creator_author);
- insertMeta("creator.author_surname", meta.creator_author_surname);
- insertMeta("creator.author_surname_fn", meta.creator_author_surname_fn);
- insertMeta("creator.author_email", meta.creator_author_email);
- insertMeta("creator.illustrator", meta.creator_illustrator);
- insertMeta("creator.translator", meta.creator_translator);
- insertMeta("date.published", meta.date_published);
- insertMeta("date.created", meta.date_created);
- insertMeta("date.issued", meta.date_issued);
- insertMeta("date.available", meta.date_available);
- insertMeta("date.modified", meta.date_modified);
- insertMeta("date.valid", meta.date_valid);
- insertMeta("rights.copyright", meta.rights_copyright);
- insertMeta("rights.license", meta.rights_license);
- insertMeta("classify.topic_register", meta.classify_topic_register);
- insertMeta("classify.subject", meta.classify_subject);
- insertMeta("classify.keywords", meta.classify_keywords);
- insertMeta("classify.loc", meta.classify_loc);
- insertMeta("classify.dewey", meta.classify_dewey);
- insertMeta("identifier.isbn", meta.identifier_isbn);
- insertMeta("identifier.oclc", meta.identifier_oclc);
- insertMeta("language.document", meta.language_document);
- insertMeta("notes.abstract", meta.notes_abstract);
- insertMeta("notes.description", meta.notes_description);
- insertMeta("notes.summary", meta.notes_summary);
-
- /+ ↓ make settings +/
- auto make = doc_matters.conf_make_meta.make;
- insertMeta("make.doc_type", make.doc_type);
- insertMeta("make.auto_num_top_at_level", make.auto_num_top_at_level);
- insertMeta("make.auto_num_top_lv", make.auto_num_top_lv.to!string);
- insertMeta("make.auto_num_depth", make.auto_num_depth.to!string);
-
- /+ ↓ doc_has counts +/
- insertMeta("doc_has.inline_links", doc_matters.has.inline_links.to!string);
- insertMeta("doc_has.inline_notes_reg", doc_matters.has.inline_notes_reg.to!string);
- insertMeta("doc_has.inline_notes_star", doc_matters.has.inline_notes_star.to!string);
- insertMeta("doc_has.tables", doc_matters.has.tables.to!string);
- insertMeta("doc_has.codeblocks", doc_matters.has.codeblocks.to!string);
- insertMeta("doc_has.images", doc_matters.has.images.to!string);
- insertMeta("doc_has.poems", doc_matters.has.poems.to!string);
- insertMeta("doc_has.groups", doc_matters.has.groups.to!string);
- insertMeta("doc_has.blocks", doc_matters.has.blocks.to!string);
- insertMeta("doc_has.quotes", doc_matters.has.quotes.to!string);
-
- meta_stmt.finalize();
-
- /+ ↓ populate objects +/
- auto obj_stmt = db.prepare(
- "INSERT INTO objects ("
- ~ "section, seq, ocn, is_a, is_of_part, is_of_type,"
- ~ "heading_level, identifier, parent_ocn, last_descendant_ocn,"
- ~ "ancestors, dummy_heading, object_number_off,"
- ~ "indent_base, indent_hang, bullet, lang,"
- ~ "has_links, has_notes_reg, has_notes_star, has_images,"
- ~ "segment, segment_prev, segment_next, anchor,"
- ~ "table_cols, table_widths, table_header,"
- ~ "code_syntax, code_linenumbers, text"
- ~ ") VALUES ("
- ~ ":section, :seq, :ocn, :is_a, :is_of_part, :is_of_type,"
- ~ ":heading_level, :identifier, :parent_ocn, :last_descendant_ocn,"
- ~ ":ancestors, :dummy_heading, :object_number_off,"
- ~ ":indent_base, :indent_hang, :bullet, :lang,"
- ~ ":has_links, :has_notes_reg, :has_notes_star, :has_images,"
- ~ ":segment, :segment_prev, :segment_next, :anchor,"
- ~ ":table_cols, :table_widths, :table_header,"
- ~ ":code_syntax, :code_linenumbers, :text"
- ~ ")"
- );
-
- string[] section_order = ["head", "toc", "body", "endnotes",
- "glossary", "bibliography", "bookindex", "blurb"];
-
- foreach (section; section_order) {
- if (section !in doc_abstraction) continue;
- auto section_objs = doc_abstraction[section];
- if (section_objs.length == 0) continue;
-
- foreach (seq, obj; section_objs) {
- obj_stmt.bind(":section", section);
- obj_stmt.bind(":seq", cast(int) seq);
- obj_stmt.bind(":ocn", obj.metainfo.ocn);
- obj_stmt.bind(":is_a", obj.metainfo.is_a);
-
- /+ ↓ nullable string fields +/
- void bindStr(string param, string val) {
- import std.typecons : Nullable;
- if (val.length > 0) {
- obj_stmt.bind(param, val);
- } else {
- obj_stmt.bind(param, Nullable!string());
- }
- }
-
- bindStr(":is_of_part", obj.metainfo.is_of_part);
- bindStr(":is_of_type", obj.metainfo.is_of_type);
-
- /+ ↓ heading level +/
- {
- import std.typecons : Nullable;
- if (obj.metainfo.is_a == "heading" && obj.metainfo.heading_lev_markup < 9) {
- obj_stmt.bind(":heading_level", obj.metainfo.heading_lev_markup);
- } else {
- obj_stmt.bind(":heading_level", Nullable!int());
- }
- }
-
- bindStr(":identifier", obj.metainfo.identifier);
- obj_stmt.bind(":parent_ocn", obj.metainfo.parent_ocn);
- obj_stmt.bind(":last_descendant_ocn", obj.metainfo.last_descendant_ocn);
-
- /+ ↓ ancestors as space-separated integers +/
- {
- bool has_ancestors = false;
- foreach (a; obj.metainfo.markedup_ancestors) {
- if (a != 0) { has_ancestors = true; break; }
- }
- if (has_ancestors) {
- string anc;
- foreach (i, a; obj.metainfo.markedup_ancestors) {
- if (i > 0) anc ~= " ";
- anc ~= a.to!string;
- }
- obj_stmt.bind(":ancestors", anc);
- } else {
- import std.typecons : Nullable;
- obj_stmt.bind(":ancestors", Nullable!string());
- }
- }
-
- obj_stmt.bind(":dummy_heading", obj.metainfo.dummy_heading ? 1 : 0);
- obj_stmt.bind(":object_number_off", obj.metainfo.object_number_off ? 1 : 0);
- obj_stmt.bind(":indent_base", obj.attrib.indent_base);
- obj_stmt.bind(":indent_hang", obj.attrib.indent_hang);
- obj_stmt.bind(":bullet", obj.attrib.bullet ? 1 : 0);
- bindStr(":lang", obj.attrib.language);
- obj_stmt.bind(":has_links", obj.has.inline_links ? 1 : 0);
- obj_stmt.bind(":has_notes_reg", obj.has.inline_notes_reg ? 1 : 0);
- obj_stmt.bind(":has_notes_star", obj.has.inline_notes_star ? 1 : 0);
- obj_stmt.bind(":has_images", obj.has.images ? 1 : 0);
- bindStr(":segment", obj.tags.in_segment_html);
- bindStr(":segment_prev", obj.tags.segname_prev);
- bindStr(":segment_next", obj.tags.segname_next);
- bindStr(":anchor", obj.tags.anchor_tag_html);
-
- /+ ↓ table properties +/
- {
- import std.typecons : Nullable;
- if (obj.metainfo.is_a == "table" && obj.table.number_of_columns > 0) {
- obj_stmt.bind(":table_cols", obj.table.number_of_columns);
- if (obj.table.column_widths.length > 0) {
- string[] ws;
- foreach (w; obj.table.column_widths) ws ~= w.to!string;
- obj_stmt.bind(":table_widths", ws.join(" "));
- } else {
- obj_stmt.bind(":table_widths", Nullable!string());
- }
- obj_stmt.bind(":table_header", obj.table.heading ? 1 : 0);
- } else {
- obj_stmt.bind(":table_cols", Nullable!int());
- obj_stmt.bind(":table_widths", Nullable!string());
- obj_stmt.bind(":table_header", Nullable!int());
- }
- }
-
- /+ ↓ code block properties +/
- {
- import std.typecons : Nullable;
- if (obj.metainfo.is_a == "code") {
- bindStr(":code_syntax", obj.code_block.syntax);
- obj_stmt.bind(":code_linenumbers", obj.code_block.linenumbers ? 1 : 0);
- } else {
- obj_stmt.bind(":code_syntax", Nullable!string());
- obj_stmt.bind(":code_linenumbers", 0);
- }
- }
-
- /+ ↓ text content +/
- bindStr(":text", obj.text);
-
- obj_stmt.execute();
- obj_stmt.reset();
- }
- }
-
- obj_stmt.finalize();
- db.run("COMMIT TRANSACTION");
- }
-}
diff --git a/src/sisudoc/io_out/create_zip_file.d b/src/sisudoc/io_out/create_zip_file.d
deleted file mode 100644
index 4063ab5..0000000
--- a/src/sisudoc/io_out/create_zip_file.d
+++ /dev/null
@@ -1,67 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.create_zip_file;
-@safe:
-template createZipFile() {
- import std.file;
- import std.outbuffer;
- import std.string;
- import std.zip;
- void createZipFile(
- string zip_file_name,
- void[] compressed_zip_data,
- ) {
- try {
- write(zip_file_name, compressed_zip_data);
- } catch (ZipException ex) {
- // Handle Errors
- }
- }
-}
diff --git a/src/sisudoc/io_out/curate/metadoc_curate.d b/src/sisudoc/io_out/curate/metadoc_curate.d
deleted file mode 100644
index 8e87167..0000000
--- a/src/sisudoc/io_out/curate/metadoc_curate.d
+++ /dev/null
@@ -1,90 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.curate.metadoc_curate;
-@safe:
-template spineMetaDocCurate() {
- auto spineMetaDocCurate(T,H)(
- T doc_matters,
- H hvst,
- ) {
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- static auto mkup = InlineMarkup();
- import sisudoc.io_out.paths_output;
- 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/sisudoc/io_out/curate/metadoc_curate_authors.d b/src/sisudoc/io_out/curate/metadoc_curate_authors.d
deleted file mode 100644
index 6a356e7..0000000
--- a/src/sisudoc/io_out/curate/metadoc_curate_authors.d
+++ /dev/null
@@ -1,528 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.curate.metadoc_curate_authors;
-@safe:
- import std.algorithm;
- import std.array;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.conv : to;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- mixin spineCurateMetadata;
- mixin InternalMarkup;
-template spineMetaDocCuratesAuthors() {
- 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 (output organised by language & filetype)
-
-
-
-
-
-
-
-
-
-
-
-
-┃") ~ "\n";
- import sisudoc.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/sisudoc/io_out/curate/metadoc_curate_topics.d b/src/sisudoc/io_out/curate/metadoc_curate_topics.d
deleted file mode 100644
index 05643b9..0000000
--- a/src/sisudoc/io_out/curate/metadoc_curate_topics.d
+++ /dev/null
@@ -1,691 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.curate.metadoc_curate_topics;
-@safe:
- import std.algorithm;
- import std.array;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.conv : to;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- mixin spineCurateMetadata;
- mixin InternalMarkup;
-template spineMetaDocCuratesTopics() {
- 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 (output organised by language & filetype)
-
-
-┃",
- _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"┃┃",
- k0.toUpper.to!(char[])[0],
- k0.toUpper.to!(char[])[0],
- );
- _prev_k = k0.toUpper.to!(char[])[0];
- }
- if (k0 != "_a") {
- topics ~= format(q"┃┃",
- 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"┃
-
-
-
-
-
-
-
-
-┃") ~ "\n";
- import sisudoc.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/sisudoc/io_out/defaults.d b/src/sisudoc/io_out/defaults.d
deleted file mode 100644
index 290ca89..0000000
--- a/src/sisudoc/io_out/defaults.d
+++ /dev/null
@@ -1,186 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.io_out.defaults;
-@safe:
-
-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/sisudoc/io_out/epub3.d b/src/sisudoc/io_out/epub3.d
deleted file mode 100644
index c715630..0000000
--- a/src/sisudoc/io_out/epub3.d
+++ /dev/null
@@ -1,804 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.epub3;
-@safe:
-template outputEPub3() {
- import std.file;
- import std.outbuffer;
- import std.uri;
- import std.zip;
- import std.conv : to;
- import sisudoc.io_out;
- import sisudoc.io_out.rgx;
- import sisudoc.io_out.rgx_xhtml;
- import sisudoc.io_out.create_zip_file;
- import sisudoc.io_out.xmls;
- import sisudoc.io_out.xmls_css;
- mixin InternalMarkup;
- mixin outputXHTMLs;
- static auto rgx = RgxO();
- static auto rgx_xhtml = RgxXHTML();
- string special_characters_text(string _txt) {
- _txt = _txt
- .replaceAll(rgx_xhtml.ampersand, "&") // "&"
- .replaceAll(rgx_xhtml.quotation, """) // """
- .replaceAll(rgx_xhtml.less_than, "<") // "<"
- .replaceAll(rgx_xhtml.greater_than, ">") // ">"
- .replaceAll(rgx.br_line, "
")
- .replaceAll(rgx.br_line_inline, "
")
- .replaceAll(rgx.br_line_spaced, "
\n
")
- .replaceAll(rgx.nbsp_char, " ");
- return _txt;
- }
- string epub3_mimetypes() {
- string o;
- o = format(q"┃application/epub+zip┃") ~ "\n";
- return o;
- }
- string epub3_container_xml() {
- string o;
- o = format(q"┃┃") ~ "\n";
- o ~= format(q"┃Contents
-
")
- .replaceAll(rgx.br_line_inline, "
")
- .replaceAll(rgx.br_line_spaced, "
\n
")
- .replaceAll(rgx.nbsp_char, " ");
- return _txt;
- }
-}
diff --git a/src/sisudoc/io_out/hub.d b/src/sisudoc/io_out/hub.d
deleted file mode 100644
index 6ca047a..0000000
--- a/src/sisudoc/io_out/hub.d
+++ /dev/null
@@ -1,239 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
-
-+/
-/++
- output hub
- check & generate output types requested
-+/
-module sisudoc.io_out.hub;
-@safe:
-template outputHub() {
- import sisudoc.io_out,
- sisudoc.io_out.metadata,
- sisudoc.io_out.xmls,
- sisudoc.io_out.create_zip_file,
- sisudoc.io_out.paths_output;
- @system void outputHub(D)(D doc) {
- mixin Msg;
- auto msg = Msg!()(doc.matters);
- enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff, text, skel }
- void Scheduled(D)(int sched, D doc) {
- auto msg = Msg!()(doc.matters);
- if (sched == outTask.source_or_pod) {
- msg.v("spine (doc reform) source processing... ");
- if (doc.matters.opt.action.pod) { msg.v("spine (doc reform) source pod processing... "); }
- import sisudoc.io_out.source_pod;
- spinePod!()(doc.matters);
- if (doc.matters.opt.action.source) { msg.vv("spine (doc reform) source done"); }
- if (doc.matters.opt.action.pod) { msg.vv("spine (doc reform) source pod done"); }
- }
- if (sched == outTask.epub) {
- msg.v("epub3 processing... ");
- import sisudoc.io_out.epub3;
- doc.outputEPub3!();
- msg.vv("epub3 done");
- }
- if (sched == outTask.html_stuff) {
- outputMetadata!()(doc.matters);
- msg.vv("html metadata done");
- }
- if (sched == outTask.html_scroll) {
- msg.v("html scroll processing... ");
- import sisudoc.io_out.html;
- outputHTML!().scroll(doc);
- msg.vv("html scroll done");
- }
- if (sched == outTask.html_seg) {
- msg.v("html seg processing... ");
- import sisudoc.io_out.html;
- outputHTML!().seg(doc);
- msg.vv("html seg done");
- }
- if (sched == outTask.html_stuff) {
- import sisudoc.io_out.html;
- outputHTML!().css(doc.matters);
- outputHTML!().images_cp(doc.matters);
- msg.vv("html css & images done");
- }
- if (sched == outTask.latex) {
- msg.v("latex processing... (available for downstream processing & pdf output");
- import sisudoc.io_out.latex;
- import std.file;
- if ((isValidPath(doc.matters.output_path ~ "/latex/sty"))
- && (!(exists(doc.matters.output_path ~ "/latex/sty")))
- ) {
- outputLaTeXstyInit!()(
- doc.matters.output_path,
- doc.matters.opt.action.generated_by,
- doc.matters.generator_program.name_version_and_compiler,
- doc.matters.generator_program.time_output_generated,
- );
- }
- outputLaTeX!()(doc.abstraction, doc.matters);
- msg.vv("latex done");
- }
- if (sched == outTask.text) {
- msg.v("text processing... ");
- import sisudoc.io_out.text;
- outputText!()(doc.abstraction, doc.matters);
- msg.vv("text done");
- }
- if (sched == outTask.odt) {
- msg.v("odf:odt processing... ");
- import sisudoc.io_out.odt;
- outputODT!()(doc.abstraction, doc.matters);
- msg.vv("odf:odt done");
- }
- if (sched == outTask.sqlite) {
- msg.v("sqlite processing... ");
- import sisudoc.io_out.sqlite;
- doc.SQLiteHubDiscreteBuildTablesAndPopulate!();
- msg.vv("sqlite done");
- }
- if (sched == outTask.skel) {
- msg.v("skel processing... ");
- import sisudoc.io_out.skel;
- outputSkel!()(doc.abstraction, doc.matters);
- msg.vv("skel done");
- }
- }
- if (doc.matters.opt.action.vox_gt_1) { writeln(doc.matters.src.filename_base); }
- if (!(doc.matters.opt.action.parallelise_subprocesses)) {
- foreach(schedule; doc.matters.opt.action.output_task_scheduler) {
- Scheduled!()(schedule, doc);
- }
- } else {
- import std.parallelism;
- foreach(schedule; parallel(doc.matters.opt.action.output_task_scheduler)) {
- Scheduled!()(schedule, doc);
- }
- }
- if (doc.matters.opt.action.sqlite_update) {
- msg.v("sqlite update processing...");
- import sisudoc.io_out.sqlite;
- doc.SQLiteHubBuildTablesAndPopulate!();
- msg.vv("sqlite update done");
- } else if (doc.matters.opt.action.sqlite_delete) {
- msg.v("sqlite delete processing...");
- import sisudoc.io_out.sqlite;
- doc.SQLiteHubBuildTablesAndPopulate!();
- msg.vv("sqlite delete done");
- }
- }
-}
-template outputHubInitialize() {
- import std.file;
- import sisudoc.io_out,
- sisudoc.io_out.metadata,
- sisudoc.io_out.paths_output;
- string _bespoke_homepage = "./spine-bespoke-output/html/homepage.index.html";
- @system void outputHubInitialize(O,I)(
- O opt_action,
- I program_info
- ) {
- if ((opt_action.html || opt_action.html_seg || opt_action.html_scroll)
- && opt_action.output_dir_set.length > 0
- && !(opt_action.output_dir_set ~ "/index.html").exists
- ) {
- writeln(_bespoke_homepage);
- if ((_bespoke_homepage).exists) {
- writeln("copy bespoke html homepage\n", _bespoke_homepage, " -> ", opt_action.output_dir_set, "/index.html");
- _bespoke_homepage.copy(opt_action.output_dir_set ~ "/index.html");
- } else {
- writeln("place bespoke homepage in ", _bespoke_homepage);
- }
- }
- if (
- opt_action.latex_document_header_sty
- || (
- opt_action.latex
- && opt_action.output_dir_set.length > 0
- && !(isValidPath(opt_action.output_dir_set ~ "/latex/sty")))
- ) { // .sty need to be produced only once (if unchanged per output-dir of which there usually will be only one)
- import sisudoc.io_out.latex;
- outputLaTeXstyInit!()(
- opt_action.output_dir_set,
- opt_action.generated_by,
- program_info.name_version_and_compiler,
- program_info.time_output_generated,
- );
- writeln(opt_action.latex);
- }
- }
-}
-template outputHubOp() {
- import sisudoc.io_out,
- sisudoc.io_out.metadata,
- sisudoc.io_out.xmls,
- sisudoc.io_out.create_zip_file,
- sisudoc.io_out.paths_output;
- @system void outputHubOp(E,O,C)(E env, O opt_action, C config) {
- if ((opt_action.sqlite_db_drop)) {
- if ((opt_action.vox_gt_2)) {
- writeln("sqlite drop db...");
- }
- import sisudoc.io_out.sqlite;
- SQLiteDbDrop!()(opt_action, config);
- if ((opt_action.vox_gt_3)) {
- writeln("sqlite drop db done");
- }
- }
- if ((opt_action.sqlite_db_create)) {
- if ((opt_action.vox_gt_2)) {
- auto pth_sqlite_db = spinePathsSQLite!()(opt_action.cgi_sqlite_search_filename, opt_action.output_dir_set);
- writeln("sqlite create table...");
- }
- import sisudoc.io_out.sqlite;
- SQLiteTablesCreate!()(env, opt_action, config);
- if ((opt_action.vox_gt_3)) {
- writeln("sqlite create table done");
- }
- }
- }
-}
diff --git a/src/sisudoc/io_out/latex.d b/src/sisudoc/io_out/latex.d
deleted file mode 100644
index 8a1ae3e..0000000
--- a/src/sisudoc/io_out/latex.d
+++ /dev/null
@@ -1,1786 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.latex;
-@safe:
-template paperLaTeX() {
- import std.format;
- import std.conv : to;
- auto paperLaTeX() {
- string mm(uint mmi) {
- string _mm = format(q"┃%smm┃", mmi.to!string);
- return _mm;
- }
- struct PaperType {
- auto a4() {
- struct A4 {
- auto portrait() {
- struct V {
- string stylesheet = "spineA4portrait";
- string papersize = "a4paper";
- string orient = "portrait";
- string fontsize = "11pt";
- const uint w = 170;
- const uint h = 257;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 450;
- bool is_portrait = true;
- }
- return V();
- }
- auto landscape() {
- struct H {
- string stylesheet = "spineA4landscape";
- string papersize = "a4paper";
- string orient = "landscape";
- string fontsize = "11pt";
- const uint w = 238;
- const uint h = 160;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 300;
- bool is_portrait = false;
- }
- return H();
- }
- }
- return A4();
- }
- auto a5() {
- struct A5 {
- auto portrait() {
- struct V {
- string stylesheet = "spineA5portrait";
- string papersize = "a5paper";
- string orient = "portrait";
- string fontsize = "11pt";
- const uint w = 112;
- const uint h = 162;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 280;
- bool is_portrait = true;
- }
- return V();
- }
- auto landscape() {
- struct H {
- string stylesheet = "spineA5landscape";
- string papersize = "a5paper";
- string orient = "landscape";
- string fontsize = "11pt";
- const uint w = 152;
- const uint h = 100;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 190;
- bool is_portrait = false;
- }
- return H();
- }
- }
- return A5();
- }
- auto b4() {
- struct B4 {
- auto portrait() {
- struct V {
- string stylesheet = "spineB4portrait";
- string papersize = "b4paper";
- string orient = "portrait";
- string fontsize = "11pt";
- const uint w = 140;
- const uint h = 204;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 356;
- bool is_portrait = true;
- }
- return V();
- }
- auto landscape() {
- struct H {
- string stylesheet = "spineB4landsape";
- string papersize = "b4paper";
- string orient = "landscape";
- string fontsize = "11pt";
- const uint w = 200;
- const uint h = 130;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 260;
- bool is_portrait = false;
- }
- return H();
- }
- }
- return B4();
- }
- auto letter() {
- struct Letter {
- auto portrait() {
- struct V {
- string stylesheet = "spineLetterPortrait";
- string papersize = "letterpaper";
- string orient = "portrait";
- string fontsize = "11pt";
- const uint w = 166;
- const uint h = 212;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 468;
- bool is_portrait = true;
- }
- return V();
- }
- auto landscape() {
- struct H {
- string stylesheet = "spineLetterLandscape";
- string papersize = "letterpaper";
- string orient = "landscape";
- string fontsize = "11pt";
- const uint w = 226;
- const uint h = 166;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 290;
- bool is_portrait = false;
- }
- return H();
- }
- }
- return Letter();
- }
- auto legal() {
- struct Legal {
- auto portrait() {
- struct V {
- string stylesheet = "spineLegalPortrait";
- string papersize = "legalpaper";
- string orient = "portrait";
- string fontsize = "11pt";
- const uint w = 168;
- const uint h = 286;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 474;
- bool is_portrait = true;
- }
- return V();
- }
- auto landscape() {
- struct H {
- string stylesheet = "spineLegalLandscape";
- string papersize = "legalpaper";
- string orient = "landscape";
- string fontsize = "11pt";
- const uint w = 296;
- const uint h = 166;
- const uint l = 30;
- const uint r = 20;
- const uint t = 30;
- const uint b = 30;
- string width = mm(w);
- string height = mm(h);
- string margin_left = mm(l);
- string margin_right = mm(r);
- string margin_top = mm(t);
- string margin_bottom = mm(b);
- uint img_px = 420;
- bool is_portrait = false;
- }
- return H();
- }
- }
- return Legal();
- }
- }
- return PaperType();
- }
-}
-template outputLaTeX() {
- import std.file;
- import std.outbuffer;
- import std.uri;
- import std.conv : to;
- import sisudoc.io_out;
- import sisudoc.io_out.rgx;
- import sisudoc.io_out.rgx_latex;
- mixin spineRgxOut;
- static auto rgx = RgxO();
- mixin spineRgxLSC;
- static auto rgx_sc = RgxLSC();
- mixin spineLanguageCodes;
- auto lang = Lang();
- auto paper = paperLaTeX;
- string sp_char_ops()(
- string _txt,
- ) {
- string _unescape_sp_char_esc()(string _txt) {
- _txt = _txt
- .replaceAll(rgx_sc.latex_special_char_escaped,
- format(q"┃%s┃", "$1"))
- .replaceAll(rgx_sc.latex_special_char_escaped_braced,
- format(q"┃%s┃", "$1"));
- return _txt;
- }
- string _unescape_fontface_esc()(string _txt) {
- _txt = _txt.replaceAll(rgx_sc.latex_identify_inline_fontface,
- format(q"┃%s%s┃", "$1", "$2"));
- return _txt;
- }
- _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx_sc.latex_special_char_for_escape);
- _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx_sc.latex_special_char_for_escape_and_braces);
- _txt = replaceAll!(m => "''")(_txt, rgx.quotes_open_and_close);
- _txt = replaceAll!(m => "$\\cdot$")(_txt, rgx.middle_dot);
- _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_link);
- _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_fontface);
- return _txt;
- }
- string sp_char_esc(O)(
- string _txt,
- const O obj,
- ) {
- if (obj.metainfo.is_a != "code") {
- _txt = _txt.sp_char_ops;
- }
- return _txt;
- }
- string sp_char_esc_txt()(
- string _txt,
- ) {
- _txt = _txt.sp_char_ops;
- return _txt;
- }
- string marked_linebreaks_newlines()(
- string _txt,
- ) {
- _txt = _txt.split(rgx.br_linebreaks_newlines).join("\\br\n").strip;
- // _txt = replaceAll!(m => "\\br " ~ m[1])(_txt, rgx.br_linebreaks_newlines);
- return _txt;
- }
- string fontface()(
- string _txt,
- ) {
- _txt = _txt
- .replaceAll(rgx.inline_emphasis, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1"))
- .replaceAll(rgx.inline_bold, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1"))
- .replaceAll(rgx.inline_italics, format(q"┃\emph{%s}┃", "$1"))
- .replaceAll(rgx.inline_italics, format(q"┃\uline{%s}┃", "$1"))
- .replaceAll(rgx.inline_superscript, format(q"┃$$^{%s}$$┃", "$1"))
- .replaceAll(rgx.inline_subscript, format(q"┃$$_{%s}$$┃", "$1"))
- .replaceAll(rgx.inline_strike, format(q"┃\sout{%s}┃", "$1"))
- .replaceAll(rgx.inline_insert, format(q"┃\uline{%s}┃", "$1"))
- .replaceAll(rgx.inline_mono, format(q"┃\begin{monosp}%s\end{monosp}┃", "$1"))
- .replaceAll(rgx.inline_italics, format(q"┃``%s''┃", "$1"));
- return _txt;
- }
- string leading_hardspaces()(
- string _txt,
- ) {
- string hardspaces(string _spaces) {
- _spaces = _spaces
- .replaceAll(rgx.space, "{\\s}");
- return _spaces;
- }
- _txt = replaceAll!(m => hardspaces(m[0]))(_txt, rgx.spaces_line_start);
- return _txt;
- }
- string nbsp_char()(string _txt) {
- if (_txt.match(rgx.nbsp_char)) {
- foreach (m; _txt.matchAll(rgx.nbsp_chars)) {
- int spaces_ = 0;
- foreach (n; m[0].matchAll(rgx.nbsp_char)) {
- spaces_ ++;
- }
- _txt = _txt.replaceFirst(rgx.nbsp_chars, "\\spaces{" ~ spaces_.to!string ~ "}");
- }
- }
- return _txt;
- }
- string spaces_to_nbsp()(string _txt) {
- if (_txt.match(rgx.spaces_keep)) {
- foreach (m; _txt.matchAll(rgx.spaces_keep)) {
- int spaces_ = 0;
- foreach (n; m[0].matchAll(rgx.space)) {
- spaces_ ++;
- }
- _txt = _txt.replaceFirst(rgx.spaces_keep, "\\spaces{" ~ spaces_.to!string ~ "}");
- }
- }
- return _txt;
- }
- string nbsp_char_to_space()(string _txt) {
- if (_txt.match(rgx.nbsp_char)) {
- _txt = _txt.replaceAll(rgx.nbsp_char, " ");
- }
- return _txt;
- }
- string links_and_images(O,M)(
- string _txt,
- const O obj,
- M doc_matters,
- ) {
- if (obj.has.inline_links) { // TODO some images do not have inline links ... image without link
- string _width_adjust(string _width) {
- if (_width.to!int > 300) { _width = "300"; } // will need to vary max with papersize & orientation
- return _width;
- }
- string _latex_image_path(string _image_path) {
- auto pth_latex = spinePathsLaTeX(doc_matters);
- _image_path = pth_latex.base_filename(doc_matters.src.filename) ~ "/" ~ _image_path;
- return _image_path;
- }
- string _if_images(string _linked_content) {
- if (_linked_content.match(rgx.inline_image_info)) {
- _linked_content = replaceAll!(m =>
- format(q"┃\includegraphics*[width=%spt]{%s}%s┃",
- _width_adjust(m[2]), _latex_image_path(m[1]), " \\br\n")
- )(_linked_content, rgx.inline_image_info);
- }
- return _linked_content;
- }
- string _check_link(string _link) {
- _link = _link
- .replaceFirst(rgx_sc.latex_clean_internal_link, "")
- .replaceAll(rgx_sc.latex_special_char_for_escape_url, "\\$1");
- return _link;
- }
- if (obj.metainfo.is_a != "code") {
- _txt = replaceAll!(m =>
- m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├"
- )(_txt, rgx.inline_link_number_only);
- _txt = replaceAll!(m =>
- ((m[1] == m[2]) && (m[2].match(rgx.uri))) // url link (regular link with url)
- ? format(q"┃\linkurl{%s}{%s}┃", _check_link(m[1]), (_check_link(m[1])).sp_char_esc_txt)
- : ((m[2].match(rgx.uri)) && (m[1].match(rgx.inline_image_info))) // linked image
- ? format(q"┃%s\href{%s}%s{%s}┃", "\\br ", _check_link(m[2]), "\n", _if_images(m[1])) // markup for images
- : (m[2].match(rgx.uri)) // not linked image
- ? format(q"┃%s\linktext{%s}{%s}┃", "\\br ", _check_link(m[2]), m[1]) // regular link with text
- : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1])) // internal links, like book index
- )(_txt, rgx.inline_link);
- }
- }
- return _txt;
- }
- string footnotes()(
- string _txt,
- ) {
- if (_txt.match(rgx.inline_notes_al_gen)) {
- string _tex_note = q"┃\hypertarget{noteref_%s}{}\footnote[%s]{%%
- \label{note_%s}%s}┃";
- _txt = _txt.split(rgx.br_linebreaks).join("\\br ").replaceAll(rgx.inline_notes_al_regular_number_note,
- format(_tex_note,
- "$1", "$1", "$1",
- "$2".strip
- ).strip
- );
- }
- return _txt;
- }
- string remove_footnotes()(
- string _txt,
- ) {
- if (_txt.match(rgx.inline_notes_al_gen)) {
- _txt = replaceAll!(m => "")(_txt, rgx.inline_notes_al_gen);
- }
- return _txt;
- }
- string para(O)(
- string _txt,
- O obj,
- ) {
- if (obj.metainfo.is_of_type == "para") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}%s┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.footnotes
- ).strip;
- }
- return _txt;
- }
- string bookindex(O)(
- string _txt,
- O obj,
- ) {
- if (obj.metainfo.is_of_type == "para"
- && obj.metainfo.is_a == "bookindex"
- ) {
- string _tex_para;
- _tex_para = q"┃%s┃";
- _txt = format(_tex_para,
- _txt.replaceAll(rgx_sc.latex_clean_bookindex_linebreak, "\n") ~ "\n\\brln\n"
- );
- }
- return _txt;
- }
- string heading(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- string paper_size_orientation,
- string _part = ""
- ) {
- struct latexMarks {
- string pg_break = "\\clearpage\n";
- }
- latexMarks manual_breaks(
- latexMarks _ltx,
- string test_for_break_level,
- ) {
- if ((!(doc_matters.conf_make_meta.make.breaks.empty)
- && (matchFirst(doc_matters.conf_make_meta.make.breaks, test_for_break_level)))
- ) { // manually override defaults
- if ((matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage))
- && (matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn))
- ) {
- if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage)) {
- if (matchFirst(m.captures["breakpage"], test_for_break_level)) {
- _ltx.pg_break = "\\clearpage\n";
- } else if (auto n = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn)) {
- if (matchFirst(n.captures["breakcolumn"], test_for_break_level)) {
- if ((paper_size_orientation == "a4.landscape")
- || (paper_size_orientation == "b4.landscape")
- || (paper_size_orientation == "a5.landscape")
- || (paper_size_orientation == "letter.landscape")
- || (paper_size_orientation == "legal.landscape")
- ) {
- _ltx.pg_break = "\\\\ \\columnbreak\n"; // "\\\\ \\newpage\n";
- } else { // portrait
- _ltx.pg_break = "\\clearpage\n";
- }
- }
- }
- }
- } else if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage)) {
- if (matchFirst(m.captures["breakpage"], test_for_break_level)) {
- _ltx.pg_break = "\\clearpage\n";
- }
- } else if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn)) {
- if (matchFirst(m.captures["breakcolumn"], test_for_break_level)) {
- if ((paper_size_orientation == "a4.landscape")
- || (paper_size_orientation == "b4.landscape")
- || (paper_size_orientation == "a5.landscape")
- || (paper_size_orientation == "letter.landscape")
- || (paper_size_orientation == "legal.landscape")
- ) {
- _ltx.pg_break = "\\\\ \\columnbreak\n"; // "\\\\ \\newpage\n";
- } else { // portrait
- _ltx.pg_break = "\\clearpage\n";
- }
- }
- }
- } else if (!(doc_matters.conf_make_meta.make.breaks.empty)) {
- _ltx.pg_break = "";
- }
- return _ltx;
- }
- if (obj.metainfo.is_a == "heading") {
- string _tex_para;
- latexMarks _ltx = latexMarks();
- string _pg_break;
- string _sect;
- string _post;
- string _title_add;
- string _columns = "";
- switch (obj.metainfo.heading_lev_markup) {
- case 0: // A == TITLE
- _pg_break = "\\begin{document}\n";
- goto default;
- case 1: // B == part: section heading level
- _pg_break = "\\clearpage\n";
- goto default;
- case 2: // C == part: section heading level
- _pg_break = "\\clearpage\n";
- goto default;
- case 3: // D == part: section heading level
- _pg_break = "\\clearpage\n";
- goto default;
- case 4: // 1 == section
- _columns = (_part != "bookindex")
- ? "" : "\n\\br\n\\begin{multicols}{2}";
- if (doc_matters.conf_make_meta.make.doc_type == "article") { // defaults for article
- _ltx.pg_break = "";
- } else if (doc_matters.conf_make_meta.make.doc_type == "book") { // defaults for book
- _ltx.pg_break = "\\clearpage\n";
- } else {
- _ltx.pg_break = "\\clearpage\n";
- }
- _ltx = manual_breaks(_ltx, "1");
- _pg_break = _ltx.pg_break;
- _sect = "section";
- _post = "";
- _title_add = format(q"┃
-\markboth{%s}{%s}┃",
- doc_matters.conf_make_meta.meta.title_full,
- doc_matters.conf_make_meta.meta.title_full,
- );
- goto default;
- case 5: // 2 == subsection
- _pg_break = "";
- // _pg_break = "newpage"; // doubt this is necessary
- _sect = "subsection";
- _post = " \\br\n";
- _title_add = "";
- goto default;
- case 6: // 3 == subsubsection
- _pg_break = "";
- // _pg_break = "newpage"; // doubt this is necessary
- _sect = "subsubsection";
- _post = " \\br\n";
- _title_add = "";
- goto default;
- case 7: // 4 == paragraph
- _pg_break = "";
- // _pg_break = "newpage"; // doubt this is necessary
- _sect = "paragraph";
- _post = " \\br\n";
- _title_add = "";
- goto default;
- case 8: // 5 == subparagraph
- _pg_break = "";
- // _pg_break = "newpage"; // doubt this is necessary
- _sect = "subparagraph";
- _post = " \\br\n";
- _title_add = "";
- goto default;
- default:
- if (obj.metainfo.heading_lev_markup == 0) {
- _tex_para = q"┃
-\begin{document}
-\thispagestyle{empty}
-\title{%s%s}
-\author{ \textnormal{%s}}
-\date{\begin{tiny}%s\end{tiny}}
-\maketitle
-\addcontentsline{toc}{part}{%s}
-\newpage
-\pagestyle{fancy}
-\pagenumbering{alph}
-\setcounter{page}{1}
-\markboth{%s}{%s}
-\br\linebreak Copyright \begin{small}\copyright\end{small} %s \br\linebreak
-%s
-\clearpage┃";
- _txt = format(_tex_para,
- (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,
- doc_matters.conf_make_meta.meta.title_subtitle.empty ? ""
- : " \\\\ - \\\\ " ~ (doc_matters.conf_make_meta.meta.title_subtitle).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.date_published).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.rights_copyright).sp_char_esc_txt.marked_linebreaks_newlines,
- (doc_matters.conf_make_meta.meta.rights_license).sp_char_esc_txt.marked_linebreaks_newlines,
- );
- } else if (obj.metainfo.heading_lev_markup < 4) {
- if (!(_txt.footnotes.strip == "Endnotes")) {
- _tex_para = q"┃%s\part*{\ocn{%s}%s}
-\addcontentsline{toc}{part}{%s}
-\markboth{%s}┃";
- _txt = format(_tex_para,
- _pg_break,
- obj.metainfo.object_number,
- _txt.strip.footnotes,
- _txt.strip.remove_footnotes,
- (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,
- );
- }
- } else if (obj.metainfo.heading_lev_markup > 3) {
- if (obj.metainfo.heading_lev_markup == 4
- && _txt.match(regex(r"^Table of Contents$"))) {
- _tex_para = q"┃
-\pagenumbering{arabic}
-\setcounter{page}{1}
-\markboth{ }{ }
-\part*{\ocn{1}%s \newline %s}
-
-\clearpage
-\pagenumbering{roman}
-\setcounter{page}{1}
-\renewcommand{\contentsname}{}
-\tableofcontents
-
-\clearpage
-\pagenumbering{arabic}
-\setcounter{page}{2}
-\clearpage
-\markboth{%s}{%s}
-%% \null
-\clearpage
-\setcounter{page}{2}┃";
- _txt = format(_tex_para,
- (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt,
- (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt,
- );
- } else if (obj.metainfo.heading_lev_markup == 4
- && _part == "bookindex"
- && _txt.match(regex(r"^Index$"))
- ) {
- _tex_para = q"┃%s\%s*{\ocn{%s}%s}
-\addcontentsline{toc}{%s}{%s%s}%s%s┃";
- _txt = format(_tex_para,
- _pg_break,
- _sect.strip,
- obj.metainfo.object_number,
- _txt.footnotes.strip,
- _sect,
- _txt.remove_footnotes.strip,
- _post,
- _title_add,
- _columns,
- );
- } else if (obj.metainfo.dummy_heading
- && obj.metainfo.heading_lev_markup == 4
- ) { /+ dummy headings completely omitted +/
- _txt = "";
- } else {
- _tex_para = q"┃%s\%s*{\ocn{%s}%s}
-\addcontentsline{toc}{%s}{%s%s}%s┃";
- _txt = format(_tex_para,
- _pg_break,
- _sect.strip,
- obj.metainfo.object_number,
- _txt.footnotes.strip,
- _sect,
- _txt.remove_footnotes.strip,
- _post,
- _title_add,
- );
- }
- }
- break;
- }
- }
- return _txt.strip;
- }
- string quote(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- ) {
- if (obj.metainfo.is_a == "quote") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\objBlockOpen
-"%s"
-\objBlockClose
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip
- ).strip;
- }
- return _txt;
- }
- string group(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- ) {
- if (obj.metainfo.is_a == "group") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\objGroupOpen
-%s
-\objGroupClose
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.footnotes.split(rgx.br_line_spaced).join(" \\brl{1} ").strip // provides more control (more noise, not as tidy)
- // _txt.footnotes.split(rgx.br_line_spaced).join("") // this works using a line-space, looks tidy, keep ref.
- ).strip;
- }
- return _txt;
- }
- string block(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- ) {
- if (obj.metainfo.is_a == "block") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\objBlockOpen
-%s
-\objBlockClose
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip
- ).strip;
- }
- return _txt;
- }
- string verse(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- ) {
- if (obj.metainfo.is_a == "verse") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\objPoemVerseOpen
-%s
-\objPoemVerseClose
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.spaces_to_nbsp.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip
- ).strip;
- }
- return _txt;
- }
- string codeblock(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- ) {
- if (obj.metainfo.is_a == "code") {
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\begin{objCodeBlock}\begin{lstlisting}
-%s
-\end{lstlisting}\end{objCodeBlock}
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _txt.nbsp_char_to_space
- ).strip;
- }
- return _txt;
- }
- auto tablarize(O)(
- string _txt,
- const O obj,
- ) {
- string[] _table_rows = (_txt).split(rgx.table_delimiter_row);
- string[] _table_cols;
- string _table;
- string _tablenote;
- foreach(row_idx, row; _table_rows) {
- _table_cols = row.split(rgx.table_delimiter_col);
- _table ~= "";
- foreach(col_idx, cell; _table_cols) {
- if ((_table_cols.length == 1)
- && (_table_rows.length <= row_idx+2)) { // check row_idx+2 (rather than == ++row_idx)
- _tablenote ~= cell;
- } else {
- // // _table ~= "\\bfseries ";
- // _table ~= cell;
- // _table ~= (_table_cols.length > (col_idx + 1)) ? "&" : "";
- _table ~= format(q"┃%s%s┃",
- cell,
- (_table_cols.length > (col_idx + 1)) ? "&" : ""
- );
- }
- }
- _table ~= "\\\\";
- }
- Tuple!(string, string) t = tuple(
- _table,
- _tablenote,
- );
- return t;
- }
- string table(O,M)(
- string _txt,
- O obj,
- M doc_matters,
- string paper_size_orientation,
- ) {
- if (obj.metainfo.is_a == "table") {
- auto _t = _txt.tablarize(obj);
- string _table = _t[0];
- string _t_n = _t[1];
- uint pw = 0;
- switch (paper_size_orientation) {
- case "a4.portrait": pw = (paper.a4.portrait.w - 20); break;
- case "a4.landscape": pw = (paper.a4.landscape.w - 20); break;
- case "b4.portrait": pw = (paper.b4.portrait.w - 20); break;
- case "b4.landscape": pw = (paper.b4.landscape.w - 20); break;
- case "a5.portrait": pw = (paper.a5.portrait.w - 20); break;
- case "a5.landscape": pw = (paper.a5.landscape.w - 20); break;
- case "letter.portrait": pw = (paper.letter.portrait.w - 20); break;
- case "letter.landscape": pw = (paper.letter.landscape.w - 20); break;
- case "legal.portrait": pw = (paper.legal.portrait.w - 20); break;
- case "legal.landscape": pw = (paper.legal.landscape.w - 20); break;
- default: pw = 0; break;
- }
- // auto textwidth = (pw - 24);
- string _colw = "";
- foreach (w; obj.table.column_widths) {
- _colw ~= format(q"┃p{%.0fmm}┃",
- (w * pw / 100)
- // (w * (pw - 24)/ 100)
- // (w * textwidth / 100)
- );
- }
- string _tex_para;
- _tex_para = q"┃\ocn{%s}\objTableOpen{%s}
-%s
-\objTableClose
-┃";
- _txt = format(_tex_para,
- obj.metainfo.object_number,
- _colw,
- _table,
- ).strip;
- }
- return _txt;
- }
- string bullets_and_indentation(O)(
- string _txt,
- O obj,
- ) {
- string _tex_para;
- string _hang; string _indent;
- int _paper_margin = -10;
- int _indent_increment = 8; // 5; 10;
- if (obj.attrib.bullet) {
- int _bullet_space = 5;
- _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin + _bullet_space).to!string;
- _txt = format(q"┃\begin{Bullet}{%smm}%s\end{Bullet}┃",
- _indent,
- _txt.footnotes
- ).strip;
- } else if (
- obj.attrib.indent_base != 0
- && obj.attrib.indent_base == obj.attrib.indent_hang
- ) {
- _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string;
- _tex_para = q"┃\begin{ParagraphIndent}{%smm}%s \end{ParagraphIndent}┃";
- _txt = format(_tex_para,
- _indent,
- _txt.footnotes
- ).strip;
- } else if (
- obj.attrib.indent_base != 0
- || obj.attrib.indent_hang != 0
- ) {
- _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string;
- _hang = (((obj.attrib.indent_hang - obj.attrib.indent_base) * _indent_increment)).to!string;
- _tex_para = q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃";
- _txt = format(_tex_para,
- _indent, _hang,
- _txt.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n")
- ).strip;
- }
- return _txt;
- }
- string latex_head(M)(
- M doc_matters,
- string paper_size_orientation,
- ) {
- struct paperTypeLatex {
- string a4_portrait;
- string a4_landscape;
- string b4_portrait;
- string b4_landscape;
- string a5_portrait;
- string a5_landscape;
- string us_letter_portrait;
- string us_letter_landscape;
- string us_legal_portrait;
- string us_legal_landscape;
- }
- auto paper_type_latex = paperTypeLatex();
- string _footer(M)(M doc_matters) {
- string _ft = "\\lfoot[\\textrm{\\thepage}]";
- string _ft_1 = format(q"┃{\tiny \href{%s}{%s}}┃", "https://sisudoc.org", "SiSU",);
- string _ft_2 = format(q"┃
- \cfoot{\href{%s}{%s}}┃", "https://git.sisudoc.org", "git",);
- if (doc_matters.conf_make_meta.make.footer.length > 0) {
- if (doc_matters.conf_make_meta.make.footer[0].matchAll(rgx.inline_link)) {
- _ft ~= doc_matters.conf_make_meta.make.footer[0]
- .replace(rgx.inline_link, "{\\tiny \\href{$2}{$1}}");
- } else {
- _ft ~= _ft_1;
- }
- if (doc_matters.conf_make_meta.make.footer.length > 1) {
- if (doc_matters.conf_make_meta.make.footer[1].matchAll(rgx.inline_link)) {
- _ft ~= doc_matters.conf_make_meta.make.footer[1]
- .replace(rgx.inline_link, "\n\\cfoot{\\href{$2}{$1}}");
- } else {
- _ft ~= _ft_2;
- }
- }
- } else {
- _ft ~= _ft_1;
- _ft ~= _ft_2;
- }
- return _ft;
- }
- struct paperMargins {
- string portrait;
- string landscape;
- }
- auto margins = paperMargins();
- struct columnsMulti {
- string portrait;
- string landscape;
- }
- auto multicol = columnsMulti();
- multicol.landscape = "";
- struct colorLinks {
- string mono;
- string color;
- }
- auto links = colorLinks();
- links.mono = format(q"┃
- colorlinks=true,
- urlcolor=black,
- filecolor=black,
- linkcolor=black,
- citecolor=black,
-┃",
- );
- links.color = format(q"┃
- colorlinks=true,
- urlcolor=myblue, %% \href{...}{...} external url
- filecolor=mygreen, %% \href{...} local file
- linkcolor=myred, %% \href{...} and \pageref{...}
- citecolor=black,
-┃",
- );
- string set_paper(P)(P paper_set,) {
- string paper_type_description;
- if (paper_set.is_portrait) {
- paper_type_description = format(q"┃
-\documentclass[%s,%s,titlepage,makeidx]{scrartcl}
-\usepackage{%s}
-\usepackage[%s,%s]{babel}
-\usepackage[autostyle, english = american]{csquotes}
-%% \MakeOuterQuote{"} %% not required, using '' as quote delimiter
-\selectlanguage{%s}
-\hypersetup{
- pdftitle={%s},
- pdfauthor={%s},
- pdfsubject={%s},
-}
-\usepackage{fancyhdr}
-\lhead[ ]{ }
-\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark }
-\rhead[ ]{ }
-%s
-\rfoot[\tiny \href{}{}]{\textrm{\thepage}}
- ┃",
- paper_set.fontsize,
- paper_set.papersize,
- "./sty/" ~ paper_set.stylesheet,
- lang.codes[doc_matters.src.language]["xlp"],
- "english",
- lang.codes[doc_matters.src.language]["xlp"],
- doc_matters.conf_make_meta.meta.title_full.strip,
- doc_matters.conf_make_meta.meta.creator_author.strip,
- doc_matters.conf_make_meta.meta.classify_subject.strip,
- _footer(doc_matters),
- );
- } else {
- paper_type_description = format(q"┃
-\documentclass[%s,%s,landscape,titlepage,twocolumn,makeidx]{scrartcl}
-\usepackage{%s}
-\usepackage[english]{babel}
-%% \usepackage{polyglossia}
-\setmainlanguage{%s}
-\setotherlanguage{%s}
-\selectlanguage{%s}
-\hypersetup{
- pdftitle={%s},
- pdfauthor={%s},
- pdfsubject={%s},
-}
-\usepackage{fancyhdr}
-\lhead[ ]{ }
-\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark }
-\rhead[ ]{ }
-%s
-\rfoot[\tiny \href{}{}]{\textrm{\thepage}}
- ┃",
- paper_set.fontsize,
- paper_set.papersize,
- "./sty/" ~ paper_set.stylesheet,
- lang.codes[doc_matters.src.language]["xlp"],
- "english",
- lang.codes[doc_matters.src.language]["xlp"],
- doc_matters.conf_make_meta.meta.title_full.strip,
- doc_matters.conf_make_meta.meta.creator_author.strip,
- doc_matters.conf_make_meta.meta.classify_subject.strip,
- _footer(doc_matters),
- );
- }
- return paper_type_description;
- }
- string paper_size_orientation_latex;
- switch (paper_size_orientation) {
- case "a4.portrait": paper_size_orientation_latex = set_paper(paper.a4.portrait); break;
- case "a4.landscape": paper_size_orientation_latex = set_paper(paper.a4.landscape); break;
- case "b4.portrait": paper_size_orientation_latex = set_paper(paper.b4.portrait); break;
- case "b4.landscape": paper_size_orientation_latex = set_paper(paper.b4.landscape); break;
- case "a5.portrait": paper_size_orientation_latex = set_paper(paper.a5.portrait); break;
- case "a5.landscape": paper_size_orientation_latex = set_paper(paper.a5.landscape); break;
- case "letter.portrait": paper_size_orientation_latex = set_paper(paper.letter.portrait); break;
- case "letter.landscape": paper_size_orientation_latex = set_paper(paper.letter.landscape); break;
- case "legal.portrait": paper_size_orientation_latex = set_paper(paper.legal.portrait); break;
- case "legal.landscape": paper_size_orientation_latex = set_paper(paper.legal.landscape); break;
- default: paper_size_orientation_latex = paper_type_latex.a4_portrait;
- }
- string links_mono_or_color_set = links.mono.strip;
- if (
- (doc_matters.opt.action.latex_color_links)
- || (paper_size_orientation ==
- "a4.landscape" ||
- "a5.landscape" ||
- "b4.landscape" ||
- "letter.landscape" ||
- "legal.landscape")
- ){
- links_mono_or_color_set = links.mono.strip;
- }
- string _latex_head = format(q"┃%%%% spine LaTeX output%s%s
-%%%% %s %s
-%s
-%s
- ┃",
- doc_matters.opt.action.generated_by ? " " ~ doc_matters.generator_program.name_version_and_compiler : "",
- doc_matters.opt.action.generated_by ? " (generated " ~ doc_matters.generator_program.time_output_generated ~ ")" : "",
- doc_matters.generator_program.project_name.strip,
- doc_matters.generator_program.url_home.strip,
- paper_size_orientation_latex.strip,
- margins.portrait.strip,
- );
- return _latex_head.strip;
- }
- string latex_body(D,M)(
- const D doc_abstraction,
- M doc_matters,
- string paper_size_orientation,
- ) {
- string _latex_body = "";
- bool _multicolumns = false;
- string _txt;
- foreach (part; doc_matters.has.keys_seq.latex) {
- foreach (obj; doc_abstraction[part]) {
- switch (obj.metainfo.is_of_part) {
- case "frontmatter": assert(part == "head" || "toc");
- _txt = obj.text
- .sp_char_esc(obj)
- .fontface;
- switch (obj.metainfo.is_of_type) {
- case "para":
- switch (obj.metainfo.is_a) {
- case "heading":
- _txt = _txt.heading(obj, doc_matters, paper_size_orientation);
- goto default;
- case "toc":
- break;
- default:
- _latex_body ~= _txt ~ "\n\n";
- _txt = "";
- break;
- }
- break;
- default: break;
- }
- break;
- case "body": assert(part == "body" || "head"); // surprise
- _txt = obj.text
- .sp_char_esc(obj)
- .fontface;
- switch (obj.metainfo.is_of_type) {
- case "para":
- switch (obj.metainfo.is_a) {
- case "heading":
- _txt = _txt.heading(obj, doc_matters, paper_size_orientation);
- goto default;
- case "para":
- _txt = _txt.para(obj)
- .bullets_and_indentation(obj)
- .links_and_images(obj, doc_matters);
- goto default;
- default:
- _latex_body ~= _txt ~ "\n\n";
- _txt = "";
- break;
- }
- break;
- case "block":
- switch (obj.metainfo.is_a) {
- case "quote":
- _txt = _txt.quote(obj, doc_matters)
- .links_and_images(obj, doc_matters);
- goto default;
- case "group": /+ (hardspaces not honored) [remove any hardspace marker] +/
- _txt = _txt.group(obj, doc_matters)
- .links_and_images(obj, doc_matters);
- goto default;
- case "block": /+ (hardspace honored) \hardspace +/
- _txt = _txt.block(obj, doc_matters)
- .links_and_images(obj, doc_matters);
- goto default;
- case "verse": /+ (hardspace honored) \hardspace +/
- _txt = _txt.verse(obj, doc_matters)
- .links_and_images(obj, doc_matters);
- goto default;
- case "code": /+ (hardspace honored) \begin{lstlisting} clear hardspace marker +/
- _txt = _txt.codeblock(obj, doc_matters);
- goto default;
- case "table":
- _txt = _txt.table(obj, doc_matters, paper_size_orientation);
- goto default; // TODO
- default:
- _latex_body ~= _txt ~ "\n\n";
- _txt = "";
- break;
- }
- break;
- default: break;
- }
- break;
- case "backmatter":
- assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail");
- _txt = obj.text
- .sp_char_esc(obj)
- .fontface;
- switch (obj.metainfo.is_of_type) {
- case "para":
- if (part != "bookindex" && _multicolumns) {
- _multicolumns = false;
- _latex_body ~= "\n\\end{multicols}\n";
- }
- switch (obj.metainfo.is_a) {
- case "heading":
- if (part == "bookindex") {
- _multicolumns = true;
- }
- _txt = _txt.heading(obj, doc_matters, paper_size_orientation, part);
- goto default;
- case "endnote": assert(part == "endnotes");
- /* uncomment code to reinstate endnotes in endnote section */
- // _txt = _txt.para(obj)
- // .bullets_and_indentation(obj)
- // .links_and_images(obj, doc_matters);
- // goto default;
- break;
- case "glossary": assert(part == "glossary");
- _txt = _txt.para(obj)
- .bullets_and_indentation(obj)
- .links_and_images(obj, doc_matters);
- goto default;
- case "bibliography": assert(part == "bibliography");
- _txt = _txt.para(obj)
- .bullets_and_indentation(obj);
- goto default;
- case "bookindex": assert(part == "bookindex");
- /+ two column, special section +/
- _txt = _txt.bookindex(obj)
- .links_and_images(obj, doc_matters);
- goto default;
- case "blurb": assert(part == "blurb");
- _txt = _txt.para(obj)
- .bullets_and_indentation(obj)
- .links_and_images(obj, doc_matters);
- goto default;
- default:
- _latex_body ~= (part == "bookindex" && obj.metainfo.is_a != "heading")
- ? _txt : (_txt ~ "\n\n");
- _txt = "";
- break;
- }
- break;
- default: break;
- }
- break;
- case "comment":
- break;
- default:
- { /+ debug +/
- if (doc_matters.opt.action.debug_do_latex
- && doc_matters.opt.action.vox_gt_2) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part);
- writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
- writeln(__FILE__, ":", __LINE__, ": ", obj.text);
- }
- }
- break;
- }
- }
- }
- if (_multicolumns) {
- _multicolumns = false;
- _latex_body ~= "\n\\end{multicols}\n";
- }
- return _latex_body;
- }
- string latex_tail(M)(
- M doc_matters,
- string paper_size_orientation,
- ) {
- string _latex_tail = format(q"┃
-
-\end{document}
- ┃",
- // doc_matters.conf_make_meta.meta.title_full,
- // doc_matters.conf_make_meta.meta.creator_author,
- );
- return _latex_tail;
- }
- void writeOutputLaTeX(T,M)(
- const T latex_content,
- M doc_matters,
- string paper_size_orientation,
- ) {
- auto pth_latex = spinePathsLaTeX(doc_matters);
- try {
- { /+ debug +/
- if (doc_matters.opt.action.debug_do_latex
- && doc_matters.opt.action.vox_gt_2) {
- writeln(latex_content.head);
- writeln(latex_content.content);
- writeln(latex_content.tail);
- }
- }
- if (!exists(pth_latex.latex_path_stuff)) {
- (pth_latex.latex_path_stuff).mkdirRecurse;
- }
- if (doc_matters.opt.action.vox_gt_1) {
- writeln(" ", pth_latex.latex_file_with_path(paper_size_orientation));
- }
- {
- auto f = File(pth_latex.latex_file_with_path(paper_size_orientation), "w");
- f.writeln(latex_content.head);
- f.writeln(latex_content.content);
- f.writeln(latex_content.tail);
- foreach (image; doc_matters.srcs.image_list) {
- string fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image;
- string fn_src_out_file = pth_latex.latex_path_stuff ~ "/" ~ image;
- if (exists(fn_src_in)) {
- fn_src_in.copy(fn_src_out_file);
- }
- }
- }
- if (!exists(pth_latex.latex_path_stuff ~ "/index.html")) {
- import sisudoc.io_out.html_snippet;
- mixin htmlSnippet;
- auto f = File(pth_latex.latex_path_stuff ~"/index.html", "w");
- f.writeln(format_html_blank_page_guide_home(
- "../../css/html_scroll.css",
- (doc_matters.opt.action.webserver_url_doc_root.length > 0)
- ? doc_matters.opt.action.webserver_url_doc_root
- : doc_matters.conf_make_meta.conf.w_srv_data_root_url
- ,
- "../../index.html",
- ));
- }
- // should be in latex init and done just once, doc_matters not passed there though
- if (!exists(pth_latex.base ~ "/index.html")) {
- import sisudoc.io_out.html_snippet;
- mixin htmlSnippet;
- auto f = File(pth_latex.base ~"/index.html", "w");
- f.writeln(format_html_blank_page_guide_home(
- "../css/html_scroll.css",
- (doc_matters.opt.action.webserver_url_doc_root.length > 0)
- ? doc_matters.opt.action.webserver_url_doc_root
- : doc_matters.conf_make_meta.conf.w_srv_data_root_url,
- "../index.html",
- ));
- }
- if (!exists(pth_latex.base_sty ~ "/index.html")) {
- import sisudoc.io_out.html_snippet;
- mixin htmlSnippet;
- auto f = File(pth_latex.base_sty ~"/index.html", "w");
- f.writeln(format_html_blank_page_guide_home(
- "../../css/html_scroll.css",
- (doc_matters.opt.action.webserver_url_doc_root.length > 0)
- ? doc_matters.opt.action.webserver_url_doc_root
- : doc_matters.conf_make_meta.conf.w_srv_data_root_url,
- "../../index.html",
- ));
- }
- } catch (ErrnoException ex) {
- // handle error
- }
- }
- void outputLaTeX(D,M)(
- const D doc_abstraction,
- M doc_matters,
- ) {
- struct LaTeX {
- string head;
- string content;
- string tail;
- }
- LaTeX latex = LaTeX();
- foreach (paper_size_orientation; doc_matters.conf_make_meta.conf.set_papersize) {
- latex.head = latex_head(doc_matters, paper_size_orientation);
- latex.content = latex_body(doc_abstraction, doc_matters, paper_size_orientation);
- latex.tail = latex_tail(doc_matters, paper_size_orientation);
- latex.writeOutputLaTeX(doc_matters, paper_size_orientation);
- }
- }
-}
-template outputLaTeXstyInit() {
- import sisudoc.io_out;
- auto paper = paperLaTeX;
- void writeOutputLaTeXstyStatic(
- string latex_sty,
- string output_dir,
- string filename,
- ) {
- if ((output_dir.length > 0)
- && isValidPath(output_dir)
- ) {
- auto pth_latex = spinePathsLaTeXsty(output_dir);
- try {
- import std.file;
- if (!exists(pth_latex.base_sty)) {
- (pth_latex.base_sty).mkdirRecurse;
- }
- {
- auto f = File(pth_latex.latex_document_header_sty(filename), "w");
- f.writeln(latex_sty);
- }
- } catch (ErrnoException ex) {
- // handle error
- }
- }
- }
- void outputLaTeXstyInit()(
- string output_dir,
- bool generated_by,
- string name_version_and_compiler,
- string time_output_generated,
- ) {
- string latex_sty = outputLaTeXstyStatic!()(generated_by, name_version_and_compiler, time_output_generated);
- latex_sty.writeOutputLaTeXstyStatic(output_dir, "spineShared.sty");
- auto sty_a4p = paper.a4.portrait;
- auto latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4p, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4p.stylesheet ~ ".sty");
- auto sty_a4l = paper.a4.landscape;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4l, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4l.stylesheet ~ ".sty");
- auto sty_b4p = paper.b4.portrait;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4p, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4p.stylesheet ~ ".sty");
- auto sty_b4l = paper.b4.landscape;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4l, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4l.stylesheet ~ ".sty");
- auto sty_a5p = paper.a5.portrait;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5p, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5p.stylesheet ~ ".sty");
- auto sty_a5l = paper.a5.landscape;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5l, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5l.stylesheet ~ ".sty");
- auto sty_letter_p = paper.letter.portrait;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_p, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_p.stylesheet ~ ".sty");
- auto sty_letter_l = paper.letter.landscape;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_l, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_l.stylesheet ~ ".sty");
- auto sty_legal_p = paper.legal.portrait;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_p, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_p.stylesheet ~ ".sty");
- auto sty_legal_l = paper.legal.landscape;
- latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_l, generated_by, name_version_and_compiler, time_output_generated);
- latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_l.stylesheet ~ ".sty");
- }
-}
-template outputLaTeXstyStatic() {
- import std.format;
- import std.conv : to;
- string outputLaTeXstyStatic(
- bool generated_by,
- string name_version_and_compiler,
- string time_output_generated,
- ) {
- string latex_sty = format(q"┃%%%% spine LaTeX output%s%s
-%% - called by the .sty containing the paper dimensions (size and orientation) to be used
-%% - spineShared.sty used by all spine documents (called indirectly)
-\ProvidesPackage{./sty/spineShared}
-\usepackage{multicol}
-\setlength{\marginparsep}{4mm}
-\setlength{\marginparwidth}{8mm}
-\usepackage{dejavu}
-\renewcommand*\familydefault{\sfdefault}
-\usepackage{inconsolata}
-\usepackage[T1]{fontenc}
-\usepackage{newunicodechar}
-%% \usepackage[utf8]{inputenc}
-\usepackage{alltt}
-\PassOptionsToPackage{hyphens}{url}
-\usepackage[
- unicode=true,
- pdfusetitle,
- pdfsubject={},
- pdfkeywords={}, %% keywords list {} {} {},
- pdftoolbar=true,
- pdfmenubar=true,
- pdfwindowui=true,
- pdffitwindow=false, %% window fit to page when opened
- pdfstartview={FitH}, %% fits the width of the page to the window
- pdfnewwindow=true, %% links in new window
- pdfborder={0 0 1},
- plainpages=false, %% was true
- bookmarks=true,
- bookmarksopen=false,
- bookmarksnumbered=false,
- backref=false,
- breaklinks=true,
- colorlinks=true,
- urlcolor=black,
- filecolor=black,
- linkcolor=black,
- citecolor=black, %% links_mono_or_color_set
-]{hyperref}
-\usepackage{xurl}
-%% \PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
-\usepackage[usenames]{color}
-\definecolor{myblack}{rgb}{0,0,0}
-\definecolor{myred}{rgb}{0.75,0,0}
-\definecolor{mygreen}{rgb}{0,0.5,0}
-\definecolor{myblue}{rgb}{0,0,0.5}
-\definecolor{mywhite}{rgb}{1,1,1}
-\usepackage{textcomp}
-\usepackage[parfill]{parskip}
-\usepackage[normalem]{ulem}
-\usepackage{soul}
-\usepackage{longtable}
-\usepackage{graphicx}
-\usepackage[tc]{titlepic}
-\usepackage{amssymb}
-\usepackage{amsmath}
-\usepackage[cm]{sfmath}
-\usepackage{underscore}
-\usepackage{listings}
-\setcounter{secnumdepth}{2}
-\setcounter{tocdepth}{4}
-\usepackage{bookmark}
-\usepackage{microtype}
-\makeatletter
-\usepackage[multiple,ragged]{footmisc}
-\setlength\footnotemargin{12pt}
-\usepackage[para]{manyfoot}
-\DeclareNewFootnote{A}
-\makeatother
-\chardef\txtbullet="2022
-\chardef\tilde="7E
-\def\asterisk{{\rm \char42} }
-\definecolor{Light}{gray}{.92}
-\definecolor{listinggray}{gray}{0.9}
-\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
-\lstset{
- backgroundcolor=\color{lbcolor},
- tabsize=4,
- rulecolor=,
- language=,
- basicstyle={\ttfamily\scriptsize},
- upquote=true,
- columns=fixed,
- showstringspaces=false,
- extendedchars=true,
- breaklines=true,
- prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
- frame=single,
- showtabs=false,
- showspaces=false,
- showstringspaces=false,
- identifierstyle=\ttfamily,
- keywordstyle=\color[rgb]{0,0,1},
- commentstyle=\color[rgb]{0.133,0.545,0.133},
- stringstyle=\color[rgb]{0.627,0.126,0.941},
-}
-\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part}
-\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section}
-\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph}
-\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph}
-\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection}
-\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection}
-\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph}
-\newenvironment{ParagraphIndent}[1]{%%
- \begin{list}{}{%%
- \setlength\topsep{0pt}%%
- \addtolength{\leftmargin}{#1}
- \setlength\parsep{0pt plus 1pt}%%
- }
- \item[]
-} {\end{list}}
-\newenvironment{ParagraphHang}[2]{%%
- \begin{list}{}{%%
- \setlength\topsep{0pt}%%
- \addtolength{\leftmargin}{#1}
- \itemindent=#2
- \setlength\parsep{0pt plus 1pt}%%
- }
- \item[]
-} {\end{list}}
-\newenvironment{Bullet}[1]{%%
- \begin{list}{}{%%
- \setlength\topsep{0pt}%%
- \addtolength{\leftmargin}{#1}
- \itemindent=-1em
- \setlength\parsep{0pt plus 1pt}%%
- }
- \item[]
- $\txtbullet$\hspace{\enspace}
-} {\end{list}}
-\newcommand{\monosp}[1]{\normaltext\ttfamily\texbackslash#1}
-\newcommand{\br}{\hfill\break}
-\newcommand{\brl}[1]{%%
- \ifx&%%
- \hfill\break
- \else
- \vspace{#1ex}
- \fi
-}
-\newcommand{\brln}{\hspace*{\fill}\linebreak}
-\newcommand{\objBlockOpen}{%%
- \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}\raggedright
- \begin{footnotesize}
-}
-\newcommand{\objBlockClose}{%%
- \end{footnotesize}
- \setlength{\parskip}{1ex plus0.5ex minus0.2ex}
-}
-\newcommand{\objGroupOpen}{%%
- \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}
- \begin{footnotesize}
-}
-\newcommand{\objGroupClose}{%%
- \end{footnotesize}
-}
-\newcommand{\objPoemVerseOpen}{%%
- \setlength{\parskip}{0.1ex plus0.1ex minus0.1ex}
- \begin{footnotesize}
-
-}
-\newcommand{\objPoemVerseClose}{%%
-
- \end{footnotesize}
- \setlength{\parskip}{1ex plus0.5ex minus0.2ex}
- \linebreak
-}
-\newcommand{\parasep}{%%
- \smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br
-}
-\newcommand{\spaces}[1]{{\hspace*{#1ex}}}
-\newcommand{\s}{\hspace*{1ex}}
-\newcommand{\hardspace}{\hspace*{1ex}}
-\renewcommand{\-}{\hspace*{1ex}}
-\newcommand{\caret}{{\^{~}}}
-\newcommand{\pipe}{{\textbar}}
-\newcommand{\curlyOpen}{{}
-\newcommand{\curlyClose}{}}
-\newcommand{\lt}{{UseTextSymbol{OML}{<}}}
-\newcommand{\gt}{{UseTextSymbol{OML}{>}}}
-\renewcommand{\slash}{{/}}
-\newcommand{\underscore}{\_}
-\newcommand{\exclaim}{\Verbatim{!}}
-\newcommand{\linktext}[2]{%%
- {\href{#1}
- {\;\ulcorner\,\textup{{#2}}\,\lrcorner}}
-}
-\newcommand{\linkurl}[2]{%%
- \;{\href{#1}
- {\;\scriptsize\ttfamily\ulcorner\,\textup{{#2}}\,\lrcorner}}
-}
-\newcommand{\link}[2]{%%
- {\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1}
- {\;\ulcorner\,{#2}\,\lrcorner}\end{scriptsize}}
-}
-\newcommand{\objCodeBlock}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1}
-\newcommand{\objCodeOpen}{%%
- \normaltext\raggedright\small\ttfamily\texbackslash
- \begin{lstlisting}
-}
-\newcommand{\objCodeClose}{%%
- \end{lstlisting}
-}
-\newcommand{\ocn}[1]{%%
- \setlength{\parindent}{0em}
- \ifx&%% #1 is empty
- \hspace{-0.5ex}{\marginpar{\begin{tiny}\end{tiny}}}
- \else%% #1 is nonempty
- \hspace{-0.5ex}{\marginpar{\begin{tiny}\hspace{0em}\hypertarget{#1}{#1}\end{tiny}}}
- \fi
-}
-\newcommand{\ocnhold}[1]{%%
- \begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}}
-}
-\newcommand{\objCodeBlockHold}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1}
-\newcommand{\objTableOpen}[1]{%%
- \setlength{\LTleft}{0pt}
- \setlength{\LTright}{\fill}
- \begin{tiny}
- \begin{longtable}{#1}
-}
-\newcommand{\objTableClose}{%%
- \end{longtable}
- \end{tiny}
-}
-\tolerance=200
-\clubpenalty=150
-\widowpenalty=150
-\setlength{\emergencystretch}{3em}
-%% \usepackage{atbegshi} %% http://ctan.org/pkg/atbegshi %% (BUG tmp FIX deal with problem, remove first page which is blank)
-%% \AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}} %% (BUG tmp FIX deal with problem, remove first page which is blank)
-┃",
- generated_by ? " " ~ name_version_and_compiler : "",
- generated_by ? " (generated " ~ time_output_generated ~ ")" : "",
-);
- return latex_sty;
- }
-}
-template outputLaTeXstyPaperSizeAndOrientation() {
- import std.format;
- import std.conv : to;
- auto outputLaTeXstyPaperSizeAndOrientation(P)(
- P doc_sty_info,
- bool generated_by,
- string name_version_and_compiler,
- string time_output_generated,
- ) {
- string latex_sty = format(q"┃%%%% spine LaTeX output%s%s
-%% - called by .tex document to set paper dimensions (size and orientation)
-%% - calls spineShared.sty used/shared by all spine documents
-\ProvidesPackage{./sty/%s}
-\usepackage{geometry}
-\geometry{
- %s,
- %s,
- left=%s,
- right=%s,
- top=%s,
- bottom=%s,
-}
-\usepackage{./sty/spineShared}┃",
- generated_by ? " " ~ name_version_and_compiler : "",
- generated_by ? " (generated " ~ time_output_generated ~ ")" : "",
- doc_sty_info.stylesheet,
- doc_sty_info.papersize,
- doc_sty_info.orient,
- doc_sty_info.margin_left,
- doc_sty_info.margin_right,
- doc_sty_info.margin_top,
- doc_sty_info.margin_bottom,
-);
- return latex_sty;
- }
-}
diff --git a/src/sisudoc/io_out/metadata.d b/src/sisudoc/io_out/metadata.d
deleted file mode 100644
index 92b3bf9..0000000
--- a/src/sisudoc/io_out/metadata.d
+++ /dev/null
@@ -1,628 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.metadata;
-// @safe:
-template outputMetadata() {
- void outputMetadata(T)(T doc_matters) {
- string inline_search_form(M)(
- M doc_matters,
- ) {
- string o;
- string _form;
- if (doc_matters.opt.action.html_link_search) {
- o = format(q"┃
-
- ┃",
- doc_matters.conf_make_meta.conf.w_srv_cgi_action,
- (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty)
- ? ""
- : "\n 🔎 ",
- (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty)
- ? ""
- : "\n ",
- doc_matters.src.filename_base,
- doc_matters.conf_make_meta.conf.w_srv_cgi_action,
- (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty)
- ? ""
- : "\n ",
- doc_matters.src.filename_base,
- );
- } else {
- o = "";
- }
- return o;
- }
- import std.digest.crc;
- import std.digest.sha;
- import std.file;
- import std.format;
- import sisudoc.io_out;
- mixin InternalMarkup;
- char[] metadata_;
-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.lnkicon:link {
- text-decoration : none;
- }
- a.lnkicon:visited {
- text-decoration : none;
- }
- a.lnkicon:hover {
- font-size : 160%%;
- }
- a:hover img {
- background-color : #FFFFFF;
- }
- 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.lnkicon:link {
- text-decoration : none;
- }
- a.lnkicon:visited {
- text-decoration : none;
- }
- a.lnkicon:hover {
- font-size : 160%%;
- }
- a:hover img {
- background-color : #FFFFFF;
- }
- input {
- color : #000000;
- background-color : #FFFFFF;
- }
-┃");
-string theme_dark_1 = format(q"┃
- h1 {
- color : #FFFFFF;
- background : #000000;
- }
- p.letter {
- color : #FFFFFF;
- background : #333333;
- }
-┃");
-string theme_light_1 = format(q"┃
- h1 {
- color : #FFFFFF;
- background : #1A3A7A;
- }
- p.letter {
- color : #FFFFFF;
- background : #1A3A7A;
- }
-┃");
- metadata_ ~= format(q"┃
-
-
-
-
";
- if (!(doc_matters.conf_make_meta.meta.title_full.empty)) {
- metadata_ ~= "$1")
- .replaceAll(rgx.inline_insert, "$1")
- .replaceAll(rgx.inline_cite, "$1")
- .replaceAll(rgx.inline_emphasis, format(q"┃
");
- }
- return _txt;
- }
- string _links(O)(string _txt, const O obj) {
- if (obj.metainfo.is_a != "code") {
- if (obj.metainfo.is_a == "toc") {
- _txt = replaceAll!(m =>
- m[1] ~ "┤"
- ~ (replaceAll!(n =>
- n["type"] ~ n["path"] ~ (n["file"].encodeComponent)
- )((obj.stow.link[m["num"].to!ulong]).to!string, rgx.uri_identify_components))
- ~ "├"
- )(_txt, rgx.inline_link_number_only)
- .replaceAll(rgx.inline_link,
- format(q"┃┥)☼(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
┥)☼(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
- }
-}
diff --git a/src/sisudoc/io_out/skel.d b/src/sisudoc/io_out/skel.d
deleted file mode 100644
index 92e0d52..0000000
--- a/src/sisudoc/io_out/skel.d
+++ /dev/null
@@ -1,268 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.skel;
-@safe:
-template outputSkel() {
- template munge() {
- import std.stdio;
- import std.conv;
- void puts(string _obj_is) {
- writeln(__FILE__, ":", __LINE__, ": ", _obj_is);
- }
- string newline = "\n";
- string newlines = "\n\n";
- string toc(O)(O obj) {
- // puts(obj.metainfo.is_a);
- // return "toc\n";
- return obj.text ~ newline;
- }
- string heading(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string para(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string group(O)(O obj) {
- /+
- The "group" is different from the "block" mark in that "group" does not
- preserve whitespace, the "block" mark does. The text falling within the
- block is a single object.
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string block(O)(O obj) {
- /+
- The "block" is different from the "group" mark in that the "block" mark
- (like the "poem" mark) preserves whitespace, the "group" mark does not.
- The text falling within the "block" is a single object, which is different
- from the "poem" mark where each identified verse is an object.
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string poem(O)(O obj) {
- /+
- The "poem" mark like the "block" preserves whitespace. Text followed by
- two newlines are identified as verse and each verse is an object i.e. a
- poem may consist of multiple verse each of which is identified as an
- object, unlike a text "block" which is identified as a single object.
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- // return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- return obj.text ~ newlines;
- }
- string verse(O)(O obj) {
- /+
- See description of poem, the poem is demarkated but the verse is the
- object.
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string code(O)(O obj) {
- /+
- "Code" blocks are a single text object, in which the original text is
- preserved.
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string quote(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string table(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newline ~ "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newlines;
- }
- string endnote(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- string bookindex(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- string bibliography(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- string glossary(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- string blurb(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- string comment(O)(O obj) {
- /+
- +/
- // puts(obj.metainfo.is_a);
- // return obj.metainfo.is_a;
- return obj.text ~ newlines;
- }
- }
- template theDocument() {
- import std.stdio;
- import sisudoc.io_out;
- // static auto rgx = RgxO();
- string skel_head(M)(
- M doc_matters,
- ) {
- return "head";
- }
- string skel_body(D,M)(
- const D doc_abstraction,
- M doc_matters,
- ) {
- string doc_object = "";
- foreach (section; doc_matters.has.keys_seq.scroll) {
- foreach (obj; doc_abstraction[section]) {
- if (obj.metainfo.is_a == "toc") { doc_object ~= munge!().toc(obj); }
- if (obj.metainfo.is_a == "heading") { doc_object ~= munge!().heading(obj); }
- if (obj.metainfo.is_a == "para") { doc_object ~= munge!().para(obj); }
- if (obj.metainfo.is_a == "group") { doc_object ~= munge!().group(obj); }
- if (obj.metainfo.is_a == "block") { doc_object ~= munge!().block(obj); }
- if (obj.metainfo.is_a == "poem") { doc_object ~= munge!().poem(obj); }
- if (obj.metainfo.is_a == "verse") { doc_object ~= munge!().verse(obj); }
- if (obj.metainfo.is_a == "code") { doc_object ~= munge!().code(obj); }
- if (obj.metainfo.is_a == "quote") { doc_object ~= munge!().quote(obj); }
- if (obj.metainfo.is_a == "table") { doc_object ~= munge!().table(obj); }
- if (obj.metainfo.is_a == "endnote") { doc_object ~= munge!().endnote(obj); }
- if (obj.metainfo.is_a == "bookindex") { doc_object ~= munge!().bookindex(obj); }
- if (obj.metainfo.is_a == "bibliography") { doc_object ~= munge!().bibliography(obj); }
- if (obj.metainfo.is_a == "glossary") { doc_object ~= munge!().glossary(obj); }
- if (obj.metainfo.is_a == "blurb") { doc_object ~= munge!().blurb(obj); }
- if (obj.metainfo.is_a == "comment") { doc_object ~= munge!().comment(obj); }
- }
- }
- return doc_object;
- }
- string skel_tail(M)(
- M doc_matters,
- ) {
- return "tail";
- }
- }
- void outputSkel(D,M) (
- const D doc_abstraction,
- M doc_matters,
- ) {
- import std.stdio;
- import sisudoc.io_out;
- void skel_out(D,M)(
- const D doc_abstraction,
- M doc_matters,
- ) {
- struct Skel {
- string head;
- string content;
- string tail;
- }
- auto skel = Skel();
- skel.head = theDocument!().skel_head(doc_matters);
- skel.content = theDocument!().skel_body(doc_abstraction, doc_matters);
- skel.tail = theDocument!().skel_tail(doc_matters);
- auto pth_skel = spinePathsSkel(doc_matters);
- try {
- import std.file;
- if (!exists(pth_skel.base_pth)) {
- (pth_skel.base_pth).mkdirRecurse;
- }
- } catch (ErrnoException ex) {
- }
- if (doc_matters.opt.action.vox_gt_1) {
- writeln(" ", pth_skel.skel_file);
- }
- // writeln(pth_skel.base_pth);
- auto f = File(pth_skel.skel_file, "w");
- f.writeln(skel.head);
- f.writeln(skel.content);
- f.writeln(skel.tail);
- }
- skel_out(doc_abstraction, doc_matters);
- }
-}
diff --git a/src/sisudoc/io_out/source_pod.d b/src/sisudoc/io_out/source_pod.d
deleted file mode 100644
index b015a04..0000000
--- a/src/sisudoc/io_out/source_pod.d
+++ /dev/null
@@ -1,544 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.io_out.source_pod;
-@system: // is not @safe: use: @system: or @trusted:
-template spinePod() {
- import std.digest.sha;
- import std.file;
- import std.outbuffer;
- import std.zip;
- import std.conv : to;
- import sisudoc.meta.rgx_files;
- import sisudoc.io_out;
- import sisudoc.io_out.create_zip_file;
- import sisudoc.io_out.xmls;
- void spinePod(T)(T doc_matters) {
- debug(asserts) {
- // static assert(is(typeof(doc_matters) == tuple));
- }
- mixin spineRgxFiles;
- string pwd = doc_matters.env.pwd;
- auto pths_pod = spinePathsPods!()(doc_matters);
- mixin spineLanguageCodes;
- auto lang = Lang();
- static auto rgx_files = RgxFiles();
- assert (doc_matters.src.filename.match(rgx_files.src_fn));
- if (doc_matters.opt.action.source_or_pod) {
- try {
- /+ ↓ clean slate: remove per-document pod directory before regeneration,
- but only on the first language of a multi-language document,
- so that subsequent languages' files are not wiped +/
- if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[0]) {
- string doc_pod_dir = pths_pod.base_filesystem_(doc_matters.src.filename);
- if (exists(doc_pod_dir) && doc_pod_dir.isDir) {
- doc_pod_dir.rmdirRecurse;
- }
- }
- {
- podArchive_directory_tree(doc_matters, pths_pod);
- }
- {
- struct STsrcDigests {
- std.zip.ZipArchive zip;
- string fn_pod;
- string[string][string] digests;
- }
- STsrcDigests _st;
- _st = pod_zipMakeReady(doc_matters, pths_pod, _st);
- {
- zipArchive(doc_matters, _st.fn_pod, _st.zip);
- if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) {
- zipArchiveDigest(doc_matters, _st.fn_pod, _st.digests);
- }
- }
- }
- } catch (ErrnoException ex) {
- // Handle error
- }
- }
- }
- void podArchive_directory_tree(M,P)(M doc_matters, P pths_pod) { // create directory structure
- if (!exists(pths_pod.pod_dir_())) {
- // used both by pod zipped (& pod filesystem (unzipped) which makes its own recursive dirs)
- pths_pod.pod_dir_().mkdirRecurse;
- }
- if (doc_matters.opt.action.source_or_pod) {
- // if (doc_matters.opt.action.vox_gt_1) { writeln(" ", pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod); }
- if (!exists(pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- if (!exists(pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- if (!exists(pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- if (!exists(pths_pod.css(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.css(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- if (doc_matters.opt.action.pod2) {
- if (!exists(pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- }
- if (!exists(pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod)) {
- pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse;
- }
- if (!exists(pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod)) {
- pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.mkdirRecurse;
- }
- }
- if (!exists(pths_pod.pod_dir_() ~ "/index.html")) {
- import sisudoc.io_out.html_snippet;
- mixin htmlSnippet;
- auto f = File(pths_pod.pod_dir_() ~"/index.html", "w");
- f.writeln(format_html_blank_page_guide_home(
- "../../css/html_scroll.css",
- (doc_matters.opt.action.webserver_url_doc_root.length > 0)
- ? doc_matters.opt.action.webserver_url_doc_root
- : doc_matters.conf_make_meta.conf.w_srv_data_root_url,
- "../../index.html",
- ));
- }
- }
- auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) {
- auto pth_dr_doc_src = doc_matters.src_path_info;
- if (doc_matters.opt.action.vox_gt_3) { // correct
- writeln(__LINE__, ":", __FILE__, ":\n",
- doc_matters.src.filename, " -> ",
- pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod
- );
- }
- auto zip = new ZipArchive(); // needed
- auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
- string[string][string] _digests;
- { // bundle images - get digest
- foreach (image; doc_matters.srcs.image_list) {
- if (doc_matters.opt.action.vox_gt_3) {
- writeln(
- pth_dr_doc_src.image_root.to!string, "/", image, " -> ",
- pths_pod.image_root(doc_matters.src.filename).zpod, "/", image
- );
- }
- auto fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image;
- auto fn_src_out_pod_zip_base
- = pths_pod.image_root(doc_matters.src.filename).zpod.to!string
- ~ "/" ~ image;
- auto fn_src_out_filesystem
- = pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.to!string
- ~ "/" ~ image;
- if (exists(fn_src_in)) {
- debug(io) { writeln("(io debug) src out found: ", fn_src_in); }
- { // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (fn_src_in).read);
- _digests["shared"]["images"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ image ~ "\n";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", image);
- }
- if (doc_matters.opt.action.source_or_pod) {
- fn_src_in.copy(fn_src_out_filesystem);
- }
- if (doc_matters.opt.action.source_or_pod) {
- zip = podArchive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip);
- }
- } else {
- if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) {
- writeln("WARNING (io) src out NOT found (image): ", fn_src_in);
- }
- }
- }
- } { // bundle abstraction .ssp file (only for --pod2)
- if (doc_matters.opt.action.pod2) {
- if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssp generated
- import sisudoc.io_out.paths_output;
- /+ doc_uid_out for any language follows the same pattern, differing
- only in the trailing ".{lng}". Strip the current language to
- reuse the base across all languages. +/
- string _doc_uid_base
- = doc_matters.src.doc_uid_out[0 .. $ - doc_matters.src.lng.length];
- foreach (_lang; doc_matters.pod.manifest_list_of_languages) { // do for all language versions
- auto out_pth_lng = spineOutPaths!()(doc_matters.output_path, _lang);
- string abstraction_dir = ((out_pth_lng.output_base.chainPath("abstraction")).asNormalizedPath).array;
- string ssp_filename = _doc_uid_base ~ _lang ~ ".ssp";
- string fn_src_in = ((abstraction_dir.chainPath(ssp_filename)).asNormalizedPath).array.to!string;
- auto fn_src_out_pod_zip_base
- = pths_pod.abstraction_root(doc_matters.src.filename).zpod.to!string
- ~ "/" ~ ssp_filename;
- auto fn_src_out_filesystem
- = pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string
- ~ "/" ~ ssp_filename;
- if (exists(fn_src_in)) {
- debug(io) { writeln("(io debug) src out found: ", fn_src_in); }
- { // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (fn_src_in).read);
- _digests[_lang]["ssp"] ~= data.sha256Of.toHexString
- ~ "::" ~ data.length.to!string ~ " - " ~ ssp_filename ~ "\n";
- }
- fn_src_in.copy(fn_src_out_filesystem);
- zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
- } else {
- if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) {
- writeln("WARNING (io) src out NOT found (abstraction): ", fn_src_in);
- }
- }
- }
- }
- }
- } { // bundle dr_document_make
- auto fn_src_in = ((doc_matters.src.is_pod)
- ? doc_matters.src.conf_dir_path
- : pth_dr_doc_src.conf_root).to!string
- ~ "/" ~ "dr_document_make";
- auto fn_src_out_pod_zip_base
- = pths_pod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "dr_document_make";
- auto fn_src_out_filesystem
- = pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.to!string
- ~ "/" ~ "dr_document_make";
- if (exists(fn_src_in)) {
- debug(io) { writeln("(io debug) src out found: ", fn_src_in); }
- if (doc_matters.opt.action.source_or_pod) {
- fn_src_in.copy(fn_src_out_filesystem);
- }
- if (doc_matters.opt.action.source_or_pod) {
- zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
- }
- } else {
- if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) {
- writeln("WARNING (io) src out NOT found (document make): ", fn_src_in);
- }
- }
- } { // pod manifest
- auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string;
- auto fn_src_out_pod_zip_base
- = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string;
- auto fn_src_out_filesystem
- = pths_pod.pod_manifest(doc_matters.src.filename).filesystem_open_zpod.to!string; // needed without root path
- auto fn_src_out_inside_pod
- = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string; // needed without root path
- string[] filelist_src_out_pod_arr;
- string[] filelist_src_zpod_arr;
- if (exists(fn_src_in)) {
- debug(io) { writeln("(io debug) src in found: ", fn_src_in); }
- filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base;
- filelist_src_zpod_arr ~= fn_src_out_inside_pod;
- {
- import dyaml;
- auto pod_filelist_yaml_string
- = File(pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod, "w");
- Node _pmy;
- string _pm = "doc:\n filename: " ~ doc_matters.src.filename ~ "\n language: " ~ doc_matters.pod.manifest_list_of_languages.to!string ~ "\n";
- if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) {
- try {
- _pmy = Loader.fromString(_pm).load();
- } catch (ErrnoException ex) {
- } catch (Throwable) {
- writeln("ERROR failed to read config file content, not parsed as yaml");
- }
- writeln("pod filename: ", _pmy["doc"]["filename"].get!string);
- writeln("pod languages: ", doc_matters.pod.manifest_list_of_languages.to!string);
- writeln("pod languages: ", doc_matters.src.language);
- // foreach(string _l; _pmy["doc"]["language"]) {
- // writeln("language: ", _l);
- // }
- }
- if (doc_matters.opt.action.source_or_pod) {
- pod_filelist_yaml_string.writeln(_pm);
- }
- if (doc_matters.opt.action.source_or_pod) {
- zip = podArchive("string", _pm, fn_src_out_pod_zip_base, zip);
- }
- }
- }
- } { // bundle primary file (.ssm/.sst) - get digest
- auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string;
- auto fn_src_out_pod_zip_base
- = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string;
- auto fn_src_out_filesystem
- = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.to!string; // needed without root path:
- auto fn_src_out_inside_pod
- = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string; // needed without root path:
- string[] filelist_src_out_pod_arr;
- string[] filelist_src_zpod_arr;
- if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssm parsed
- foreach (_lang; doc_matters.pod.manifest_list_of_languages) { // do for all language versions
- string fn_src_out_filesystem_lng
- = pths_pod.fn_doc(doc_matters.src.filename, _lang).filesystem_open_zpod.to!string;
- string _sstm = (doc_matters.pod.manifest_path ~ "/media/text/" ~ _lang ~ "/" ~ doc_matters.src.filename);
- string _pth_file_sstm;
- if (exists(_sstm)) { _pth_file_sstm = _sstm;
- } else if (exists(fn_src_in)) { _pth_file_sstm = fn_src_in;
- }
- if (exists(_pth_file_sstm)) { // what of language?
- debug(io) { writeln("(io debug) src in found: ", _pth_file_sstm); }
- { // take DIGEST write to pod file digests.txt
- auto data = (cast(byte[]) (_pth_file_sstm).read);
- _digests[_lang]["sstm"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename ~ " - [" ~ _lang ~ "]";
- // writeln(data.sha256Of.toHexString, "::", data.length, " - ", doc_matters.src.filename);
- }
- filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base;
- filelist_src_zpod_arr ~= fn_src_out_inside_pod;
- string _pod_to_markup_file = doc_matters.src.pod_name ~ "/" ~ "media/text/" ~ _lang ~ "/" ~ doc_matters.src.filename;
- if (doc_matters.opt.action.source_or_pod) {
- _pth_file_sstm.copy(fn_src_out_filesystem_lng);
- }
- if (doc_matters.opt.action.source_or_pod) {
- auto _rgx_sstm = regex(r"(?P
")
- .replaceAll(rgx.br_line, "
")
- .replaceAll(rgx.br_line_spaced, "
")
- .replaceAll(rgx_xhtml.line_break, "
");
- return _txt;
- }
- string _html_font_face(string _txt){
- _txt = _txt
- .replaceAll(rgx.inline_emphasis, "$1")
- .replaceAll(rgx.inline_bold, "$1")
- .replaceAll(rgx.inline_underscore, "$1")
- .replaceAll(rgx.inline_italics, "$1")
- .replaceAll(rgx.inline_superscript, "$1")
- .replaceAll(rgx.inline_subscript, "$1")
- .replaceAll(rgx.inline_strike, "$1")
- .replaceAll(rgx.inline_insert, "$1")
- .replaceAll(rgx.inline_mono, "$1")
- .replaceAll(rgx.inline_cite, "$1");
- return _txt;
- }
- string _notes;
- string _urls;
- string _txt = _html_font_face(_html_special_characters(obj.text));
- { /+ debug +/
- if (doc_matters.opt.action.debug_do_sqlite) {
- writeln(_txt, "\n");
- }
- }
- return _txt;
- }
- string html_special_characters(string _txt){
- _txt = _txt
- .replaceAll(rgx_xhtml.ampersand, "&")
- .replaceAll(rgx_xhtml.quotation, """)
- .replaceAll(rgx_xhtml.less_than, "<")
- .replaceAll(rgx_xhtml.greater_than, ">")
- .replaceAll(rgx.nbsp_char, " ")
- .replaceAll(rgx.br_line_inline, "
")
- .replaceAll(rgx.br_line, "
")
- .replaceAll(rgx.br_line_spaced, "
")
- .replaceAll(rgx_xhtml.line_break, "
");
- return _txt;
- }
- string html_special_characters_code(string _txt){
- _txt = _txt
- .replaceAll(rgx_xhtml.ampersand, "&")
- .replaceAll(rgx_xhtml.quotation, """)
- .replaceAll(rgx_xhtml.less_than, "<")
- .replaceAll(rgx_xhtml.greater_than, ">")
- .replaceAll(rgx.nbsp_char, " ");
- return _txt;
- }
- string html_font_face(string _txt){
- _txt = _txt
- .replaceAll(rgx.inline_emphasis, "$1")
- .replaceAll(rgx.inline_bold, "$1")
- .replaceAll(rgx.inline_underscore, "$1")
- .replaceAll(rgx.inline_italics, "$1")
- .replaceAll(rgx.inline_superscript, "$1")
- .replaceAll(rgx.inline_subscript, "$1")
- .replaceAll(rgx.inline_strike, "$1")
- .replaceAll(rgx.inline_insert, "$1")
- .replaceAll(rgx.inline_mono, "$1")
- .replaceAll(rgx.inline_cite, "$1");
- return _txt;
- }
- string inline_grouped_text_bullets_indents(M,O)(
- M doc_matters,
- const O obj,
- string _txt,
- string _suffix = ".html",
- string _xml_type = "seg",
- ) {
- static auto rgx = RgxO();
- static auto rgx_xhtml = RgxXHTML();
- if (obj.metainfo.is_a == "group") {
- _txt = (_txt)
- .replaceAll(rgx.grouped_para_indent_1,
- " ")
- .replaceAll(rgx.grouped_para_indent_2,
- " ")
- .replaceAll(rgx.grouped_para_indent_3,
- " ")
- .replaceAll(rgx.grouped_para_indent_4,
- " ")
- .replaceAll(rgx.grouped_para_indent_5,
- " ")
- .replaceAll(rgx.grouped_para_indent_6,
- " ")
- .replaceAll(rgx.grouped_para_indent_7,
- " ")
- .replaceAll(rgx.grouped_para_indent_8,
- " ")
- .replaceAll(rgx.grouped_para_indent_9,
- " ")
- .replaceAll(rgx.grouped_para_indent_hang, " ")
- .replaceAll(rgx.grouped_para_bullet, "● ")
- .replaceAll(rgx.grouped_para_bullet_indent_1,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_2,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_3,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_4,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_5,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_6,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_7,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_8,
- " ● ")
- .replaceAll(rgx.grouped_para_bullet_indent_9,
- " ● ");
- }
- return _txt;
- }
- string inline_images(M,O)(
- M doc_matters,
- const O obj,
- string _txt,
- string _suffix = ".html",
- string _xml_type = "seg",
- ) {
- string _img_pth;
- if (_xml_type == "epub") {
- _img_pth = "image/";
- } else if (_xml_type == "scroll") {
- _img_pth = "../../image/";
- } else if (_xml_type == "seg") {
- _img_pth = "../../../image/";
- }
- if (_txt.match(rgx.inline_image)) {
- _txt = _txt.replaceAll( // TODO bug where image dimensions (w or h) not given & consequently set to 0; should not be used (calculate earlier, abstraction)
- rgx.inline_image,
- ("$1 $6"));
- }
- return _txt;
- }
- string inline_links(M,O)(
- M doc_matters,
- const O obj,
- string _txt,
- string _xml_type = "seg",
- ) {
- if (obj.has.inline_links) {
- if (obj.metainfo.is_a != "code") {
- _txt = replaceAll!(m =>
- m["linked_text"] ~ "┤" ~ to!string((obj.stow.link[m["num"].to!ulong])).encode ~ "├"
- )(_txt, rgx.inline_link_number_only);
- }
- if ((_txt.match(rgx.mark_internal_site_lnk))
- && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
- _txt = _txt.replaceAll(
- rgx.inline_seg_link,
- "$1");
- }
- auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language);
- if (_xml_type == "seg") {
- foreach (m; _txt.matchAll(rgx.inline_link_seg_and_hash)) {
- if (m.captures["hash"] in doc_matters.has.tag_associations) {
- if (m.captures["hash"] == doc_matters.has.tag_associations[(m.captures["hash"])]["seg_lv4"]) {
- _txt = _txt.replaceFirst(
- rgx.inline_link_seg_and_hash,
- "┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html
- ~ "/"
- ~ pth_html.tail_fn_seg(doc_matters.src.filename, "$2.html")
- ~ "├"
- );
- } else {
- _txt = _txt.replaceFirst(
- rgx.inline_link_seg_and_hash,
- "┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html
- ~ "/"
- ~ doc_matters.src.filename_base
- ~ "/"
- ~ doc_matters.has.tag_associations[(m.captures["hash"])]["seg_lv4"]
- ~ ".html"
- ~ "#" ~ m.captures["hash"]
- ~ "├"
- );
- }
- } else {
- if (doc_matters.opt.action.vox_gt_1) {
- writeln(
- "WARNING on internal document links, anchor to link <<"
- ~ m.captures["hash"]
- ~ ">> not found in document, "
- ~ "anchor: " ~ m.captures["hash"]
- ~ " document: " ~ doc_matters.src.filename
- );
- }
- }
- }
- } else {
- if (auto m = _txt.match(rgx.inline_link_seg_and_hash)) {
- _txt = _txt.replaceFirst(
- rgx.inline_link_seg_and_hash,
- "┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html
- ~ "/"
- ~ pth_html.tail_fn_scroll(doc_matters.src.filename)
- ~ "#" ~ m.captures["hash"]
- ~ "├"
- );
- }
- }
- _txt = _txt
- .replaceAll(
- rgx.inline_link_fn_suffix,
- ("$1.html"))
- .replaceAll(
- rgx.inline_link,
- ("$1"))
- .replaceAll(
- rgx.mark_internal_site_lnk,
- "");
- }
- debug(markup_links) {
- if (_txt.match(rgx.inline_link)) {
- writeln(__LINE__,
- " (missed) markup link identified (",
- obj.has.inline_links,
- "): ", obj.metainfo.is_a, ": ",
- obj.text
- );
- }
- // if (obj.metainfo.is_a == "bookindex") { // DEBUG LINE
- // if (_txt.match(regex(r""
- ~ "" ~ m.captures["num"] ~ "."
- ~ m.captures["note"]
- ~ "
- %s -
┃", - obj.metainfo.is_a, - _txt, - ); - return o; - } - string html_para(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); - assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); - assert(obj.metainfo.is_of_type == "para"); - assert(obj.metainfo.is_a == "para" || "toc" || "endnote" || "glossary" || "bibliography" || "bookindex" || "blurb"); - string _txt = munge_html(doc_matters, obj); - _txt = (obj.attrib.bullet) ? ("● " ~ _txt) : _txt; - _txt = inline_markup(doc_matters, obj, _txt); - string o = format(q"┃- %s -
┃", - obj.metainfo.is_a, - obj.attrib.indent_hang, - obj.attrib.indent_base, - _txt - ); - return o; - } - string html_quote(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "quote"); - string _txt = munge_html(doc_matters, obj); - string o = format(q"┃- %s -
┃", - obj.metainfo.is_a, - _txt - ); - return o; - } - string html_group(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "group"); - string _txt = munge_html(doc_matters, obj); - _txt = inline_markup(doc_matters, obj, _txt); - string o = format(q"┃- %s -
┃", - obj.metainfo.is_a, - _txt - ); - return o; - } - string html_block(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "block"); - string _txt = munge_html(doc_matters, obj); - _txt = inline_markup(doc_matters, obj, _txt); - string o = format(q"┃ -%s
┃", - obj.metainfo.is_a, - _txt.stripRight - ); - return o; - } - string html_verse(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "verse"); - string _txt = munge_html(doc_matters, obj); - string o = format(q"┃%s
┃", - obj.metainfo.is_a, - _txt - ); - return o; - } - string html_code(O)( - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "code"); - string _txt = html_special_characters_code(obj.text); - string o = format(q"┃%s
┃", - obj.metainfo.is_a, - _txt - ); - return o; - } - string html_table(M,O)( - M doc_matters, - const O obj, - ) { - assert(obj.metainfo.is_of_part == "body"); - assert(obj.metainfo.is_of_section == "body"); - assert(obj.metainfo.is_of_type == "block"); - assert(obj.metainfo.is_a == "table"); - Tuple!(string, string) _tablarize(O)( - const O obj, - string _txt, - ) { - string[] _table_rows = _txt.split(rgx.table_delimiter_row); - string[] _table_cols; - string _table; - string _tablenote; - foreach(row_idx, row; _table_rows) { - _table_cols = row.split(rgx.table_delimiter_col); - _table ~= "-
- ≅ SiSU Spine ፨ (object numbering & object search) -
-- (web 1993, object numbering 1997, object search 2002 ...) 2026 -
-",
- "",
- "
",
- "",
- "
- ۰ %s -
- ┃", - indent, - indent, - link, - text, - )); - } - } - lev4_subtoc ~= "%s - %s -
-%s - %s -
-- %s -
-- %s -
-- %s -
-- %s -
-%s
-%s
-%s
-%s
-%s -
\n";
- foreach (k, _line; _block_lines) {
- if (k == 1) {
- _codelines ~= format(q"┃ %s
- ┃",
- _line,
- );
- } else {
- _codelines ~= format(q"┃ %s
- ┃",
- _line,
- );
- }
- }
- _codelines ~= " ";
- } else {
- _codelines = " \n"; - _codelines ~= _txt; - _codelines ~= ""; - } - return _codelines; - } - if (!(obj.metainfo.identifier.empty)) { - o = format(q"┃
%s
-%s
-and headings. */ -/* Scoped to direct body children to avoid affecting div.toc lists. */ -/* ------------------------------------------------------------------ */ -body > ul, -body > ol { - margin-left : 5%%; - margin-right : 2em; - margin-top : 0.8em; - margin-bottom : 0.8em; - padding-left : 1.5em; - list-style-position : outside; -} -body > ul { list-style-type : disc; } -body > ol { list-style-type : decimal; } -body > ul li, -body > ol li { - margin-left : 0; - margin-right : 0; - margin-top : 0.3em; - margin-bottom : 0.3em; - line-height : 133%%; - background : none; - text-align : left; - text-indent : 0; -} -details { - margin-top : 1em; - margin-bottom : 0.5em; -} -summary { - margin-left : 5%%; - margin-right : 2em; - padding-left : 0.2em; - padding-top : 0.4em; - padding-bottom : 0.4em; - font-size : 1.6rem; - line-height : 133%%; - cursor : pointer; -} -details > ul, -details > ol { - margin-left : 5%%; - padding-left : 1.5em; -} -details > ul li, -details > ol li { - margin-left : 0; -} -┃", - _color_ocn_light, - _css_indent, - _color_ocn_light, -); - string _css_dark_html_seg = format(q"┃ -html { -} -*{ - padding : 0px; - margin : 0px; -} -body { - height : 100vh; - background-color : #000000; - 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.lnkocn:link { - color : %s; - text-decoration : none; -} -a.lnkocn:visited { - color : #9ACD32; - text-decoration : none; -} -a.lnkocn:hover { - color : #BBBBBB; - font-size : 1.8rem; -} -a.lnkicon:link { - text-decoration : none; -} -a.lnkicon:visited { - text-decoration : none; -} -a.lnkicon:hover { - color : #BBBBBB; - font-size : 120%%; -} -a:hover img { - background-color : #000000; -} -a:active { - color : #888888; - text-decoration : underline; -} -input { - color : #FFFFFF; - background-color : #777777; -} -div { - margin-left : 0; - margin-right : 0; -} -div.p { - margin-left : 5%%; - margin-right : 1%%; -} -div.substance { - width : 100%%; - background-color : #000000; -} -div.ocn { - width : 5%%; - float : right; - top : 0; - background-color : #000000; -} -div.endnote { - width : 95%%; - background-color : #000000; -} -div.toc { - position : absolute; - float : left; - margin : 0; - padding : 0; - padding-top : 0.5em; - border : 0; - width : 13em; - background-color : #111111; - margin-right : 1em; -} -div.summary { - margin : 0; - padding : 0; - border-left : 13em solid #111111; - padding-left : 1em; - background-color : #111111; -} -div.content, div.main_column { - margin : 0; - padding : 0; - border-left : 13em solid #000000; - padding-left : 1em; - padding-right : 1em; -} -div.content0, div.main_column0 { - margin : 0; - padding : 0; - border-left : 0%% solid #000000; - padding-left : 5%%; -} -div.scroll { - margin : 0; - padding : 0; - padding-left : 1em; - padding-right : 1em; -} -div.content:after { - content : ' '; - clear : both; - display : block; - height : 0; - overflow : hidden; -} -div.footer { - clear : left; - padding : 0.5em; - font-size : 1.4rem; - margin : 0; -} -div.toc ul { - list-style : none; - padding : 0; - margin : 0; -} -div.toc li ul a, li ul span.currentlink -{ - font-weight : normal; - font-size : 1.5rem; - padding-left : 2em; - background-color : #111111; -} -div.toc a, span.currentlink{ - display : block; - text-decoration : none; - padding-left : 0.5em; - color : #FF00AA; -} -hr { - width : 90%%; - margin-left : 5%%; - margin-right : 2em; - margin-top : 1.8em; - margin-bottom : 1.8em; -} -span.currentlink { - text-decoration : none; - background-color : #AAAAF9; -} -div.toc a:visited { - color : #FF00AA; -} -div.toc a:hover { - color : #CCCCCC; - background-color : #F9F9AA; -} -nav#toc ol { - list-style-type : none; -} -.norm, .bold, .verse, .group, .block, .alt { - line-height : 133%%; - margin-top : 12px; - margin-bottom : 0px; - padding-left : 0em; - text-indent : 0em; -} -p, h0, h1, h2, h3, h4, h5, h6, h7, ul, li { - display : block; - font-family : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; - margin-left : 5%%; - margin-right : 2em; -} -p { - font-size : 1.6rem; - font-weight : normal; - line-height : 133%%; - text-align : justify; - text-indent : 0mm; - margin-top : 0.8em; - margin-bottom : 0.8em; -} -img { - max-width : 100%%; - height : auto; -} -pre { - width : auto; - display : block; - clear : both; - color : #555555; -} -pre.codeline { - display : table; - clear : both; - table-layout : fixed; - margin-left : 5%%; - margin-right : 5%%; - width : 90%%; - white-space : pre-wrap; - border-style : none; - border-radius : 5px 5px 5px 5px; - box-shadow : 0 2px 5px #AAAAAA inset; - margin-bottom : 1em; - padding : 0.5em 1em; - page-break-inside : avoid; - word-wrap : break-word; - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - white-space : pre; - white-space : pre-wrap; - white-space : -moz-pre-wrap; - white-space : -o-pre-wrap; - background-color : #555555; - color : #DDDDDD; - font-size : 1.5rem; - line-height : 100%%; -} -pre.codeline::before { - counter-reset : linenum; -} -pre.codeline span.tr { - display : table-row; - counter-increment : linenum; -} -pre.codeline span.th { - display : table-cell; - user-select : none; - -moz-user-select : none; - -webkit-user-select : none; - padding : 0.5em 0.5em; -} -pre.codeline span.th::before { - content : counter(linenum) "."; - color : #999999; - text-align : right; - display : block; -} -pre.codeline span.th { - width : 4em; -} -pre.codeline code { - display : table-cell; -} -p.code { - border-style : none; -} -p.spaced { white-space : pre; } -p.block { - white-space : pre; -} -p.group { } -p.alt { } -p.verse { - white-space : pre; - margin-bottom : 6px; -} -p.caption { - text-align : left; - font-size : 1.4rem; - display : inline; -} -p.endnote { - font-size : 1.5rem; - line-height : 120%%; - text-align : left; - margin-right : 15mm; - padding-left : 1em; - text-indent : -1em; -} -p.center { - text-align : center; -} -p.bold { - font-weight : bold; -} -p.bold_left { - font-weight : bold; - text-align : left; -} -p.centerbold { - text-align : center; - font-weight : bold; -} -p.em { - font-weight : bold; - font-style : normal; - background : #FFF3B6; -} -.small, .small_center { - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 0px; - margin-right : 6px; -} -p.small { - text-align : left; -} -p.small_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -.tiny, .tiny_left, .tiny_right, .tiny_center { - font-size : 1.35rem; - margin-top : 0px; - margin-bottom : 0px; - color : #EEEEEE; - margin-right : 6px; - text-align : left; -} -p.tiny { } -p.tiny_left { - margin-left : 0px; - margin-right : 0px; - text-align : left; -} -p.tiny_right { - margin-right : 1em; - text-align : right; -} -p.tiny_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -p.concordance_word { - line-height : 150%%; - font-weight : bold; - display : inline; - margin-top : 4px; - margin-bottom : 1px; -} -p.concordance_count { - font-size : 1.4rem; - color : #555555; - display : inline; - margin-left : 0em; -} -p.concordance_object { - font-size : 1.4rem; - line-height : 120%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -p.book_index_lev1 { - line-height : 100%%; - margin-top : 4px; - margin-bottom : 1px; -} -p.book_index_lev2 { - line-height : 100%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -tt { - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - background-color : #555555; - color : #DDDDDD; -} -%s -note { white-space : pre; } -label.ocn { - width : 2%%; - float : right; - top : 0; - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 6px; - margin-right : 6px; - text-align : right; - color : %s; - -khtml-user-select : none; - -moz-user-select : none; - -ms-user-select : none; - -o-user-select : none; - -webkit-user-select : none; - user-select : none; -} -table { - display : block; - margin-left : 5%%; - margin-right : 2em; - background-color : inherit; -} -tr { } -th,td { - vertical-align : top; - text-align : left; -} -th { - font-weight : bold; -} -em { - font-weight : bold; - font-style : italic; -} -p.left,th.left,td.left { - text-align : left; -} -p.small_left,th.small_left,td.small_left { - text-align : left; - font-size : 1.4rem; -} -p.right,th.right,td.right { - text-align : right; -} -ul, li { - list-style-type : none; - list-style : none; - padding-left : 20px; - font-weight : normal; - line-height : 150%%; - text-align : left; - text-indent : 0mm; - margin-left : 1em; - margin-right : 2em; - margin-top : 3px; - margin-bottom : 3px; -} -li { - background : (../image_sys/bullet_09.png) no-repeat 0px 6px; -} -ul { } -h0, h1, h2, h3, h4, h5, h6, h7 { - font-weight : bold; - line-height : 120%%; - text-align : left; - margin-top : 20px; - margin-bottom : 10px; -} -h4.norm, h5.norm, h6.norm, h7.norm { - margin-top : 10px; - margin-bottom : 0px; -} -h0 { font-size : 1.9rem; } -h1 { font-size : 1.8rem; } -h2 { font-size : 1.75rem; } -h3 { font-size : 1.7rem; } -h4 { font-size : 1.65rem; } -h5 { font-size : 1.6rem; } -h6 { font-size : 1.55rem; } -h7 { font-size : 1.5rem; } -h0, h1, h2, h3, h4, h5, h6, h7 { - text-shadow : .2em .2em .3em #999999; -} -h1.i { margin-left : 2em; } -h2.i { margin-left : 3em; } -h3.i { margin-left : 4em; } -h4.i { margin-left : 5em; } -h5.i { margin-left : 6em; } -h6.i { margin-left : 7em; } -h7.i { margin-left : 8em; } -h8.i { margin-left : 9em; } -h9.i { margin-left : 10em; } -.toc { - font-weight : normal; - margin-top : 6px; - margin-bottom : 6px; -} -h0.toc { - margin-left : 1em; - font-size : 1.8rem; - line-height : 150%%; -} -h1.toc { - margin-left : 1em; - font-size : 1.75rem; - line-height : 150%%; -} -h2.toc { - margin-left : 2em; - font-size : 1.7rem; - line-height : 140%%; -} -h3.toc { - margin-left : 3em; - font-size : 1.65rem; - line-height : 120%%; -} -h4.toc { - margin-left : 4em; - font-size : 1.6rem; - line-height : 120%%; -} -h5.toc { - margin-left : 5em; - font-size : 1.5rem; - line-height : 110%%; -} -h6.toc { - margin-left : 6em; - font-size : 1.5rem; - line-height : 110%%; -} -h7.toc { - margin-left : 7em; - font-size : 1.45rem; - line-height : 100%%; -} -.subtoc { - margin-right : 34%%; - font-weight : normal; -} -h5.subtoc { - margin-left : 2em; - font-size : 1.4rem; - margin-top : 2px; - margin-bottom : 2px; -} -h6.subtoc { - margin-left : 3em; - font-size : 1.35; - margin-top : 0px; - margin-bottom : 0px; -} -h7.subtoc { - margin-left : 4em; - font-size : 1.3rem; - margin-top : 0px; - margin-bottom : 0px; -} -input, select, textarea { - font-size : 2.2rem; -} -input[type="text"] { - font-size : 1.8rem; - line-height : 120%%; -} -button[type="submit"] { - font-size : 1.8rem; - line-height : 120%%; -} -p.form { - font-size : 2.2rem; - line-height : 150%%; -} -.icon-bar { - width : 100%%; - overflow : auto; - margin : 0em 0em 0em; -} -.left-bar { - width : 85%%; - float : left; - display : inline; - overflow : auto; -} -.toc-button { - position : absolute; - top : 8px; - width : 3em; - height : 3em; - border-radius : 50%%; - background : #555555; - fill : #DDDDDD; - box-shadow : 0 2px 5px #EEEEEE inset; -} -.toc-button svg { - position : relative; - left : 25%%; - top : 25%%; - width : 150%%; - height : 150%%; -} -.toc-button p { - vertical-align : center; - font-size : 1.8rem; -} -.prev-next-button { - position : absolute; - top : 8px; - width : 3em; - height : 3em; - border-radius : 50%%; - background : #555555; - box-shadow : 0 2px 5px #AAAAAA inset; -} -.prev-next-button svg { - position : relative; - left : 20%%; - top : 20%%; - width : 60%%; - height : 60%%; -} -.menu { - right : 8em; - } -.previous { - right : 4em; - } -.next { - right : 0em; - } -.arrow { - fill : #DDDDDD; -} -.minitoc { - line-height : 120%%; - font-size : 1.6rem; - margin-top : 6px; - margin-bottom : 0px; - padding-left : 0em; - text-indent : 0em; - -khtml-user-select : none; - -moz-user-select : none; - -ms-user-select : none; - -o-user-select : none; - -webkit-user-select : none; - user-select : none; -} -/* flex */ -.flex-menu-bar { - display : -webkit-flex; - display : flex; - -webkit-flex-wrap : wrap; - -webkit-align-items : center; - align-items : center; - width : 100%%; - margin-left : 5%%; - margin-right : 2%%; - background-color : #000000; -} -.flex-menu-option { - background-color : #000000; - margin-right : 4px; -} -.flex-list { - display : -webkit-flex; - display : flex; - -webkit-align-items : center; - display : block; - align-items : center; - width : 100%%; - background-color : #000000; -} -.flex-list-item { - background-color : #000000; - margin : 4px; -} -/* grid */ -.wrapper { - display : grid; - grid-template-columns : 100%%; - grid-template-areas : - "headband" - "doc_header" - "doc_title" - "doc_toc" - "doc_prefix" - "doc_intro" - "doc_body" - "doc_endnotes" - "doc_glossary" - "doc_biblio" - "doc_bookindex" - "doc_blurb" - "doc_suffix"; - margin : 0px; - padding : 0px; - background-color : #000000; -} -.delimit { - border-style : none; - border-color : #000000; - padding : 10px; -} -.headband { - grid-area : headband; - background-color : #000000; -} -.doc_header { - grid-area : doc_header; -} -.doc_title { - grid-area : doc_title; -} -.doc_toc { - grid-area : doc_toc; -} -.doc_prefix { - grid-area : doc_prefix; -} -.doc_intro { - grid-area : doc_intro; -} -.doc_body { - grid-area : doc_body; -} -.doc_endnotes { - grid-area : doc_endnotes; -} -.doc_glossary { - grid-area : doc_glossary; -} -.doc_biblio { - grid-area : doc_biblio; -} -.doc_bookindex { - grid-area : doc_bookindex; -} -.doc_blurb { - grid-area : doc_blurb; -} -.doc_suffix { - grid-area : doc_suffix; -} -.nav-ul { - list-style : none; - float : left; -} -.nav-li { - float : left; - padding-right : 0.7em; -} -.nav-li a { - text-decoration : none; - color : #000000; -} -footer { - background-color : #FF704E; -} -/* ------------------------------------------------------------------ */ -/* Homepage / body-flow HTML5 markup */ -/*
and headings. */ -/* Scoped to direct body children to avoid affecting div.toc lists. */ -/* ------------------------------------------------------------------ */ -body > ul, -body > ol { - margin-left : 5%%; - margin-right : 2em; - margin-top : 0.8em; - margin-bottom : 0.8em; - padding-left : 1.5em; - list-style-position : outside; -} -body > ul { list-style-type : disc; } -body > ol { list-style-type : decimal; } -body > ul li, -body > ol li { - margin-left : 0; - margin-right : 0; - margin-top : 0.3em; - margin-bottom : 0.3em; - line-height : 133%%; - background : none; - text-align : left; - text-indent : 0; -} -details { - margin-top : 1em; - margin-bottom : 0.5em; -} -summary { - margin-left : 5%%; - margin-right : 2em; - padding-left : 0.2em; - padding-top : 0.4em; - padding-bottom : 0.4em; - font-size : 1.6rem; - line-height : 133%%; - cursor : pointer; -} -details > ul, -details > ol { - margin-left : 5%%; - padding-left : 1.5em; -} -details > ul li, -details > ol li { - margin-left : 0; -} -┃", - _color_ocn_dark, - _css_indent, - _color_ocn_dark, -); - string _css_light_html_scroll = format(q"┃ -html { - font-size : 62.5%%; -} -*{ - padding : 0px; - margin : 0px; -} -body { - height : 100vh; - font-size : 1.6rem; - background-color : #FFFFFF; - 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.lnkocn:link { - color : %s; - text-decoration : none; -} -a.lnkocn:visited { - color : #32CD32; - text-decoration : none; -} -a.lnkocn:hover { - color : #777777; - font-size : 1.8rem; -} -a.lnkicon:link { - text-decoration : none; -} -a.lnkicon:visited { - text-decoration : none; -} -a.lnkicon:hover { - font-size : 160%%; -} -a:hover img { - background-color : #FFFFFF; -} -a:active { - color : #003399; - text-decoration : underline; -} -input { - color : #000000; - background-color : #FFFFFF; -} -div { - margin-left : 0; - margin-right : 0; -} -div.p { - margin-left : 5%%; - margin-right : 1%%; -} -div.substance { - width : 100%%; - background-color : #FFFFFF; -} -div.ocn { - width : 5%%; - float : right; - top : 0; - background-color : #FFFFFF; -} -div.endnote { - width : 95%%; - background-color : #FFFFFF; -} -div.toc { - position : absolute; - float : left; - margin : 0; - padding : 0; - padding-top : 0.5em; - border : 0; - width : 13em; - background-color : #EEEEEE; - margin-right : 1em; -} -div.summary { - margin : 0; - padding : 0; - border-left : 13em solid #EEEEEE; - padding-left : 1em; - background-color : #EEEEEE; -} -div.content, div.main_column { - margin : 0; - padding : 0; - border-left : 13em solid #FFFFFF; - padding-left : 1em; - padding-right : 1em; -} -div.content0, div.main_column0 { - margin : 0; - padding : 0; - border-left : 0%% solid #FFFFFF; - padding-left : 5%%; -} -div.scroll { - margin : 0; - padding : 0; - padding-left : 1em; - padding-right : 1em; -} -div.content:after { - content : ' '; - clear : both; - display : block; - height : 0; - overflow : hidden; -} -div.footer { - clear : left; - padding : 0.5em; - font-size : 1.4rem; - margin : 0; -} -div.toc ul { - list-style : none; - padding : 0; - margin : 0; -} -div.toc li ul a, li ul span.currentlink -{ - font-weight : normal; - font-size : 1.5rem; - padding-left : 2em; - background-color : #EEEEEE; -} -div.toc a, span.currentlink{ - display : block; - text-decoration : none; - padding-left : 0.5em; - color : #0000aa; -} -hr { - width : 90%%; - margin-left : 5%%; - margin-right : 2em; - margin-top : 1.8em; - margin-bottom : 1.8em; -} -span.currentlink { - text-decoration : none; - background-color : #AAAAAA; -} -div.toc a:visited { - color : #0000aa; -} -div.toc a:hover { - color : #000000; - background-color : #F9F9AA; -} -nav#toc ol { - list-style-type : none; -} -.norm, .bold, .verse, .group, .block, .alt { - line-height : 133%%; - margin-top : 12px; - margin-bottom : 0px; - padding-left : 0em; - text-indent : 0em; -} -p, h0, h1, h2, h3, h4, h5, h6, h7, ul, li { - display : block; - font-family : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; - margin-left : 5%%; - margin-right : 2em; -} -p { - font-size : 1.6rem; - font-weight : normal; - line-height : 133%%; - text-align : justify; - text-indent : 0mm; - margin-top : 0.8em; - margin-bottom : 0.8em; -} -img { - max-width : 100%%; - height : auto; -} -pre { - width : auto; - display : block; - clear : both; - color : #555555; -} -pre.codeline { - display : table; - clear : both; - table-layout : fixed; - margin-left : 5%%; - margin-right : 5%%; - width : 90%%; - white-space : pre-wrap; - border-style : none; - border-radius : 5px 5px 5px 5px; - box-shadow : 0 2px 5px #AAAAAA inset; - margin-bottom : 1em; - padding : 0.5em 1em; - page-break-inside : avoid; - word-wrap : break-word; - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - white-space : pre; - white-space : pre-wrap; - white-space : -moz-pre-wrap; - white-space : -o-pre-wrap; - background-color : #EEEEEE; - color : #000000; - font-size : 1.5rem; - line-height : 100%%; -} -pre.codeline::before { - counter-reset : linenum; -} -pre.codeline span.tr { - display : table-row; - counter-increment : linenum; -} -pre.codeline span.th { - display : table-cell; - user-select : none; - -moz-user-select : none; - -webkit-user-select : none; - padding : 0.5em 0.5em; - /* background-color : #666666; */ -} -pre.codeline span.th::before { - content : counter(linenum) "."; - color : #999999; - text-align : right; - display : block; -} -pre.codeline span.th { - width : 4em; -} -pre.codeline code { - display : table-cell; -} -p.code { - border-style : none; -} -p.spaced { white-space : pre; } -p.block { - white-space : pre; -} -p.group { } -p.alt { } -p.verse { - white-space : pre; - margin-bottom : 6px; -} -p.caption { - text-align : left; - font-size : 1.4rem; - display : inline; -} -p.endnote { - font-size : 1.55rem; - line-height : 120%%; - text-align : left; - margin-right : 15mm; - padding-left : 1em; - text-indent : -1em; -} -p.center { - text-align : center; -} -p.bold { - font-weight : bold; -} -p.bold_left { - font-weight : bold; - text-align : left; -} -p.centerbold { - text-align : center; - font-weight : bold; -} -p.em { - font-weight : bold; - font-style : normal; - background : #FFF3B6; -} -.small, .small_center { - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 0px; - margin-right : 6px; -} -p.small { - text-align : left; -} -p.small_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -.tiny, .tiny_left, .tiny_right, .tiny_center { - font-size : 1.2rem; - margin-top : 0px; - margin-bottom : 0px; - color : #777777; - margin-right : 6px; - text-align : left; -} -p.tiny { } -p.tiny_left { - margin-left : 0px; - margin-right : 0px; - text-align : left; -} -p.tiny_right { - margin-right : 1em; - text-align : right; -} -p.tiny_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -p.icons, .icons_center { - font-size : 100%%; - margin-top : 0px; - margin-bottom : 0px; - margin-right : 6px; -} -p.icons { - text-align : left; -} -p.concordance_word { - line-height : 150%%; - font-weight : bold; - display : inline; - margin-top : 4px; - margin-bottom : 1px; -} -p.concordance_count { - font-size : 1.4rem; - color : #777777; - display : inline; - margin-left : 0em; -} -p.concordance_object { - font-size : 1.4rem; - line-height : 120%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -p.book_index_lev1 { - line-height : 100%%; - margin-top : 4px; - margin-bottom : 1px; -} -p.book_index_lev2 { - line-height : 100%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -tt { - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - background-color : #EEEEEE; - color : #000000; -} -%s -note { white-space : pre; } -label.ocn { - width : 2%%; - float : right; - top : 0; - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 6px; - margin-right : 6px; - text-align : right; - color : %s; - -khtml-user-select : none; - -moz-user-select : none; - -ms-user-select : none; - -o-user-select : none; - -webkit-user-select : none; - user-select : none; -} -table { - display : block; - margin-left : 5%%; - margin-right : 2em; - background-color : inherit; -} -tr { } -th,td { - vertical-align : top; - text-align : left; -} -th { - font-weight : bold; -} -em { - font-weight : bold; - font-style : italic; -} -p.left,th.left,td.left { - text-align : left; -} -p.small_left,th.small_left,td.small_left { - text-align : left; - font-size : 1.4rem; -} -p.right,th.right,td.right { - text-align : right; -} -ul, li { - list-style-type : none; - list-style : none; - padding-left : 20px; - font-weight : normal; - line-height : 150%%; - text-align : left; - text-indent : 0mm; - margin-left : 1em; - margin-right : 2em; - margin-top : 3px; - margin-bottom : 3px; -} -li { - background : url(../image_sys/bullet_09.png) no-repeat 0px 6px; -} -ul { } -h0, h1, h2, h3, h4, h5, h6, h7 { - font-weight : bold; - line-height : 120%%; - text-align : left; - margin-top : 20px; - margin-bottom : 10px; -} -h4.norm, h5.norm, h6.norm, h7.norm { - margin-top : 10px; - margin-bottom : 0px; -} -h0 { font-size : 1.85rem; } -h1 { font-size : 1.8rem; } -h2 { font-size : 1.75rem; } -h3 { font-size : 1.7rem; } -h4 { font-size : 1.65rem; } -h5 { font-size : 1.6rem; } -h6 { font-size : 1.55rem; } -h7 { font-size : 1.5rem; } -h0, h1, h2, h3, h4, h5, h6, h7 { - text-shadow : .2em .2em .3em #808080; -} -h1.i { margin-left : 2em; } -h2.i { margin-left : 3em; } -h3.i { margin-left : 4em; } -h4.i { margin-left : 5em; } -h5.i { margin-left : 6em; } -h6.i { margin-left : 7em; } -h7.i { margin-left : 8em; } -h8.i { margin-left : 9em; } -h9.i { margin-left : 10em; } -.toc { - font-weight : normal; - margin-top : 6px; - margin-bottom : 6px; -} -h0.toc { - margin-left : 1em; - font-size : 1.85rem; - line-height : 150%%; -} -h1.toc { - margin-left : 1em; - font-size : 1.8rem; - line-height : 150%%; -} -h2.toc { - margin-left : 2em; - font-size : 1.75rem; - line-height : 140%%; -} -h3.toc { - margin-left : 3em; - font-size : 1.7rem; - line-height : 120%%; -} -h4.toc { - margin-left : 4em; - font-size : 1.65rem; - line-height : 120%%; -} -h5.toc { - margin-left : 5em; - font-size : 1.6rem; - line-height : 110%%; -} -h6.toc { - margin-left : 6em; - font-size : 1.55rem; - line-height : 110%%; -} -h7.toc { - margin-left : 7em; - font-size : 1.5rem; - line-height : 100%%; -} -.subtoc { - margin-right : 34%%; - font-weight : normal; -} -h5.subtoc { - margin-left : 2em; - font-size : 1.45rem; - margin-top : 2px; - margin-bottom : 2px; -} -h6.subtoc { - margin-left : 3em; - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 0px; -} -h7.subtoc { - margin-left : 4em; - font-size : 1.35rem; - margin-top : 0px; - margin-bottom : 0px; -} -input, select, textarea { - font-size : 2.2rem; -} -input[type="text"] { - font-size : 1.8rem; - line-height : 120%%; -} -button[type="submit"] { - font-size : 1.8rem; - line-height : 120%%; -} -p.form { - font-size : 2.2rem; - line-height : 150%%; -} -/* flex */ -.flex-menu-bar { - display : -webkit-flex; - display : flex; - -webkit-flex-wrap : wrap; - -webkit-align-items : center; - align-items : center; - width : 100%%; - margin-left : 5%%; - margin-right : 2%%; - background-color : #FFFFFF; -} -.flex-menu-option { - background-color : #FFFFFF; - margin-right : 4px; -} -.flex-list { - display : -webkit-flex; - display : flex; - -webkit-align-items : center; - display : block; - align-items : center; - width : 100%%; - background-color : #FFFFFF; -} -.flex-list-item { - background-color : #FFFFFF; - margin : 4px; -} -/* grid */ -.wrapper { - display : grid; - grid-template-columns : 100%%; - grid-template-areas : - "headband" - "doc_header" - "doc_title" - "doc_toc" - "doc_prefix" - "doc_intro" - "doc_body" - "doc_endnotes" - "doc_glossary" - "doc_biblio" - "doc_bookindex" - "doc_blurb" - "doc_suffix"; - margin : 0px; - padding : 0px; - background-color : #FFFFFF; -} -.delimit { - border-style : none; - border-color : #FFFFFF; - padding : 10px; -} -.headband { - grid-area : headband; - background-color : #FFFFFF; -} -.doc_header { - grid-area : doc_header; -} -.doc_title { - grid-area : doc_title; -} -.doc_toc { - grid-area : doc_toc; -} -.doc_prefix { - grid-area : doc_prefix; -} -.doc_intro { - grid-area : doc_intro; -} -.doc_body { - grid-area : doc_body; -} -.doc_endnotes { - grid-area : doc_endnotes; -} -.doc_glossary { - grid-area : doc_glossary; -} -.doc_biblio { - grid-area : doc_biblio; -} -.doc_bookindex { - grid-area : doc_bookindex; -} -.doc_blurb { - grid-area : doc_blurb; -} -.doc_suffix { - grid-area : doc_suffix; -} -.nav-ul { - list-style : none; - float : left; -} -.nav-li { - float : left; - padding-right : 0.7em; -} -.nav-li a { - text-decoration : none; - color : #FFFFFF; -} -footer { - background-color : #00704E; -} -/* ------------------------------------------------------------------ */ -/* Homepage / body-flow HTML5 markup */ -/*
and headings. */ -/* Scoped to direct body children to avoid affecting div.toc lists. */ -/* ------------------------------------------------------------------ */ -body > ul, -body > ol { - margin-left : 5%%; - margin-right : 2em; - margin-top : 0.8em; - margin-bottom : 0.8em; - padding-left : 1.5em; - list-style-position : outside; -} -body > ul { list-style-type : disc; } -body > ol { list-style-type : decimal; } -body > ul li, -body > ol li { - margin-left : 0; - margin-right : 0; - margin-top : 0.3em; - margin-bottom : 0.3em; - line-height : 133%%; - background : none; - text-align : left; - text-indent : 0; -} -details { - margin-top : 1em; - margin-bottom : 0.5em; -} -summary { - margin-left : 5%%; - margin-right : 2em; - padding-left : 0.2em; - padding-top : 0.4em; - padding-bottom : 0.4em; - font-size : 1.6rem; - line-height : 133%%; - cursor : pointer; -} -details > ul, -details > ol { - margin-left : 5%%; - padding-left : 1.5em; -} -details > ul li, -details > ol li { - margin-left : 0; -} -┃", - _color_ocn_light, - _css_indent, - _color_ocn_light, -); - string _css_dark_html_scroll = format(q"┃ -html { -} -*{ - padding : 0px; - margin : 0px; -} -body { - height : 100vh; - background-color : #000000; - 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.lnkocn:link { - color : %s; - text-decoration : none; -} -a.lnkocn:visited { - color : #9ACD32; - text-decoration : none; -} -a.lnkocn:hover { - color : #BBBBBB; - font-size : 1.8rem; -} -a.lnkicon:link { - text-decoration : none; -} -a.lnkicon:visited { - text-decoration : none; -} -a.lnkicon:hover { - color : #BBBBBB; - font-size : 120%%; -} -a:hover img { - background-color : #000000; -} -a:active { - color : #888888; - text-decoration : underline; -} -input { - color : #FFFFFF; - background-color : #777777; -} -div { - margin-left : 0; - margin-right : 0; -} -div.p { - margin-left : 5%%; - margin-right : 1%%; -} -div.substance { - width : 100%%; - background-color : #000000; -} -div.ocn { - width : 5%%; - float : right; - top : 0; - background-color : #000000; -} -div.endnote { - width : 95%%; - background-color : #000000; -} -div.toc { - position : absolute; - float : left; - margin : 0; - padding : 0; - padding-top : 0.5em; - border : 0; - width : 13em; - background-color : #111111; - margin-right : 1em; -} -div.summary { - margin : 0; - padding : 0; - border-left : 13em solid #111111; - padding-left : 1em; - background-color : #111111; -} -div.content, div.main_column { - margin : 0; - padding : 0; - border-left : 13em solid #000000; - padding-left : 1em; - padding-right : 1em; -} -div.content0, div.main_column0 { - margin : 0; - padding : 0; - border-left : 0%% solid #000000; - padding-left : 5%%; -} -div.scroll { - margin : 0; - padding : 0; - padding-left : 1em; - padding-right : 1em; -} -div.content:after { - content : ' '; - clear : both; - display : block; - height : 0; - overflow : hidden; -} -div.footer { - clear : left; - padding : 0.5em; - font-size : 1.4rem; - margin : 0; -} -div.toc ul { - list-style : none; - padding : 0; - margin : 0; -} -div.toc li ul a, li ul span.currentlink -{ - font-weight : normal; - font-size : 1.5rem; - padding-left : 2em; - background-color : #111111; -} -div.toc a, span.currentlink{ - display : block; - text-decoration : none; - padding-left : 0.5em; - color : #FF00AA; -} -hr { - width : 90%%; - margin-left : 5%%; - margin-right : 2em; - margin-top : 1.8em; - margin-bottom : 1.8em; -} -span.currentlink { - text-decoration : none; - background-color : #AAAAF9; -} -div.toc a:visited { - color : #FF00AA; -} -div.toc a:hover { - color : #CCCCCC; - background-color : #F9F9AA; -} -nav#toc ol { - list-style-type : none; -} -.norm, .bold, .verse, .group, .block, .alt { - line-height : 133%%; - margin-top : 12px; - margin-bottom : 0px; - padding-left : 0em; - text-indent : 0em; -} -p, h0, h1, h2, h3, h4, h5, h6, h7, ul, li { - display : block; - font-family : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; - margin-left : 5%%; - margin-right : 2em; -} -p { - font-size : 1.6rem; - font-weight : normal; - line-height : 133%%; - text-align : justify; - text-indent : 0mm; - margin-top : 0.8em; - margin-bottom : 0.8em; -} -img { - max-width : 100%%; - height : auto; -} -pre { - width : auto; - display : block; - clear : both; - color : #555555; -} -pre.codeline { - display : table; - clear : both; - table-layout : fixed; - margin-left : 5%%; - margin-right : 5%%; - width : 90%%; - white-space : pre-wrap; - border-style : none; - border-radius : 5px 5px 5px 5px; - box-shadow : 0 2px 5px #AAAAAA inset; - margin-bottom : 1em; - padding : 0.5em 1em; - page-break-inside : avoid; - word-wrap : break-word; - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - white-space : pre; - white-space : pre-wrap; - white-space : -moz-pre-wrap; - white-space : -o-pre-wrap; - background-color : #555555; - color : #DDDDDD; - font-size : 1.5rem; - line-height : 100%%; -} -pre.codeline::before { - counter-reset : linenum; -} -pre.codeline span.tr { - display : table-row; - counter-increment : linenum; -} -pre.codeline span.th { - display : table-cell; - user-select : none; - -moz-user-select : none; - -webkit-user-select : none; - padding : 0.5em 0.5em; -} -pre.codeline span.th::before { - content : counter(linenum) "."; - color : #999999; - text-align : right; - display : block; -} -pre.codeline span.th { - width : 4em; -} -pre.codeline code { - display : table-cell; -} -p.code { - border-style : none; -} -p.spaced { white-space : pre; } -p.block { - white-space : pre; -} -p.group { } -p.alt { } -p.verse { - white-space : pre; - margin-bottom : 6px; -} -p.caption { - text-align : left; - font-size : 1.4rem; - display : inline; -} -p.endnote { - font-size : 1.5rem; - line-height : 120%%; - text-align : left; - margin-right : 15mm; - padding-left : 1em; - text-indent : -1em; -} -p.center { - text-align : center; -} -p.bold { - font-weight : bold; -} -p.bold_left { - font-weight : bold; - text-align : left; -} -p.centerbold { - text-align : center; - font-weight : bold; -} -p.em { - font-weight : bold; - font-style : normal; - background : #FFF3B6; -} -.small, .small_center { - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 0px; - margin-right : 6px; -} -p.small { - text-align : left; -} -p.small_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -.tiny, .tiny_left, .tiny_right, .tiny_center { - font-size : 1.35rem; - margin-top : 0px; - margin-bottom : 0px; - color : #EEEEEE; - margin-right : 6px; - text-align : left; -} -p.tiny { } -p.tiny_left { - margin-left : 0px; - margin-right : 0px; - text-align : left; -} -p.tiny_right { - margin-right : 1em; - text-align : right; -} -p.tiny_center { - margin-left : 0px; - margin-right : 0px; - text-align : center; -} -p.concordance_word { - line-height : 150%%; - font-weight : bold; - display : inline; - margin-top : 4px; - margin-bottom : 1px; -} -p.concordance_count { - font-size : 1.4rem; - color : #555555; - display : inline; - margin-left : 0em; -} -p.concordance_object { - font-size : 1.4rem; - line-height : 120%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -p.book_index_lev1 { - line-height : 100%%; - margin-top : 4px; - margin-bottom : 1px; -} -p.book_index_lev2 { - line-height : 100%%; - text-align : left; - margin-left : 3em; - margin-top : 1px; - margin-bottom : 3px; -} -tt { - font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; - background-color : #555555; - color : #DDDDDD; -} -%s -note { white-space : pre; } -label.ocn { - width : 2%%; - float : right; - top : 0; - font-size : 1.4rem; - margin-top : 0px; - margin-bottom : 6px; - margin-right : 6px; - text-align : right; - color : %s; - -khtml-user-select : none; - -moz-user-select : none; - -ms-user-select : none; - -o-user-select : none; - -webkit-user-select : none; - user-select : none; -} -table { - display : block; - margin-left : 5%%; - margin-right : 2em; - background-color : inherit; -} -tr { } -th,td { - vertical-align : top; - text-align : left; -} -th { - font-weight : bold; -} -em { - font-weight : bold; - font-style : italic; -} -p.left,th.left,td.left { - text-align : left; -} -p.small_left,th.small_left,td.small_left { - text-align : left; - font-size : 1.4rem; -} -p.right,th.right,td.right { - text-align : right; -} -ul, li { - list-style-type : none; - list-style : none; - padding-left : 20px; - font-weight : normal; - line-height : 150%%; - text-align : left; - text-indent : 0mm; - margin-left : 1em; - margin-right : 2em; - margin-top : 3px; - margin-bottom : 3px; -} -li { - background : (../image_sys/bullet_09.png) no-repeat 0px 6px; -} -ul { } -h0, h1, h2, h3, h4, h5, h6, h7 { - font-weight : bold; - line-height : 120%%; - text-align : left; - margin-top : 20px; - margin-bottom : 10px; -} -h4.norm, h5.norm, h6.norm, h7.norm { - margin-top : 10px; - margin-bottom : 0px; -} -h0 { font-size : 1.9rem; } -h1 { font-size : 1.8rem; } -h2 { font-size : 1.75rem; } -h3 { font-size : 1.7rem; } -h4 { font-size : 1.65rem; } -h5 { font-size : 1.6rem; } -h6 { font-size : 1.55rem; } -h7 { font-size : 1.5rem; } -h0, h1, h2, h3, h4, h5, h6, h7 { - text-shadow : .2em .2em .3em #999999; -} -h1.i { margin-left : 2em; } -h2.i { margin-left : 3em; } -h3.i { margin-left : 4em; } -h4.i { margin-left : 5em; } -h5.i { margin-left : 6em; } -h6.i { margin-left : 7em; } -h7.i { margin-left : 8em; } -h8.i { margin-left : 9em; } -h9.i { margin-left : 10em; } -.toc { - font-weight : normal; - margin-top : 6px; - margin-bottom : 6px; -} -h0.toc { - margin-left : 1em; - font-size : 1.8rem; - line-height : 150%%; -} -h1.toc { - margin-left : 1em; - font-size : 1.75rem; - line-height : 150%%; -} -h2.toc { - margin-left : 2em; - font-size : 1.7rem; - line-height : 140%%; -} -h3.toc { - margin-left : 3em; - font-size : 1.65rem; - line-height : 120%%; -} -h4.toc { - margin-left : 4em; - font-size : 1.6rem; - line-height : 120%%; -} -h5.toc { - margin-left : 5em; - font-size : 1.5rem; - line-height : 110%%; -} -h6.toc { - margin-left : 6em; - font-size : 1.5rem; - line-height : 110%%; -} -h7.toc { - margin-left : 7em; - font-size : 1.45rem; - line-height : 100%%; -} -.subtoc { - margin-right : 34%%; - font-weight : normal; -} -h5.subtoc { - margin-left : 2em; - font-size : 1.4rem; - margin-top : 2px; - margin-bottom : 2px; -} -h6.subtoc { - margin-left : 3em; - font-size : 1.35; - margin-top : 0px; - margin-bottom : 0px; -} -h7.subtoc { - margin-left : 4em; - font-size : 1.3rem; - margin-top : 0px; - margin-bottom : 0px; -} -input, select, textarea { - font-size : 2.2rem; -} -input[type="text"] { - font-size : 1.8rem; - line-height : 120%%; -} -button[type="submit"] { - font-size : 1.8rem; - line-height : 120%%; -} -p.form { - font-size : 2.2rem; - line-height : 150%%; -} -/* flex */ -.flex-menu-bar { - display : -webkit-flex; - display : flex; - -webkit-flex-wrap : wrap; - -webkit-align-items : center; - align-items : center; - width : 100%%; - margin-left : 5%%; - margin-right : 2%%; - background-color : #000000; -} -.flex-menu-option { - background-color : #000000; - margin-right : 4px; -} -.flex-list { - display : -webkit-flex; - display : flex; - -webkit-align-items : center; - display : block; - align-items : center; - width : 100%%; - background-color : #000000; -} -.flex-list-item { - background-color : #000000; - margin : 4px; -} -/* grid */ -.wrapper { - display : grid; - grid-template-columns : 100%%; - grid-template-areas : - "headband" - "doc_header" - "doc_title" - "doc_toc" - "doc_prefix" - "doc_intro" - "doc_body" - "doc_endnotes" - "doc_glossary" - "doc_biblio" - "doc_bookindex" - "doc_blurb" - "doc_suffix"; - margin : 0px; - padding : 0px; - background-color : #000000; -} -.delimit { - border-style : none; - border-color : #000000; - padding : 10px; -} -.headband { - grid-area : headband; - background-color : #000000; -} -.doc_header { - grid-area : doc_header; -} -.doc_title { - grid-area : doc_title; -} -.doc_toc { - grid-area : doc_toc; -} -.doc_prefix { - grid-area : doc_prefix; -} -.doc_intro { - grid-area : doc_intro; -} -.doc_body { - grid-area : doc_body; -} -.doc_endnotes { - grid-area : doc_endnotes; -} -.doc_glossary { - grid-area : doc_glossary; -} -.doc_biblio { - grid-area : doc_biblio; -} -.doc_bookindex { - grid-area : doc_bookindex; -} -.doc_blurb { - grid-area : doc_blurb; -} -.doc_suffix { - grid-area : doc_suffix; -} -.nav-ul { - list-style : none; - float : left; -} -.nav-li { - float : left; - padding-right : 0.7em; -} -.nav-li a { - text-decoration : none; - color : #000000; -} -footer { - background-color : #FF704E; -} -/* ------------------------------------------------------------------ */ -/* Homepage / body-flow HTML5 markup */ -/*
and headings. */
-/* Scoped to direct body children to avoid affecting div.toc lists. */
-/* ------------------------------------------------------------------ */
-body > ul,
-body > ol {
- margin-left : 5%%;
- margin-right : 2em;
- margin-top : 0.8em;
- margin-bottom : 0.8em;
- padding-left : 1.5em;
- list-style-position : outside;
-}
-body > ul { list-style-type : disc; }
-body > ol { list-style-type : decimal; }
-body > ul li,
-body > ol li {
- margin-left : 0;
- margin-right : 0;
- margin-top : 0.3em;
- margin-bottom : 0.3em;
- line-height : 133%%;
- background : none;
- text-align : left;
- text-indent : 0;
-}
-details {
- margin-top : 1em;
- margin-bottom : 0.5em;
-}
-summary {
- margin-left : 5%%;
- margin-right : 2em;
- padding-left : 0.2em;
- padding-top : 0.4em;
- padding-bottom : 0.4em;
- font-size : 1.6rem;
- line-height : 133%%;
- cursor : pointer;
-}
-details > ul,
-details > ol {
- margin-left : 5%%;
- padding-left : 1.5em;
-}
-details > ul li,
-details > ol li {
- margin-left : 0;
-}
-┃",
- _color_ocn_dark,
- _css_indent,
- _color_ocn_dark,
-);
- string _css_light_epub = format(q"┃
-html {
- font-size : 62.5%%;
-}
-*{
- padding : 0px;
- margin : 0px;
-}
-body {
- height : 100vh;
- font-size : 1.6rem;
- background-color : #FFFFFF;
- 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.lnkocn:link {
- color : %s;
- text-decoration : none;
-}
-a.lnkocn:visited {
- color : #32CD32;
- text-decoration : none;
-}
-a.lnkocn:hover {
- color : #777777;
- font-size : 1.8rem;
-}
-a.lnkicon:link {
- text-decoration : none;
-}
-a.lnkicon:visited {
- text-decoration : none;
-}
-a.lnkicon:hover {
- font-size : 160%%;
-}
-a:hover img {
- background-color : #FFFFFF;
-}
-a:active {
- color : #003399;
- text-decoration : underline;
-}
-input {
- color : #000000;
- background-color : #FFFFFF;
-}
-div {
- margin-left : 0;
- margin-right : 0;
-}
-div.p {
- margin-left : 5%%;
- margin-right : 1%%;
-}
-div.substance {
- width : 100%%;
- background-color : #FFFFFF;
-}
-div.ocn {
- width : 5%%;
- float : right;
- top : 0;
- background-color : #FFFFFF;
-}
-div.endnote {
- width : 95%%;
- background-color : #FFFFFF;
-}
-div.toc {
- position : absolute;
- float : left;
- margin : 0;
- padding : 0;
- padding-top : 0.5em;
- border : 0;
- width : 13em;
- background-color : #EEEEEE;
- margin-right : 1em;
-}
-div.summary {
- margin : 0;
- padding : 0;
- border-left : 13em solid #EEEEEE;
- padding-left : 1em;
- background-color : #EEEEEE;
-}
-div.content, div.main_column {
- margin : 0;
- padding : 0;
- border-left : 13em solid #FFFFFF;
- padding-left : 1em;
- padding-right : 1em;
-}
-div.content0, div.main_column0 {
- margin : 0;
- padding : 0;
- border-left : 0%% solid #FFFFFF;
- padding-left : 5%%;
-}
-div.scroll {
- margin : 0;
- padding : 0;
- padding-left : 1em;
- padding-right : 1em;
-}
-div.content:after {
- content : ' ';
- clear : both;
- display : block;
- height : 0;
- overflow : hidden;
-}
-div.footer {
- clear : left;
- padding : 0.5em;
- font-size : 1.4rem;
- margin : 0;
-}
-div.toc ul {
- list-style : none;
- padding : 0;
- margin : 0;
-}
-div.toc li ul a, li ul span.currentlink
-{
- font-weight : normal;
- font-size : 1.5rem;
- padding-left : 2em;
- background-color : #EEEEEE;
-}
-div.toc a, span.currentlink{
- display : block;
- text-decoration : none;
- padding-left : 0.5em;
- color : #0000aa;
-}
-hr {
- width : 90%%;
- margin-left : 5%%;
- margin-right : 2em;
- margin-top : 1.8em;
- margin-bottom : 1.8em;
-}
-span.currentlink {
- text-decoration : none;
- background-color : #AAAAAA;
-}
-div.toc a:visited {
- color : #0000aa;
-}
-div.toc a:hover {
- color : #000000;
- background-color : #F9F9AA;
-}
-nav#toc ol {
- list-style-type : none;
-}
-.norm, .bold, .verse, .group, .block, .alt {
- line-height : 133%%;
- margin-top : 12px;
- margin-bottom : 0px;
- padding-left : 0em;
- text-indent : 0em;
-}
-p, h0, h1, h2, h3, h4, h5, h6, h7, ul, li {
- display : block;
- font-family : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman;
- margin-left : 5%%;
- margin-right : 2em;
-}
-p {
- font-size : 1.6rem;
- font-weight : normal;
- line-height : 133%%;
- text-align : justify;
- text-indent : 0mm;
- margin-top : 0.8em;
- margin-bottom : 0.8em;
-}
-img {
- max-width : 100%%;
- height : auto;
-}
-pre {
- width : auto;
- display : block;
- clear : both;
- color : #555555;
-}
-pre.codeline {
- display : table;
- clear : both;
- table-layout : fixed;
- margin-left : 5%%;
- margin-right : 5%%;
- width : 90%%;
- white-space : pre-wrap;
- border-style : none;
- border-radius : 5px 5px 5px 5px;
- box-shadow : 0 2px 5px #AAAAAA inset;
- margin-bottom : 1em;
- padding : 0.5em 1em;
- page-break-inside : avoid;
- word-wrap : break-word;
- font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace;
- white-space : pre;
- white-space : pre-wrap;
- white-space : -moz-pre-wrap;
- white-space : -o-pre-wrap;
- background-color : #EEEEEE;
- color : #000000;
- font-size : 1.5rem;
- line-height : 100%%;
-}
-pre.codeline::before {
- counter-reset : linenum;
-}
-pre.codeline span.tr {
- display : table-row;
- counter-increment : linenum;
-}
-pre.codeline span.th {
- display : table-cell;
- user-select : none;
- -moz-user-select : none;
- -webkit-user-select : none;
- padding : 0.5em 0.5em;
- /* background-color : #666666; */
-}
-pre.codeline span.th::before {
- content : counter(linenum) ".";
- color : #999999;
- text-align : right;
- display : block;
-}
-pre.codeline span.th {
- width : 4em;
-}
-pre.codeline code {
- display : table-cell;
-}
-p.code {
- border-style : none;
-}
-p.spaced { white-space : pre; }
-p.block {
- white-space : pre;
-}
-p.group { }
-p.alt { }
-p.verse {
- white-space : pre;
- margin-bottom : 6px;
-}
-p.caption {
- text-align : left;
- font-size : 1.4rem;
- display : inline;
-}
-p.endnote {
- font-size : 1.55rem;
- line-height : 120%%;
- text-align : left;
- margin-right : 15mm;
- padding-left : 1em;
- text-indent : -1em;
-}
-p.center {
- text-align : center;
-}
-p.bold {
- font-weight : bold;
-}
-p.bold_left {
- font-weight : bold;
- text-align : left;
-}
-p.centerbold {
- text-align : center;
- font-weight : bold;
-}
-p.em {
- font-weight : bold;
- font-style : normal;
- background : #FFF3B6;
-}
-.small, .small_center {
- font-size : 1.4rem;
- margin-top : 0px;
- margin-bottom : 0px;
- margin-right : 6px;
-}
-p.small {
- text-align : left;
-}
-p.small_center {
- margin-left : 0px;
- margin-right : 0px;
- text-align : center;
-}
-.tiny, .tiny_left, .tiny_right, .tiny_center {
- font-size : 1.2rem;
- margin-top : 0px;
- margin-bottom : 0px;
- color : #777777;
- margin-right : 6px;
- text-align : left;
-}
-p.tiny { }
-p.tiny_left {
- margin-left : 0px;
- margin-right : 0px;
- text-align : left;
-}
-p.tiny_right {
- margin-right : 1em;
- text-align : right;
-}
-p.tiny_center {
- margin-left : 0px;
- margin-right : 0px;
- text-align : center;
-}
-p.icons, .icons_center {
- font-size : 100%%;
- margin-top : 0px;
- margin-bottom : 0px;
- margin-right : 6px;
-}
-p.icons {
- text-align : left;
-}
-p.concordance_word {
- line-height : 150%%;
- font-weight : bold;
- display : inline;
- margin-top : 4px;
- margin-bottom : 1px;
-}
-p.concordance_count {
- font-size : 1.4rem;
- color : #777777;
- display : inline;
- margin-left : 0em;
-}
-p.concordance_object {
- font-size : 1.4rem;
- line-height : 120%%;
- text-align : left;
- margin-left : 3em;
- margin-top : 1px;
- margin-bottom : 3px;
-}
-p.book_index_lev1 {
- line-height : 100%%;
- margin-top : 4px;
- margin-bottom : 1px;
-}
-p.book_index_lev2 {
- line-height : 100%%;
- text-align : left;
- margin-left : 3em;
- margin-top : 1px;
- margin-bottom : 3px;
-}
-tt {
- font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace;
- background-color : #EEEEEE;
- color : #000000;
-}
-%s
-note { white-space : pre; }
-label.ocn {
- width : 2%%;
- float : right;
- top : 0;
- font-size : 1.4rem;
- margin-top : 0px;
- margin-bottom : 6px;
- margin-right : 6px;
- text-align : right;
- color : %s;
- -khtml-user-select : none;
- -moz-user-select : none;
- -ms-user-select : none;
- -o-user-select : none;
- -webkit-user-select : none;
- user-select : none;
-}
-table {
- display : block;
- margin-left : 5%%;
- margin-right : 2em;
- background-color : inherit;
-}
-tr { }
-th,td {
- vertical-align : top;
- text-align : left;
-}
-th {
- font-weight : bold;
-}
-em {
- font-weight : bold;
- font-style : italic;
-}
-p.left,th.left,td.left {
- text-align : left;
-}
-p.small_left,th.small_left,td.small_left {
- text-align : left;
- font-size : 1.4rem;
-}
-p.right,th.right,td.right {
- text-align : right;
-}
-ul, li {
- list-style-type : none;
- list-style : none;
- padding-left : 20px;
- font-weight : normal;
- line-height : 150%%;
- text-align : left;
- text-indent : 0mm;
- margin-left : 1em;
- margin-right : 2em;
- margin-top : 3px;
- margin-bottom : 3px;
-}
-li {
- background : url(../image_sys/bullet_09.png) no-repeat 0px 6px;
-}
-ul { }
-h0, h1, h2, h3, h4, h5, h6, h7 {
- font-weight : bold;
- line-height : 120%%;
- text-align : left;
- margin-top : 20px;
- margin-bottom : 10px;
-}
-h4.norm, h5.norm, h6.norm, h7.norm {
- margin-top : 10px;
- margin-bottom : 0px;
-}
-h0 { font-size : 1.85rem; }
-h1 { font-size : 1.8rem; }
-h2 { font-size : 1.75rem; }
-h3 { font-size : 1.7rem; }
-h4 { font-size : 1.65rem; }
-h5 { font-size : 1.6rem; }
-h6 { font-size : 1.55rem; }
-h7 { font-size : 1.5rem; }
-h0, h1, h2, h3, h4, h5, h6, h7 {
- text-shadow : .2em .2em .3em #808080;
-}
-h1.i { margin-left : 2em; }
-h2.i { margin-left : 3em; }
-h3.i { margin-left : 4em; }
-h4.i { margin-left : 5em; }
-h5.i { margin-left : 6em; }
-h6.i { margin-left : 7em; }
-h7.i { margin-left : 8em; }
-h8.i { margin-left : 9em; }
-h9.i { margin-left : 10em; }
-.toc {
- font-weight : normal;
- margin-top : 6px;
- margin-bottom : 6px;
-}
-h0.toc {
- margin-left : 1em;
- font-size : 1.85rem;
- line-height : 150%%;
-}
-h1.toc {
- margin-left : 1em;
- font-size : 1.8rem;
- line-height : 150%%;
-}
-h2.toc {
- margin-left : 2em;
- font-size : 1.75rem;
- line-height : 140%%;
-}
-h3.toc {
- margin-left : 3em;
- font-size : 1.7rem;
- line-height : 120%%;
-}
-h4.toc {
- margin-left : 4em;
- font-size : 1.65rem;
- line-height : 120%%;
-}
-h5.toc {
- margin-left : 5em;
- font-size : 1.6rem;
- line-height : 110%%;
-}
-h6.toc {
- margin-left : 6em;
- font-size : 1.55rem;
- line-height : 110%%;
-}
-h7.toc {
- margin-left : 7em;
- font-size : 1.5rem;
- line-height : 100%%;
-}
-.subtoc {
- margin-right : 34%%;
- font-weight : normal;
-}
-h5.subtoc {
- margin-left : 2em;
- font-size : 1.45rem;
- margin-top : 2px;
- margin-bottom : 2px;
-}
-h6.subtoc {
- margin-left : 3em;
- font-size : 1.4rem;
- margin-top : 0px;
- margin-bottom : 0px;
-}
-h7.subtoc {
- margin-left : 4em;
- font-size : 1.35rem;
- margin-top : 0px;
- margin-bottom : 0px;
-}
-input, select, textarea {
- font-size : 2.2rem;
-}
-input[type="text"] {
- font-size : 1.8rem;
- line-height : 120%%;
-}
-button[type="submit"] {
- font-size : 1.8rem;
- line-height : 120%%;
-}
-p.form {
- font-size : 2.2rem;
- line-height : 150%%;
-}
-
-┃",
- _color_ocn_light,
- _css_indent,
- _color_ocn_light,
-);
- string _css_dark_epub = format(q"┃
-html {
-}
-*{
- padding : 0px;
- margin : 0px;
-}
-body {
- height : 100vh;
- background-color : #000000;
- 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.lnkocn:link {
- color : %s;
- text-decoration : none;
-}
-a.lnkocn:visited {
- color : #9ACD32;
- text-decoration : none;
-}
-a.lnkocn:hover {
- color : #BBBBBB;
- font-size : 1.8rem;
-}
-a.lnkicon:link {
- text-decoration : none;
-}
-a.lnkicon:visited {
- text-decoration : none;
-}
-a.lnkicon:hover {
- color : #BBBBBB;
- font-size : 120%%;
-}
-a:hover img {
- background-color : #000000;
-}
-a:active {
- color : #888888;
- text-decoration : underline;
-}
-input {
- color : #FFFFFF;
- background-color : #777777;
-}
-div {
- margin-left : 0;
- margin-right : 0;
-}
-div.p {
- margin-left : 5%%;
- margin-right : 1%%;
-}
-div.substance {
- width : 100%%;
- background-color : #000000;
-}
-div.ocn {
- width : 5%%;
- float : right;
- top : 0;
- background-color : #000000;
-}
-div.endnote {
- width : 95%%;
- background-color : #000000;
-}
-div.toc {
- position : absolute;
- float : left;
- margin : 0;
- padding : 0;
- padding-top : 0.5em;
- border : 0;
- width : 13em;
- background-color : #111111;
- margin-right : 1em;
-}
-div.summary {
- margin : 0;
- padding : 0;
- border-left : 13em solid #111111;
- padding-left : 1em;
- background-color : #111111;
-}
-div.content, div.main_column {
- margin : 0;
- padding : 0;
- border-left : 13em solid #000000;
- padding-left : 1em;
- padding-right : 1em;
-}
-div.content0, div.main_column0 {
- margin : 0;
- padding : 0;
- border-left : 0%% solid #000000;
- padding-left : 5%%;
-}
-div.scroll {
- margin : 0;
- padding : 0;
- padding-left : 1em;
- padding-right : 1em;
-}
-div.content:after {
- content : ' ';
- clear : both;
- display : block;
- height : 0;
- overflow : hidden;
-}
-div.footer {
- clear : left;
- padding : 0.5em;
- font-size : 1.4rem;
- margin : 0;
-}
-div.toc ul {
- list-style : none;
- padding : 0;
- margin : 0;
-}
-div.toc li ul a, li ul span.currentlink
-{
- font-weight : normal;
- font-size : 1.5rem;
- padding-left : 2em;
- background-color : #111111;
-}
-div.toc a, span.currentlink{
- display : block;
- text-decoration : none;
- padding-left : 0.5em;
- color : #FF00AA;
-}
-hr {
- width : 90%%;
- margin-left : 5%%;
- margin-right : 2em;
- margin-top : 1.8em;
- margin-bottom : 1.8em;
-}
-span.currentlink {
- text-decoration : none;
- background-color : #AAAAF9;
-}
-div.toc a:visited {
- color : #FF00AA;
-}
-div.toc a:hover {
- color : #CCCCCC;
- background-color : #F9F9AA;
-}
-nav#toc ol {
- list-style-type : none;
-}
-.norm, .bold, .verse, .group, .block, .alt {
- line-height : 133%%;
- margin-top : 12px;
- margin-bottom : 0px;
- padding-left : 0em;
- text-indent : 0em;
-}
-p, h0, h1, h2, h3, h4, h5, h6, h7, ul, li {
- display : block;
- font-family : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman;
- margin-left : 5%%;
- margin-right : 2em;
-}
-p {
- font-size : 1.6rem;
- font-weight : normal;
- line-height : 133%%;
- text-align : justify;
- text-indent : 0mm;
- margin-top : 0.8em;
- margin-bottom : 0.8em;
-}
-img {
- max-width : 100%%;
- height : auto;
-}
-pre {
- width : auto;
- display : block;
- clear : both;
- color : #555555;
-}
-pre.codeline {
- display : table;
- clear : both;
- table-layout : fixed;
- margin-left : 5%%;
- margin-right : 5%%;
- width : 90%%;
- white-space : pre-wrap;
- border-style : none;
- border-radius : 5px 5px 5px 5px;
- box-shadow : 0 2px 5px #AAAAAA inset;
- margin-bottom : 1em;
- padding : 0.5em 1em;
- page-break-inside : avoid;
- word-wrap : break-word;
- font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace;
- white-space : pre;
- white-space : pre-wrap;
- white-space : -moz-pre-wrap;
- white-space : -o-pre-wrap;
- background-color : #555555;
- color : #DDDDDD;
- font-size : 1.5rem;
- line-height : 100%%;
-}
-pre.codeline::before {
- counter-reset : linenum;
-}
-pre.codeline span.tr {
- display : table-row;
- counter-increment : linenum;
-}
-pre.codeline span.th {
- display : table-cell;
- user-select : none;
- -moz-user-select : none;
- -webkit-user-select : none;
- padding : 0.5em 0.5em;
-}
-pre.codeline span.th::before {
- content : counter(linenum) ".";
- color : #999999;
- text-align : right;
- display : block;
-}
-pre.codeline span.th {
- width : 4em;
-}
-pre.codeline code {
- display : table-cell;
-}
-p.code {
- border-style : none;
-}
-p.spaced { white-space : pre; }
-p.block {
- white-space : pre;
-}
-p.group { }
-p.alt { }
-p.verse {
- white-space : pre;
- margin-bottom : 6px;
-}
-p.caption {
- text-align : left;
- font-size : 1.4rem;
- display : inline;
-}
-p.endnote {
- font-size : 1.5rem;
- line-height : 120%%;
- text-align : left;
- margin-right : 15mm;
- padding-left : 1em;
- text-indent : -1em;
-}
-p.center {
- text-align : center;
-}
-p.bold {
- font-weight : bold;
-}
-p.bold_left {
- font-weight : bold;
- text-align : left;
-}
-p.centerbold {
- text-align : center;
- font-weight : bold;
-}
-p.em {
- font-weight : bold;
- font-style : normal;
- background : #FFF3B6;
-}
-.small, .small_center {
- font-size : 1.4rem;
- margin-top : 0px;
- margin-bottom : 0px;
- margin-right : 6px;
-}
-p.small {
- text-align : left;
-}
-p.small_center {
- margin-left : 0px;
- margin-right : 0px;
- text-align : center;
-}
-.tiny, .tiny_left, .tiny_right, .tiny_center {
- font-size : 1.35rem;
- margin-top : 0px;
- margin-bottom : 0px;
- color : #EEEEEE;
- margin-right : 6px;
- text-align : left;
-}
-p.tiny { }
-p.tiny_left {
- margin-left : 0px;
- margin-right : 0px;
- text-align : left;
-}
-p.tiny_right {
- margin-right : 1em;
- text-align : right;
-}
-p.tiny_center {
- margin-left : 0px;
- margin-right : 0px;
- text-align : center;
-}
-p.concordance_word {
- line-height : 150%%;
- font-weight : bold;
- display : inline;
- margin-top : 4px;
- margin-bottom : 1px;
-}
-p.concordance_count {
- font-size : 1.4rem;
- color : #555555;
- display : inline;
- margin-left : 0em;
-}
-p.concordance_object {
- font-size : 1.4rem;
- line-height : 120%%;
- text-align : left;
- margin-left : 3em;
- margin-top : 1px;
- margin-bottom : 3px;
-}
-p.book_index_lev1 {
- line-height : 100%%;
- margin-top : 4px;
- margin-bottom : 1px;
-}
-p.book_index_lev2 {
- line-height : 100%%;
- text-align : left;
- margin-left : 3em;
- margin-top : 1px;
- margin-bottom : 3px;
-}
-tt {
- font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace;
- background-color : #555555;
- color : #DDDDDD;
-}
-%s
-note { white-space : pre; }
-label.ocn {
- width : 2%%;
- float : right;
- top : 0;
- font-size : 1.4rem;
- margin-top : 0px;
- margin-bottom : 6px;
- margin-right : 6px;
- text-align : right;
- color : %s;
- -khtml-user-select : none;
- -moz-user-select : none;
- -ms-user-select : none;
- -o-user-select : none;
- -webkit-user-select : none;
- user-select : none;
-}
-table {
- display : block;
- margin-left : 5%%;
- margin-right : 2em;
- background-color : inherit;
-}
-tr { }
-th,td {
- vertical-align : top;
- text-align : left;
-}
-th {
- font-weight : bold;
-}
-em {
- font-weight : bold;
- font-style : italic;
-}
-p.left,th.left,td.left {
- text-align : left;
-}
-p.small_left,th.small_left,td.small_left {
- text-align : left;
- font-size : 1.4rem;
-}
-p.right,th.right,td.right {
- text-align : right;
-}
-ul, li {
- list-style-type : none;
- list-style : none;
- padding-left : 20px;
- font-weight : normal;
- line-height : 150%%;
- text-align : left;
- text-indent : 0mm;
- margin-left : 1em;
- margin-right : 2em;
- margin-top : 3px;
- margin-bottom : 3px;
-}
-li {
- background : (../image_sys/bullet_09.png) no-repeat 0px 6px;
-}
-ul { }
-h0, h1, h2, h3, h4, h5, h6, h7 {
- font-weight : bold;
- line-height : 120%%;
- text-align : left;
- margin-top : 20px;
- margin-bottom : 10px;
-}
-h4.norm, h5.norm, h6.norm, h7.norm {
- margin-top : 10px;
- margin-bottom : 0px;
-}
-h0 { font-size : 1.9rem; }
-h1 { font-size : 1.8rem; }
-h2 { font-size : 1.75rem; }
-h3 { font-size : 1.7rem; }
-h4 { font-size : 1.65rem; }
-h5 { font-size : 1.6rem; }
-h6 { font-size : 1.55rem; }
-h7 { font-size : 1.5rem; }
-h0, h1, h2, h3, h4, h5, h6, h7 {
- text-shadow : .2em .2em .3em #999999;
-}
-h1.i { margin-left : 2em; }
-h2.i { margin-left : 3em; }
-h3.i { margin-left : 4em; }
-h4.i { margin-left : 5em; }
-h5.i { margin-left : 6em; }
-h6.i { margin-left : 7em; }
-h7.i { margin-left : 8em; }
-h8.i { margin-left : 9em; }
-h9.i { margin-left : 10em; }
-.toc {
- font-weight : normal;
- margin-top : 6px;
- margin-bottom : 6px;
-}
-h0.toc {
- margin-left : 1em;
- font-size : 1.8rem;
- line-height : 150%%;
-}
-h1.toc {
- margin-left : 1em;
- font-size : 1.75rem;
- line-height : 150%%;
-}
-h2.toc {
- margin-left : 2em;
- font-size : 1.7rem;
- line-height : 140%%;
-}
-h3.toc {
- margin-left : 3em;
- font-size : 1.65rem;
- line-height : 120%%;
-}
-h4.toc {
- margin-left : 4em;
- font-size : 1.6rem;
- line-height : 120%%;
-}
-h5.toc {
- margin-left : 5em;
- font-size : 1.5rem;
- line-height : 110%%;
-}
-h6.toc {
- margin-left : 6em;
- font-size : 1.5rem;
- line-height : 110%%;
-}
-h7.toc {
- margin-left : 7em;
- font-size : 1.45rem;
- line-height : 100%%;
-}
-.subtoc {
- margin-right : 34%%;
- font-weight : normal;
-}
-h5.subtoc {
- margin-left : 2em;
- font-size : 1.4rem;
- margin-top : 2px;
- margin-bottom : 2px;
-}
-h6.subtoc {
- margin-left : 3em;
- font-size : 1.35;
- margin-top : 0px;
- margin-bottom : 0px;
-}
-h7.subtoc {
- margin-left : 4em;
- font-size : 1.3rem;
- margin-top : 0px;
- margin-bottom : 0px;
-}
-input, select, textarea {
- font-size : 2.2rem;
-}
-input[type="text"] {
- font-size : 1.8rem;
- line-height : 120%%;
-}
-button[type="submit"] {
- font-size : 1.8rem;
- line-height : 120%%;
-}
-p.form {
- font-size : 2.2rem;
- line-height : 150%%;
-}
-
-┃",
- _color_ocn_dark,
- _css_indent,
- _color_ocn_dark,
-);
- auto css_() {
- struct _CSS {
- string html_seg = "/* spine css html seg stylesheet */\n";
- string html_scroll = "/* spine css html scroll stylesheet */\n";
- string epub = "/* spine css epub stylesheet */\n";
- }
- return _CSS();
- }
- auto css = css_();
- if (doc_matters.opt.action.css_theme_default) {
- css.html_seg ~= _css_light_html_seg;
- css.html_scroll ~= _css_light_html_scroll;
- css.epub ~= _css_light_epub;
- } else {
- css.html_seg ~= _css_dark_html_seg;
- css.html_scroll ~= _css_dark_html_scroll;
- css.epub ~= _css_dark_epub;
- }
- return css;
- }
-}
diff --git a/src/sisudoc/meta/conf_make_meta_json.d b/src/sisudoc/meta/conf_make_meta_json.d
deleted file mode 100644
index c996b12..0000000
--- a/src/sisudoc/meta/conf_make_meta_json.d
+++ /dev/null
@@ -1,693 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.meta.conf_make_meta_json;
-@safe:
-static template contentJSONtoSpineStruct() {
- import std.algorithm;
- import std.array;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.utf;
- import std.conv : to;
- import sisudoc.meta.conf_make_meta_structs;
- import sisudoc.meta.conf_make_meta_json;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- ConfComposite _struct_composite;
- auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) {
- mixin spineRgxIn;
- 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/sisudoc/meta/conf_make_meta_structs.d b/src/sisudoc/meta/conf_make_meta_structs.d
deleted file mode 100644
index 6bfd8fb..0000000
--- a/src/sisudoc/meta/conf_make_meta_structs.d
+++ /dev/null
@@ -1,309 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.conf_make_meta_structs;
-@safe:
-import std.exception;
-import std.json;
-import std.path;
-import std.regex;
-import std.stdio;
-import std.string;
-import std.typecons;
-import std.utf;
-import std.conv : to;
-import sisudoc.meta.defaults;
-import sisudoc.meta.rgx_yaml;
-import sisudoc.meta.rgx;
-mixin spineRgxIn;
-static auto rgx = RgxI();
-mixin spineRgxYamlTags;
-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 = "┥sisudoc.org┝┤https://sisudoc.org├"
- ~ " ┥doc-reform.org┝┤https://doc-reform.org├"
- ~ " ┥sources / git┝┤https://git.sisudoc.org/projects├";
- 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) {
- return _mk;
- }
- 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 = "┥sisudoc.org┝┤https://sisudoc.org├"
- ~ " ┥doc-reform.org┝┤https://doc-reform.org├"
- ~ " ┥sources / git┝┤https://git.sisudoc.org/projects├";
- 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/sisudoc/meta/conf_make_meta_yaml.d b/src/sisudoc/meta/conf_make_meta_yaml.d
deleted file mode 100644
index f4ee7d9..0000000
--- a/src/sisudoc/meta/conf_make_meta_yaml.d
+++ /dev/null
@@ -1,964 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.meta.conf_make_meta_yaml;
-@safe:
-template contentYAMLtoSpineStruct() {
- import std.algorithm;
- import std.array;
- import std.exception;
- import std.path;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.utf;
- import std.conv : to;
- import sisudoc.meta.conf_make_meta_structs;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx_yaml;
- import sisudoc.meta.rgx;
- ConfComposite _struct_composite;
- @system ConfComposite contentYAMLtoSpineStruct(C,Y,M,O,Cfg)(
- C _struct_composite,
- 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;
- }
- @system string _get_yaml_node_string(Y)(
- Y _yaml,
- string _return,
- string _title,
- string _subtitle,
- bool _munge=false
- ) {
- if ((_title in _yaml && _yaml[_title].type.sequence)
- && (_yaml[_title].type.mapping
- && _yaml[_title].tag.match(rgx_y.yaml_tag_is_map))
- ) {
- if (_subtitle in _yaml[_title]
- && _yaml[_title][_subtitle].type.string
- && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_str)
- ) {
- _return = (!(_munge))
- ? _yaml[_title][_subtitle].get!string
- : check_input_markup(_yaml[_title][_subtitle].get!string);
- }
- }
- return _return;
- }
- @system int _get_yaml_node_int(Y)(
- Y _yaml,
- int _return,
- string _title,
- string _subtitle
- ) {
- if ((_title in _yaml && _yaml[_title].type.sequence)
- && (_yaml[_title].type.mapping
- && _yaml[_title].tag.match(rgx_y.yaml_tag_is_map))
- ) {
- if (_subtitle in _yaml[_title]
- && _yaml[_title][_subtitle].type.string
- && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_int)
- ) {
- _return = _yaml[_title][_subtitle].get!int;
- } else if (_subtitle in _yaml[_title]
- && _yaml[_title][_subtitle].type.string
- && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_str)
- ) {
- _return = _yaml[_title][_subtitle].get!int;
- }
- }
- return _return;
- }
- confCompositeMakeBuild _mk;
- if (_identifier != "header") { // called only once per run anyway
- string _init_string;
- /+ 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 {
- _init_string = (_cfg.http_request_type.empty) ? "http" : _cfg.http_request_type;
- _struct_composite.conf.w_srv_http = _get_yaml_node_string(_yaml, _init_string, "webserv", "http");
- }
- if (_opt_action.cgi_search_title.length > 0) {
- _struct_composite.conf.w_srv_cgi_search_form_title = _opt_action.cgi_search_title;
- } else {
- _init_string = (_cfg.cgi_search_form_title.empty) ? "≅ SiSU spine search form" : _cfg.cgi_search_form_title;
- _struct_composite.conf.w_srv_cgi_search_form_title = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_search_form_title");
- }
- if (_opt_action.cgi_sqlite_search_filename.length > 0) {
- _struct_composite.conf.w_srv_cgi_search_script = _opt_action.cgi_sqlite_search_filename;
- } else {
- _init_string = (_cfg.cgi_filename.empty) ? "spine_search" : _cfg.cgi_filename;
- _struct_composite.conf.w_srv_cgi_search_script = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_search_script");
- }
- if (_opt_action.sqliteDB_filename.length > 0) {
- _struct_composite.conf.w_srv_db_sqlite_filename = _opt_action.sqliteDB_filename;
- } else {
- _init_string = (_cfg.db_sqlite_filename.empty) ? "spine.search.db" : _cfg.db_sqlite_filename;
- _struct_composite.conf.w_srv_db_sqlite_filename = _get_yaml_node_string(_yaml, _init_string, "webserv", "db_sqlite_filename");
- }
- if (_opt_action.sqliteDB_path.length > 0) {
- _struct_composite.conf.w_srv_db_sqlite_path = _opt_action.sqliteDB_path;
- } else {
- _init_string = (_cfg.db_sqlite_path.empty) ? "/var/www/sqlite" : _cfg.db_sqlite_path;
- _struct_composite.conf.w_srv_db_sqlite_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "db_sqlite_path");
- }
- if (_opt_action.cgi_url_action.length > 0) {
- _struct_composite.conf.w_srv_cgi_action
- = _opt_action.cgi_url_action;
- } else {
- _init_string = (_cfg.www_url_doc_root.empty) ? "http://locahost" : _cfg.www_url_doc_root; // "https://sisudoc.org"
- _struct_composite.conf.w_srv_cgi_action = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_action");
- 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; // not yet right
- }
- }
- 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 {
- _init_string = (_cfg.processing_path_doc_root.empty) ? "/var/www/spine" : _cfg.processing_path_doc_root;
- _struct_composite.conf.w_srv_data_root_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_root_path");
- }
- }
- if (_opt_action.cgi_bin_root.length > 0) {
- _struct_composite.conf.w_srv_cgi_bin_path = _opt_action.cgi_bin_root;
- } else {
- _init_string = (_cfg.cgi_bin_root.empty) ? "/var/www/cgi/cgi-bin" : _cfg.cgi_bin_root;
- _struct_composite.conf.w_srv_cgi_bin_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_bin_path");
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_root_part");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_data_root_part = _init_string; }
- } {
- _init_string = "image"; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "images_root_part");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_images_root_part = _init_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
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_http");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_data_http = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_http");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_http = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "host");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_host = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_bin_subpath");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_bin_subpath = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_port");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_port = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_user");
- if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_user = _init_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";
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_host");
- _struct_composite.conf.w_srv_cgi_host = (!(_init_string.empty)) ? _init_string : _struct_composite.conf.w_srv_host;
- }
- 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)?
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "processing", "concord_max");
- if (!(_init_string.empty)) { _struct_composite.conf.processing_concord_max = _init_string; }
- }
- if ("flag" in _yaml
- && _yaml["flag"].type.sequence
- ) {
- if (_yaml["flag"].type.mapping
- && _yaml["flag"].tag.match(rgx_y.yaml_tag_is_map)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act0");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act0 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act1");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act1 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act2");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act2 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act3");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act3 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act4");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act4 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act5");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act5 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act6");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act6 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act7");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act7 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act8");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act8 = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act9");
- if (!(_init_string.empty)) { _struct_composite.conf.flag_act9 = _init_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;
- _init_string = _set_papersize; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "papersize");
- if (!(_init_string.empty)) { _set_papersize = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "text_wrap");
- if (!(_init_string.empty)) { _struct_composite.conf.set_text_wrap = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "emphasis");
- if (!(_init_string.empty)) { _struct_composite.conf.set_emphasis = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "language");
- if (!(_init_string.empty)) { _struct_composite.conf.set_language = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "digest");
- if (!(_init_string.empty)) { _struct_composite.conf.set_digest = _init_string; }
- }
- }
- if ("search" in _yaml
- && _yaml["search"].type.sequence
- ) {
- if (_yaml["search"].type.mapping
- && _yaml["search"].tag.match(rgx_y.yaml_tag_is_map)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "flag");
- if (!(_init_string.empty)) { _struct_composite.conf.search_flag = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "action");
- if (!(_init_string.empty)) { _struct_composite.conf.search_action = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "db");
- if (!(_init_string.empty)) { _struct_composite.conf.search_db = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "title");
- if (!(_init_string.empty)) { _struct_composite.conf.search_title = _init_string; }
- }
- }
- }
- } else { // !(_identifier != "header")
- string _init_string;
- int _init_int;
- /+ make ------------------------------------------------------------------- +/
- if ("make" in _yaml
- && _yaml["make"].type.sequence
- ) {
- if (_yaml["make"].type.mapping
- && _yaml["make"].tag.match(rgx_y.yaml_tag_is_map)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "doc_type");
- if (!(_init_string.empty)) { _struct_composite.make_str.doc_type = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "breaks");
- if (!(_init_string.empty)) { _struct_composite.make_str.breaks = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "bold");
- if (!(_init_string.empty)) { _struct_composite.make_str.bold = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "cover_image");
- if (!(_init_string.empty)) { _struct_composite.make_str.cover_image = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "css");
- if (!(_init_string.empty)) { _struct_composite.make_str.css = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "emphasis");
- if (!(_init_string.empty)) { _struct_composite.make_str.emphasis = _init_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);
- foreach(string hbt; __match_footer_array.to!(string[])) {
- _struct_composite.make_str.footer ~= url_markup(hbt);
- }
- } else if ("footer" in _yaml["make"]
- && _yaml["make"]["footer"].type.string
- && _yaml["make"]["footer"].tag.match(rgx_y.yaml_tag_is_seq)
- ) {
- _struct_composite.make_str.footer = [];
- foreach(string hbt; _yaml["make"]["footer"]) {
- _struct_composite.make_str.footer ~= url_markup(hbt);
- }
- }
- 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;
- }
- }
- {
- _init_int = _get_yaml_node_int(_yaml, 99, "make", "auto_num_depth");
- if (!(_init_int == 99)) { _struct_composite.make_str.auto_num_depth = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "author");
- if (!(_init_string.empty)) { _struct_composite.meta.creator_author = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "email");
- if (!(_init_string.empty)) { _struct_composite.meta.creator_author_email = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "illustrator");
- if (!(_init_string.empty)) { _struct_composite.meta.creator_illustrator = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "translator");
- if (!(_init_string.empty)) { _struct_composite.meta.creator_translator = _init_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;
- }
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "edition");
- if (!(_init_string.empty)) { _struct_composite.meta.title_edition = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "full");
- if (!(_init_string.empty)) { _struct_composite.meta.title_full = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "language");
- if (!(_init_string.empty)) { _struct_composite.meta.title_language = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "note");
- if (!(_init_string.empty)) { _struct_composite.meta.title_note = _init_string; }
- }
- if ("subtitle" in _yaml["title"]) {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "subtitle");
- if (!(_init_string.empty)) { _struct_composite.meta.title_subtitle = _init_string; }
- } else if ("sub" in _yaml["title"]) {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "sub");
- if (!(_init_string.empty)) { _struct_composite.meta.title_subtitle = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "dewey");
- if (!(_init_string.empty)) { _struct_composite.meta.classify_dewey = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "loc");
- if (!(_init_string.empty)) { _struct_composite.meta.classify_loc = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "keywords");
- if (!(_init_string.empty)) { _struct_composite.meta.classify_keywords = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "added_to_site");
- if (!(_init_string.empty)) { _struct_composite.meta.date_added_to_site = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "available");
- if (!(_init_string.empty)) { _struct_composite.meta.date_available = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "created");
- if (!(_init_string.empty)) { _struct_composite.meta.date_created = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "issued");
- if (!(_init_string.empty)) { _struct_composite.meta.date_issued = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "modified");
- if (!(_init_string.empty)) { _struct_composite.meta.date_modified = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "published");
- if (!(_init_string.empty)) { _struct_composite.meta.date_published = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "valid");
- if (!(_init_string.empty)) { _struct_composite.meta.date_valid = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "abstract");
- if (!(_init_string.empty)) { _struct_composite.meta.notes_abstract = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "description");
- if (!(_init_string.empty)) { _struct_composite.meta.notes_description = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "summary");
- if (!(_init_string.empty)) { _struct_composite.meta.notes_summary = _init_string; }
- }
- }
- }
- if ("original" in _yaml
- && _yaml["original"].type.sequence
- ) {
- if (_yaml["original"].type.mapping
- && _yaml["original"].tag.match(rgx_y.yaml_tag_is_map)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "language");
- if (!(_init_string.empty)) { _struct_composite.meta.original_language = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "language_char");
- if (!(_init_string.empty)) { _struct_composite.meta.original_language_char = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "source");
- if (!(_init_string.empty)) { _struct_composite.meta.original_source = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "title");
- if (!(_init_string.empty)) { _struct_composite.meta.original_title = _init_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)
- ) {
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright", true);
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_text");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_text = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_audio");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_audio = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_cover");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_cover = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_illustrations");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_illustrations = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_photographs");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_photographs = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_translation");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_translation = _init_string; }
- } {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_video");
- if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_video = _init_string; }
- }
- {
- _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "license", true);
- if (!(_init_string.empty)) { _struct_composite.meta.rights_license = _init_string; }
- }
- }
- }
- }
- return _struct_composite;
- }
-}
-template configParseYAMLreturnSpineStruct() {
- import dyaml;
- import sisudoc.meta.conf_make_meta_structs;
- import sisudoc.meta.conf_make_meta_json;
- mixin contentYAMLtoSpineStruct;
- @system ConfComposite configParseYAMLreturnSpineStruct(T,M,O,Cfg)(
- T _document_struct,
- ConfComposite _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;
- import std.regex;
- import std.stdio;
- // import std.traits;
- import std.typecons;
- import std.utf;
- import std.conv : to;
- import dyaml;
- import sisudoc.meta.conf_make_meta_structs;
- import sisudoc.meta.conf_make_meta_json;
- import sisudoc.meta.rgx_yaml;
- import sisudoc.meta.rgx;
- mixin spineRgxIn;
- mixin contentJSONtoSpineStruct;
- static auto rgx = RgxI();
- mixin spineRgxYamlTags;
- static auto rgx_y = RgxYaml();
- @system ConfComposite docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(Src,M,O,Cfg)(
- Src header_src,
- ConfComposite _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/sisudoc/meta/defaults.d b/src/sisudoc/meta/defaults.d
deleted file mode 100644
index 53a791e..0000000
--- a/src/sisudoc/meta/defaults.d
+++ /dev/null
@@ -1,297 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.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/sisudoc/meta/doc_debugs.d b/src/sisudoc/meta/doc_debugs.d
deleted file mode 100644
index 40a0af5..0000000
--- a/src/sisudoc/meta/doc_debugs.d
+++ /dev/null
@@ -1,250 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
-
-+/
-/++
- output debugs
-+/
-module sisudoc.meta.doc_debugs;
-template spineDebugs() {
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx_files;
- import std.algorithm;
- import std.array;
- import std.container;
- import std.exception;
- import std.json;
- import std.stdio;
- import std.file;
- import std.path;
- import std.range;
- import std.regex;
- import std.string;
- import std.typecons;
- import std.utf;
- import std.conv : to;
- auto spineDebugs(S,T)(
- const S contents,
- T doc_matters,
- ) {
- 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/sisudoc/meta/metadoc.d b/src/sisudoc/meta/metadoc.d
deleted file mode 100644
index 421ff78..0000000
--- a/src/sisudoc/meta/metadoc.d
+++ /dev/null
@@ -1,307 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.metadoc;
-@safe:
-template spineAbstraction() {
- import std.datetime;
- import std.digest.crc;
- import std.digest.sha;
- import sisudoc.meta;
- import sisudoc.meta.metadoc_from_src;
- import sisudoc.meta.conf_make_meta_structs;
- import sisudoc.meta.conf_make_meta_json;
- import sisudoc.meta.defaults;
- import sisudoc.io_in.paths_source;
- import sisudoc.io_in.read_config_files;
- import sisudoc.io_in.read_source_files;
- mixin spineBiblio;
- enum makeMeta { make, meta }
- enum docAbst { doc_abstract_obj, doc_has }
- @system auto spineAbstraction(E,P,O,Cfg,M)(
- E _env,
- P program_info,
- O _opt_action,
- Cfg _cfg,
- M _manifest,
- ConfComposite _make_and_meta_struct
- ){
- { /+ document config/make file +/
- auto _config_document_struct = readConfigDoc!()(_manifest, _env);
- import sisudoc.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);
- auto doc_digests = _header_body_insertfilelist_imagelist.doc_digest; // CHECK, REVIEW, discard likely, other route taken
- 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.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 sisudoc.meta.conf_make_meta_yaml;
- _make_and_meta_struct =
- docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()(
- _header_body_insertfilelist_imagelist.header_raw,
- _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.sourcefile_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 ST_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;
- }
- ConfComposite conf_make_meta() {
- return _make_and_meta_struct;
- }
- auto doc_digest() {
- return doc_digests;
- }
- 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.insert_file_list;
- }
- auto image_list() {
- return _doc_has_struct.imagelist;
- }
- }
- return SRC_();
- }
- }
- auto doc_matters = ST_DocumentMatters();
- if ((_opt_action.debug_do)
- || (_opt_action.debug_do_stages)
- ) {
- writeln("- step4 complete for [", _manifest.src.filename, "]");
- }
- auto theDOC() {
- struct ST_DOC {
- const auto abstraction() {
- return doc_abstraction;
- }
- auto matters() {
- return doc_matters;
- }
- }
- return ST_DOC();
- }
- auto the_doc = theDOC();
- return the_doc;
- }
-}
diff --git a/src/sisudoc/meta/metadoc_from_src.d b/src/sisudoc/meta/metadoc_from_src.d
deleted file mode 100644
index 4967c1f..0000000
--- a/src/sisudoc/meta/metadoc_from_src.d
+++ /dev/null
@@ -1,1537 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
-
-+/
-// document abstraction:
-// abstraction of sisu markup for downstream processing
-// metadoc_from_src.d
-module sisudoc.meta.metadoc_from_src;
-@safe:
-template docAbstraction() {
- // ↓ abstraction imports
- import std.algorithm;
- import std.container;
- import std.digest.sha;
- import std.file;
- import std.json;
- import std.path;
- import sisudoc.meta;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import sisudoc.meta.metadoc_object_setter;
- import sisudoc.meta.rgx;
- public import sisudoc.meta.metadoc_from_src_functions;
- mixin docAbstractionFunctions;
- @system auto docAbstraction(CMM,Opt,Mf) (
- 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;
- int[string] node_para_int_ = node_metadata_para_int;
- string[string] node_para_str_ = node_metadata_para_str;
- ObjGenericComposite comp_obj_;
- line_occur = [
- "heading" : 0,
- "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]);
- }
- }
- _loopMarkupSrcByLineStruct 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);
- {
- ST_txt_by_line_block_generic _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");
- {
- ST_txt_by_line_block_generic _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 ]));
- }
- {
- ST_txt_by_line_block_generic _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) {
- {
- ST_txt_by_line_block_poem _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- 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;
- }
- {
- ST_txt_by_line_block_start _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
- ST_flow_book_index _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- 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;
- {
- ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
- {
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- 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
- {
- ST_flow_heading_found _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith);
- {
- heading_match_str = _get.heading_match_str;
- heading_match_rgx = _get.heading_match_rgx;
- 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
- {
- ST_flow_heading_make_set _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith);
- {
- line = _get.line;
- an_object = _get.this_object;
- 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);
- {
- ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- 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
- {
- ST_flow_block_flag_line_empty _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!
- {
- ST_flow_table_of_contents_gather_headings _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"];
- }
- ObjGenericComposite 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
- {
- ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
- {
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- 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";
- ObjGenericComposite 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);
- {
- ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
- {
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- 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
- _loopMarkupSrcByLineStruct _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith);
- the_document_toc_section = _doc_by_line.toc;
- the_document_body_section = _doc_by_line.body;
- the_document_glossary_section = _doc_by_line.glossary;
- 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) { // writeln("toc"); // 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) { // writeln("body");
- 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.metainfo.sha256 = obj.obj_digest;
- obj = _links(obj);
- }
- }
- auto image_list = (_images.sort()).uniq;
- // endnotes optional only one 1~ level
- if (the_document_endnotes_section.length > 1) { // writeln("endnotes");
- 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) { // writeln("glossary");
- 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.metainfo.sha256 = obj.obj_digest;
- obj = _links(obj);
- }
- }
- // bibliography optional only one 1~ level
- if (the_document_bibliography_section.length > 1) { // writeln("bibliography");
- 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.metainfo.sha256 = obj.obj_digest;
- 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) { // writeln("book index"); // 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.metainfo.sha256 = obj.obj_digest;
- 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) { // writeln("blurb");
- 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.metainfo.sha256 = obj.obj_digest;
- 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];
- }
- }
- }
- }
- }
- }
- /+ ↓ compute children_headings for heading objects +/
- {
- int[][int] heading_children;
- foreach (obj; the_document_body_section) {
- if (obj.metainfo.is_a == "heading" && obj.metainfo.parent_ocn != 0) {
- heading_children[obj.metainfo.parent_ocn] ~= obj.metainfo.ocn;
- }
- }
- foreach (ref obj; the_document_head_section) {
- if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) {
- obj.metainfo.children_headings = heading_children[obj.metainfo.ocn];
- }
- }
- foreach (ref obj; the_document_body_section) {
- if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) {
- obj.metainfo.children_headings = heading_children[obj.metainfo.ocn];
- }
- }
- }
- // 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",],
- "text": ["head", "toc", "body",],
- ];
- if (document_the["endnotes"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "endnotes";
- document_section_keys_sequenced["seg"] ~= "endnotes";
- document_section_keys_sequenced["latex"] ~= "endnotes";
- document_section_keys_sequenced["text"] ~= "endnotes";
- }
- if (document_the["glossary"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "glossary";
- document_section_keys_sequenced["seg"] ~= "glossary";
- document_section_keys_sequenced["sql"] ~= "glossary";
- document_section_keys_sequenced["latex"] ~= "glossary";
- document_section_keys_sequenced["text"] ~= "glossary";
- }
- if (document_the["bibliography"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "bibliography";
- document_section_keys_sequenced["seg"] ~= "bibliography";
- document_section_keys_sequenced["sql"] ~= "bibliography";
- document_section_keys_sequenced["latex"] ~= "bibliography";
- document_section_keys_sequenced["text"] ~= "bibliography";
- }
- if (document_the["bookindex"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "bookindex";
- document_section_keys_sequenced["seg"] ~= "bookindex";
- document_section_keys_sequenced["sql"] ~= "bookindex";
- document_section_keys_sequenced["latex"] ~= "bookindex";
- document_section_keys_sequenced["text"] ~= "bookindex";
- }
- if (document_the["blurb"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "blurb";
- document_section_keys_sequenced["seg"] ~= "blurb";
- document_section_keys_sequenced["sql"] ~= "blurb";
- document_section_keys_sequenced["latex"] ~= "blurb";
- document_section_keys_sequenced["text"] ~= "blurb";
- }
- if ((opt_action.html)
- || (opt_action.html_scroll)
- || (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;
- }
- }
- DocHas_ 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/sisudoc/meta/metadoc_from_src_functions.d b/src/sisudoc/meta/metadoc_from_src_functions.d
deleted file mode 100644
index bb3cd4e..0000000
--- a/src/sisudoc/meta/metadoc_from_src_functions.d
+++ /dev/null
@@ -1,5432 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
-
-+/
-// document abstraction:
-// abstraction of sisu markup for downstream processing
-// metadoc_from_src.d
-module sisudoc.meta.metadoc_from_src_functions;
-@safe:
-template docAbstractionFunctions() {
- // ↓ abstraction imports
- // ↓ 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_quotemarks_code_open)) {
- dochas["codeblock"]++;
- an_object["lang"] = "";
- an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
- an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : "";
- debug(codequotemarks) { writefln( "* [code quotemarks] %s", line); }
- pith["block_is"] = eN.blk_is.code;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks; //
- } else if (auto m = line.matchFirst(rgx.block_quotemarks_poem_open)) {
- dochas["poem"]++;
- an_object["syntax"] = "";
- an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
- an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
- debug(poem) { writefln( "* [poem quotemarks] %s", line); }
- object_number_poem["start"] = obj_cite_digits.object_number.to!string;
- pith["block_is"] = eN.blk_is.poem;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks; //
- pith["verse_new"] = eN.bi.on;
- } else if (auto m = line.matchFirst(rgx.block_quotemarks_group_open)) {
- dochas["group"]++;
- an_object["syntax"] = "";
- an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
- an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
- debug(group) { writefln( "* [group quotemarks] %s", line); }
- pith["block_is"] = eN.blk_is.group;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks;
- } else if (auto m = line.matchFirst(rgx.block_quotemarks_block_open)) {
- dochas["block"]++;
- an_object["syntax"] = "";
- an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
- an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
- debug(block) { writefln( "* [block quotemarks] %s", line); }
- pith["block_is"] = eN.blk_is.block;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks;
- } else if (auto m = line.matchFirst(rgx.block_quotemarks_quote_open)) {
- dochas["quote"]++;
- an_object["syntax"] = "";
- an_object["attrib"] = m["attrib"].to!string;
- an_object["lang"] = m["lang"].to!string;
- debug(quote) { writefln( "* [quote quotemarks] %s", line); // quote (quotemarks) open
- }
- pith["block_is"] = eN.blk_is.quote;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks;
- } else if (auto m = line.matchFirst(rgx.block_quotemarks_table_open)) { // quotemarks table open
- debug(table) { writefln( "* [table quotemarks] %s", line); }
- dochas["table"] ++;
- an_object["table_head"] = m["attrib"].to!string;
- an_object["block_type"] = "quotemarks";
- pith["block_is"] = eN.blk_is.table;
- pith["block_state"] = eN.blk_state.on;
- pith["block_delim"] = eN.blk_delim.quotemarks;
- } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) {
- dochas["codeblock"]++;
- an_object["lang"] = "";
- 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.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- debug(group) { writeln(line); }
- an_object[an_object_key] = an_object[an_object_key].stripRight;
- pith["block_is"] = eN.blk_is.group;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- debug(group) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- debug(group) { writeln(line); }
- 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.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- debug(block) { writeln(line); }
- an_object[an_object_key] = an_object[an_object_key].stripRight;
- pith["block_is"] = eN.blk_is.block;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- debug(block) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- debug(block) { writeln(line); }
- 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.quotemarks) {
- if (auto m = line.matchFirst(rgx.block_quotemarks_close)) {
- an_object[an_object_key] = "verse";
- debug(poem) { writefln( "* [poem quotemarks] %s", line); }
- if (processing.length > 0) {
- an_object[an_object_key] = processing["verse"];
- }
- if (an_object.length > 0) {
- debug(poem) { writeln(__LINE__); writeln(obj_cite_digits.object_number, line); }
- processing.remove("verse");
- an_object["is"] = "verse";
- ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
- = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
- an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
- anchor_tag = substantive_obj_misc_struct.anchor_tag;
- comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
- comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_;
- tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
- object_number_poem["end"] = obj_cite_digits.object_number.to!string;
- object_reset(an_object);
- processing.remove("verse");
- ++cntr;
- }
- pith["block_is"] = eN.blk_is.poem;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- processing["verse"] ~= line ~= "\n";
- if (pith["verse_new"] == eN.bi.on) {
- obj_cite_digits = ocn_emit(pith["ocn"]);
- pith["verse_new"] = eN.bi.off;
- } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) {
- processing["verse"] = processing["verse"].stripRight;
- pith["verse_new"] = eN.bi.on;
- verse_line = eN.bi.off;
- }
- if (pith["verse_new"] == eN.bi.on) {
- verse_line = 1;
- an_object[an_object_key] = processing["verse"];
- debug(poem) { writefln(
- "* %s tic\n%s",
- obj_cite_digits.object_number,
- an_object[an_object_key]
- );
- }
- processing.remove("verse");
- an_object["is"] = "verse";
- auto comp_obj_location
- = node_construct.node_location_emitter(
- content_non_header,
- tag_in_seg,
- lev_anchor_tag,
- tag_assoc,
- obj_cite_digits,
- cntr,
- heading_ptr-1,
- an_object["is"]
- );
- ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
- = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
- an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
- anchor_tag = substantive_obj_misc_struct.anchor_tag;
- comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
- comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_;
- tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
- object_reset(an_object);
- processing.remove("verse");
- ++cntr;
- }
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (auto m = line.matchFirst(rgx.block_tic_close)) {
- an_object[an_object_key] = "verse";
- 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.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- debug(codequotemarks) { writeln(line); }
- an_object[an_object_key] = an_object[an_object_key]
- .replaceFirst(rgx.newline_eol_delimiter_only, "")
- .stripRight;
- pith["block_is"] = eN.blk_is.code;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- debug(codequotemarks) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- debug(codetic) { writeln(line); }
- 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.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- debug(table) { writeln(line); }
- pith["block_is"] = eN.blk_is.table;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- debug(table) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- debug(table) { writeln(line); }
- 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.quotemarks) {
- if (line.matchFirst(rgx.block_quotemarks_close)) {
- debug(quote) { writeln(line); }
- an_object[an_object_key] = an_object[an_object_key].stripRight;
- pith["block_is"] = eN.blk_is.quote;
- pith["block_state"] = eN.blk_state.closing;
- pith["block_delim"] = eN.blk_delim.off;
- } else {
- debug(quote) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- }
- } else if (pith["block_delim"] == eN.blk_delim.tic) {
- if (line.matchFirst(rgx.block_tic_close)) {
- debug(quote) { writeln(line); }
- 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
- // ↓ - object digest
- pure ubyte[32] obj_digest()(
- ObjGenericComposite obj,
- ) {
- obj.metainfo.sha256 = obj.text.sha256Of;
- return obj.metainfo.sha256;
- }
- // ↑ - object digest
- // ↓ - 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
- {
- ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- 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)) {
- {
- ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- 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,
- ) {
- string[string][string] notes_;
- if (the_document_body_section.length > 1) {
- string _notes;
- foreach (ref obj; the_document_body_section) {
- if (obj.has.inline_notes_reg) {
- if ((obj.text).matchFirst(rgx.inline_notes_al_gen)) {
- foreach (m; (obj.text).matchAll(rgx.inline_notes_al_regular_number_note)) {
- _notes ~= "\n\n" ~ m["num"] ~ ". " ~ m["note"];
- notes_[(m["num"])]["ocn"] = obj.metainfo.ocn.to!string;
- }
- }
- }
- }
- }
- if (the_document_endnotes_section.length > 1) {
- segnames["html"] ~= "endnotes";
- segnames["epub"] ~= "endnotes";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_endnotes_section) {
- auto matches = (obj.text).matchAll(rgx.endnote_section_note);
- foreach (m; matches) {
- obj.metainfo.parent_ocn = notes_[(m["notenumber"])]["ocn"].to!int;
- }
- }
- foreach (ref obj; the_document_endnotes_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
- }
- 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"];
- }
- string[] text() {
- return document_section_keys_sequenced["text"];
- }
- }
- return doc_sect_keys_seq();
- }
-}
diff --git a/src/sisudoc/meta/metadoc_object_setter.d b/src/sisudoc/meta/metadoc_object_setter.d
deleted file mode 100644
index 018c51b..0000000
--- a/src/sisudoc/meta/metadoc_object_setter.d
+++ /dev/null
@@ -1,429 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
-
-+/
-/++
- object setter:
- setting of sisu objects for downstream processing
- metadoc_object_setter.d
-+/
-module sisudoc.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;
- int[] children_headings;
- ubyte[32] sha256;
- }
- 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,
- quotemarks,
- }
- }
- return _e();
- }
-}
diff --git a/src/sisudoc/meta/metadoc_show_config.d b/src/sisudoc/meta/metadoc_show_config.d
deleted file mode 100644
index c4be08a..0000000
--- a/src/sisudoc/meta/metadoc_show_config.d
+++ /dev/null
@@ -1,230 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.metadoc_show_config;
-@safe:
-template spineShowSiteConfig() {
- void spineShowSiteConfig(O,T)(
- O opt_action,
- T config,
- ) {
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.digest.crc;
- import std.digest.sha;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- auto markup = InlineMarkup();
- auto char_repeat_number = 66;
- 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 sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.digest.crc;
- import std.digest.sha;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- auto markup = InlineMarkup();
- auto min_repeat_number = 66;
- 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/sisudoc/meta/metadoc_show_make.d b/src/sisudoc/meta/metadoc_show_make.d
deleted file mode 100644
index 4001e15..0000000
--- a/src/sisudoc/meta/metadoc_show_make.d
+++ /dev/null
@@ -1,121 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.metadoc_show_make;
-@safe:
-template spineShowMake() {
- void spineShowMake(T)(T doc_matters) {
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.digest.crc;
- import std.digest.sha;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- auto markup = InlineMarkup();
- auto min_repeat_number = 66;
- 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/sisudoc/meta/metadoc_show_metadata.d b/src/sisudoc/meta/metadoc_show_metadata.d
deleted file mode 100644
index 4159bc3..0000000
--- a/src/sisudoc/meta/metadoc_show_metadata.d
+++ /dev/null
@@ -1,169 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.metadoc_show_metadata;
-@safe:
-template spineShowMetaData() {
- void spineShowMetaData(T)(T doc_matters) {
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.digest.crc;
- import std.digest.sha;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- auto markup = InlineMarkup();
- auto min_repeat_number = 66;
- 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/sisudoc/meta/metadoc_show_summary.d b/src/sisudoc/meta/metadoc_show_summary.d
deleted file mode 100644
index 037b34a..0000000
--- a/src/sisudoc/meta/metadoc_show_summary.d
+++ /dev/null
@@ -1,164 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta.metadoc_show_summary;
-@safe:
-template spineMetaDocSummary() {
- void spineMetaDocSummary(D)(D doc) {
- auto doc_matters = doc.matters;
- import sisudoc.meta.defaults;
- import sisudoc.meta.rgx;
- import std.array;
- import std.digest.crc;
- import std.digest.sha;
- import std.exception;
- import std.regex;
- import std.stdio;
- import std.string;
- import std.typecons;
- import std.uni;
- import std.utf;
- import std.conv : to;
- mixin InternalMarkup;
- auto markup = InlineMarkup();
- auto min_repeat_number = 66;
- 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_gt_2
- || 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%s - %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),
- doc_matters.doc_digest.markup_doc.toHexString,
- 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/sisudoc/meta/package.d b/src/sisudoc/meta/package.d
deleted file mode 100644
index 99de2f3..0000000
--- a/src/sisudoc/meta/package.d
+++ /dev/null
@@ -1,62 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
-
- - License: AGPL 3 or later:
-
- Spine (SiSU), a framework for document structuring, publishing and
- search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU AFERO General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see [https://www.gnu.org/licenses/].
-
- If you have Internet connection, the latest version of the AGPL should be
- available at these locations:
- [https://www.fsf.org/licensing/licenses/agpl.html]
- [https://www.gnu.org/licenses/agpl.html]
-
- - Spine (by Doc Reform, related to SiSU) uses standard:
- - docReform markup syntax
- - standard SiSU markup syntax with modified headers and minor modifications
- - docReform object numbering
- - standard SiSU object citation numbering & system
-
- - Homepages:
- [https://www.sisudoc.org]
- [https://www.doc-reform.org]
-
- - Git
- [https://git.sisudoc.org/]
-
-+/
-module sisudoc.meta;
-public import sisudoc.meta.defaults;
-/+ std +/
-public import std.array;
-public import std.exception;
-public import std.range;
-public import std.regex;
-public import std.stdio;
-public import std.string;
-public import std.typecons;
-// public import std.uni;
-public import std.utf;
-public import std.conv : to;
diff --git a/src/sisudoc/meta/rgx.d b/src/sisudoc/meta/rgx.d
deleted file mode 100644
index db485eb..0000000
--- a/src/sisudoc/meta/rgx.d
+++ /dev/null
@@ -1,280 +0,0 @@
-/+
-- Name: SisuDoc Spine, Doc Reform [a part of]
- - Description: documents, structuring, processing, publishing, search
- - static content generator
-
- - Author: Ralph Amissah
- [ralph.amissah@gmail.com]
-
- - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.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^|[ (\[])(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?=[.,;:?!'"]?([ )\]]|$))`, "mg");
- static smid_inline_link_markup_regular = ctRegex!(`(?P
^|[ (\[])\{\s*(?P(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P^|[ ])\{\s*(?P┥)☼(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
┥)☼(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P
+ - read config files
+ meta_config_files.d
++/
+module sisudoc.io_in.paths_source;
+@safe:
+import std.array;
+import std.file;
+import std.path;
+import std.regex;
+import std.stdio;
+import std.conv : to;
+import sisudoc.meta.defaults;
+import sisudoc.meta.rgx_files;
+template PodManifest() {
+ mixin spineRgxFiles;
+ static auto rgx_files = RgxFiles();
+ auto PodManifest(O)(
+ O _opt_action,
+ string _pth=""
+ ) {
+ struct ManifestFile_ {
+ string pod_manifest_filename() {
+ return "pod.manifest";
+ }
+ string pod_manifest_path() {
+ string _manifest_path;
+ if ((isValidPath(_pth) && exists(_pth) != 0 && _pth.isDir)
+ && (exists(_pth.chainPath(pod_manifest_filename).array) != 0
+ && (_pth.chainPath(pod_manifest_filename).array).isFile)) {
+ _manifest_path = _pth;
+ } else if (_pth.match(rgx_files.src_pth_contents)
+ && exists(_pth) != 0 && _pth.isFile) {
+ _manifest_path = _pth.dirName;
+ } else if (_pth.match(rgx_files.src_pth_pod_sst_or_ssm)
+ && exists(_pth) != 0 && (_pth.isFile)) {
+ if (auto m = _pth.match(rgx_files.src_pth_pod_sst_or_ssm)) {
+ _manifest_path = m.captures["podpath"];
+ }
+ } else {
+ if (_opt_action.vox_gt_3 || _opt_action.debug_do) {
+ if (exists(_pth) == 0 && (_pth.isFile)) {
+ writeln("WARNING, src file is not .sst or .ssm (nor is it a pod directory): ", _pth); // remove? unless can distinguish pod
+ }
+ }
+ _manifest_path = "";
+ }
+ return _manifest_path;
+ }
+ string pods_collection_root_path() {
+ return (pod_manifest_path.length > 0) ? ((chainPath(pod_manifest_path, "..")).asNormalizedPath).array.to!string : "";
+ }
+ string pod_manifest_file_with_path() {
+ string _k;
+ if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) {
+ _k = pod_manifest_path.chainPath(pod_manifest_filename).array;
+ } else if (exists(pod_manifest_path)!=0) {
+ _k = pod_manifest_path;
+ }
+ if (exists(_k)==0) {
+ // writeln("ERROR >> Processing Skipped! Manifest not found: ", _k);
+ _k = null;
+ }
+ return _k;
+ }
+ }
+ return ManifestFile_();
+ }
+}
+template PathMatters() {
+ mixin InternalMarkup;
+ mixin spineRgxFiles;
+ static auto rgx_files = RgxFiles();
+ static auto mkup = InlineMarkup();
+ auto PathMatters(O,E)(
+ O _opt_action,
+ E _env,
+ string _pth,
+ string _fns = "",
+ char[][] _manifest_fn_list = [[]],
+ ) {
+ auto _manifested = PodManifest!()(_opt_action, _pth);
+ struct ManifestMatters_ {
+ auto env() {
+ auto _env = _env;
+ struct Env_ {
+ auto pwd() {
+ return _env["pwd"];
+ }
+ auto home() {
+ return _env["home"];
+ }
+ }
+ return Env_();
+ }
+ auto opt() {
+ struct Opt_ {
+ auto action() {
+ return _opt_action;
+ }
+ }
+ return Opt_();
+ }
+ bool src_is_pod() {
+ return (_manifested.pod_manifest_path.length > 0) ? true : false;
+ }
+ auto pod() {
+ struct Pod_ {
+ bool src_is_pod() {
+ return (_manifested.pod_manifest_path.length > 0) ? true : false;
+ }
+ string collection_root() {
+ return _manifested.pods_collection_root_path;
+ }
+ string manifest_filename() {
+ return _manifested.pod_manifest_filename;
+ }
+ string manifest_path() {
+ return _manifested.pod_manifest_path;
+ }
+ string pod_name_with_path() {
+ return _manifested.pod_manifest_path.baseName;
+ }
+ string manifest_file_with_path() {
+ return _manifested.pod_manifest_file_with_path;
+ }
+ string[] config_dr_document_make_dirs() {
+ string[] _config_dirs;
+ return _config_dirs;
+ }
+ string[] config_local_site_dirs() {
+ string[] _config_dirs;
+ return _config_dirs;
+ }
+ string[] image_dirs() {
+ string[] _image_dirs;
+ return _image_dirs;
+ }
+ auto manifest_list_of_filenames() {
+ return _manifest_fn_list;
+ }
+ string[] manifest_list_of_languages() {
+ string[] _lngs;
+ foreach (filename_; manifest_list_of_filenames) {
+ string _k = "en";
+ if (auto m = (filename_).match(rgx_files.language_code_and_filename)) {
+ _k = m.captures[1].to!string;
+ }
+ _lngs ~= _k; // all the languages from the manifest list of filenames with paths
+ }
+ return _lngs;
+ }
+ }
+ return Pod_();
+ }
+ auto src() {
+ string _fns = _fns; // required here by dmd & not by ldc (for D:2078)
+ auto _opt_action = _opt_action;
+ auto _env = _env;
+ struct SRC_ {
+ bool is_pod() {
+ return (_manifested.pod_manifest_path.length > 0) ? true : false;
+ }
+ string path_and_fn() {
+ return _fns;
+ }
+ string pod_name_with_path() {
+ return (is_pod) ? _manifested.pod_manifest_path : "";
+ }
+ string pods_collection_root_path() {
+ return (is_pod) ? _manifested.pods_collection_root_path : "";
+ }
+ string pod_name() {
+ return pod_name_with_path.baseName;
+ }
+ string filename() {
+ return path_and_fn.baseName;
+ }
+ string filename_base() {
+ return filename.stripExtension;
+ }
+ string filename_extension() {
+ return filename.match(rgx_files.src_pth_sst_or_ssm).captures["extension"];
+ }
+ string lng() {
+ string _k;
+ if (auto m = path_and_fn.match(rgx_files.language_code_and_filename)) {
+ _k = m.captures[1];
+ } else {_k = "en"; }
+ return _k;
+ }
+ string doc_uid() {
+ string _uid;
+ if (is_pod && !(pod_name_with_path.empty)) {
+ if (pod_name_with_path.baseName == filename_base) {
+ _uid = filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
+ } else {
+ _uid = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
+ }
+ } else {
+ _uid = mkup.uid_sep ~ filename_base ~ "." ~ filename_extension ~ mkup.uid_sep ~ lng;
+ }
+ return _uid;
+ }
+ string doc_uid_out() {
+ string _uid;
+ if (is_pod && !(pod_name_with_path.empty)) {
+ if (pod_name_with_path.baseName == filename_base) {
+ _uid = filename_base ~ "." ~ lng;
+ } else {
+ _uid = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ "." ~ lng;
+ }
+ } else {
+ _uid = "_" ~ filename_base ~ "." ~ lng;
+ }
+ return _uid;
+ }
+ string docname_composite_unique_per_src_doc() {
+ string _fn;
+ if (pod_name_with_path.baseName == filename_base) {
+ _fn = filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
+ } else if (!(pod_name_with_path.empty)) {
+ _fn = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
+ } else {
+ _fn = "_" ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng;
+ }
+ return _fn;
+ }
+ string docname_composite_unique_per_src_pod() {
+ /+
+ z pod name if any + src filename (without lng code)
+ filename ~ mkup.uid_sep ~ lng
+ * unique per src pod
+ used by
+ - pod (multilingual collection)
+ - sqlite discrete index (multilingual collection)
+ +/
+ string _fn;
+ if (pod_name_with_path.baseName == filename_base) {
+ _fn = filename_base ~ mkup.uid_sep ~ filename_extension;
+ } else if (!(pod_name_with_path.empty)) {
+ _fn = pod_name_with_path.baseName ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension;
+ } else {
+ _fn = "_" ~ mkup.uid_sep ~ filename_base ~ mkup.uid_sep ~ filename_extension;
+ }
+ return _fn;
+ }
+ string language() {
+ return lng();
+ }
+ string file_with_absolute_path() {
+ return _env["pwd"].chainPath(path_and_fn).array;
+ }
+ string absolute_path_to_src() {
+ return (_env["pwd"].chainPath(path_and_fn)).dirName.array;
+ }
+ string path_to_doc_root_path_to_lang_and_filename() {
+ return _env["pwd"].chainPath(path_and_fn).array;
+ }
+ string base_dir() {
+ string _dir;
+ if (
+ auto m = (absolute_path_to_src)
+ .match(regex(r"[/](?P
+ - read config files
+ meta_config_files.d
++/
+module sisudoc.io_in.read_config_files;
+@safe:
+import std.file;
+import std.path;
+import sisudoc.meta;
+import sisudoc.io_in.paths_source;
+import sisudoc.meta.rgx_files;
+import sisudoc.meta.rgx;
+template readConfigSite() {
+ @system final auto readConfigSite(Cf,O,Cfg)(Cf _conf_file_details, O _opt_action, Cfg _cfg) {
+ mixin spineRgxIn;
+ static auto rgx = RgxI();
+ string conf_filename = "NONE";
+ string config_file_str;
+ string default_config_file_str = format(q"┃
+flag:
+ act0: "--html"
+ act1: "--html --epub"
+output:
+ path: "%s"
+default:
+ language: "en"
+ papersize: "a4"
+ text_wrap: "80"
+ digest: "sha256"
+webserv:
+ http: "%s"
+ host: "%s"
+ data_http: "%s"
+ data_host: "%s"
+ data_root_url: "%s"
+ data_root_path: "%s"
+ data_root_part: ""
+ images_root_part: "image"
+ cgi_search_form_title: "%s"
+ cgi_http: "%s"
+ cgi_host: "%s"
+ cgi_bin_url: "%s"
+ cgi_bin_subpath: "%s"
+ cgi_bin_path: "%s"
+ cgi_search_script: "%s"
+ cgi_port: ""
+ cgi_user: ""
+ cgi_action: "%s"
+ db_sqlite_path: "%s"
+ db_sqlite_filename: "%s"
+ db_pg_table: ""
+ db_pg_user: ""
+┃",
+ _cfg.processing_path_doc_root, // doc root
+ _cfg.http_request_type, // http
+ _cfg.http_host, // host / domain
+ _cfg.http_request_type, // data "http" or "https"
+ _cfg.http_host, // data domain "localhost"
+ _cfg.www_url_doc_root, // data root url "http://locahost" "https://sisudoc.org"
+ _cfg.processing_path_doc_root, // data root path
+ _cfg.cgi_search_form_title, // cgi title // e.g. "≅ SiSU Spine search"
+ _cfg.http_request_type, // cgi http
+ _cfg.http_host, // cgi host
+ _cfg.cgi_url_root, // cgi bin url
+ _cfg.cgi_bin_subpath, // cgi bin path
+ _cfg.cgi_bin_root, // cgi bin path
+ _cfg.cgi_filename, // cgi filename
+ _cfg.cgi_url_action, // cgi action
+ _cfg.db_sqlite_path, // sqlite db path
+ _cfg.db_sqlite_filename, // sqlite db filename
+);
+ foreach(conf_fn; [_conf_file_details.config_filename_site]) {
+ foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) {
+ char[] conf_file;
+ conf_filename = conf_fn;
+ if (exists(pth)) {
+ auto f_attrib = pth.getLinkAttributes;
+ if (
+ _conf_file_details.possible_config_path_locations.config_local_site.length == 1
+ && f_attrib.attrIsFile
+ ) {
+ conf_file = pth.to!(char[]);
+ conf_filename = pth.baseName;
+ } else if (f_attrib.attrIsDir) {
+ conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array;
+ conf_filename = conf_fn;
+ }
+ try {
+ if (exists(conf_file)) {
+ if (conf_file.getLinkAttributes.attrIsFile) {
+ if (_opt_action.vox_gt_2 || _opt_action.debug_do) {
+ writeln("config file used: \"", conf_file, "\" (cli flag settings override config file's individual settings)");
+ }
+ config_file_str = conf_file.readText;
+ break;
+ }
+ }
+ } catch (ErrnoException ex) {
+ } catch (FileException ex) {
+ }
+ }
+ }
+ if (config_file_str.length > 0) { break; }
+ }
+ if (config_file_str.length > 0) {
+ import dyaml;
+ Node yaml_root;
+ try {
+ yaml_root = Loader.fromString(config_file_str).load();
+ } catch (Throwable) {
+ import std.stdio;
+ writeln("ERROR failed to read config file content, not parsed as yaml, program default used");
+ conf_filename = "VIRTUAL";
+ config_file_str = default_config_file_str;
+ }
+ }
+ if (config_file_str.length == 0) { /+ use dummy default config file +/
+ // writeln("WARNING config file NOT found, default provided");
+ conf_filename = "VIRTUAL";
+ config_file_str = default_config_file_str;
+ }
+ struct _ConfContent {
+ string filename() {
+ return conf_filename;
+ }
+ string filetype() {
+ string _ft = "";
+ if (content.match(rgx.yaml_config)) {
+ _ft = "yaml";
+ }
+ return _ft;
+ }
+ string content() {
+ return config_file_str;
+ }
+ }
+ return _ConfContent();
+ }
+}
+static template readConfigDoc() {
+ import std.file;
+ import std.path;
+ import sisudoc.meta;
+ import sisudoc.io_in.paths_source;
+ import sisudoc.meta.rgx_files;
+ import sisudoc.meta.rgx;
+ @system final auto readConfigDoc(M,E)(M _manifested, E _env) {
+ mixin spineRgxIn;
+ static auto rgx = RgxI();
+ mixin spineRgxFiles;
+ static auto rgx_files = RgxFiles();
+ string config_file_str;
+ string conf_filename = "NONE";
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
+ string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.dr_document_make;
+ foreach(conf_fn; [_conf_file_details.config_filename_document]) {
+ foreach(pth; possible_config_path_locations) {
+ char[] conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array;
+ conf_filename = conf_fn;
+ if (config_file_str.length > 0) {
+ break;
+ }
+ try {
+ if (exists(conf_file)) {
+ if (conf_file.getLinkAttributes.attrIsFile) {
+ config_file_str = conf_file.readText;
+ break;
+ }
+ }
+ } catch (ErrnoException ex) {
+ } catch (FileException ex) {
+ }
+ }
+ if (config_file_str.length > 0) { break; }
+ }
+ struct _ConfContent {
+ string filename() {
+ return conf_filename;
+ }
+ string content() {
+ return config_file_str;
+ }
+ string filetype() {
+ string _ft = "";
+ if (content.match(rgx.yaml_config)) {
+ _ft = "yaml";
+ }
+ return _ft;
+ }
+ }
+ return _ConfContent();
+ }
+}
+static template configReadSiteYAML() {
+ import std.file;
+ import std.path;
+ import sisudoc.meta;
+ import sisudoc.io_in.paths_source;
+ import sisudoc.meta.rgx_files;
+ import sisudoc.meta.rgx;
+ final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) {
+ string _configuration = configReadInSiteYAML!()(_manifested, _env);
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
+ string _conf_yaml_fn = _conf_file_details.config_filename_site;
+ YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
+ return _yaml_conf;
+ }
+}
+static template configReadDocYAML() {
+ import std.file;
+ import std.path;
+ import sisudoc.meta;
+ import sisudoc.io_in.paths_source;
+ final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) {
+ string _configuration = configReadInDocYAML!()(_manifested, _env);
+ auto _conf_file_details = configFilePaths!()(_manifested, _env);
+ string _conf_yaml_fn = _conf_file_details.config_filename_document;
+ YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn);
+ return _yaml_conf;
+ }
+}
diff --git a/src/sisudoc/ocda/io_in/read_source_files.d b/src/sisudoc/ocda/io_in/read_source_files.d
new file mode 100644
index 0000000..31cbd37
--- /dev/null
+++ b/src/sisudoc/ocda/io_in/read_source_files.d
@@ -0,0 +1,435 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 source_read_source_files;
+ - open markup files
+ - if master file scan for addional files to import/insert
++/
+module sisudoc.io_in.read_source_files;
+@safe:
+template spineRawMarkupContent() {
+ import std.digest.sha;
+ import std.file;
+ import std.path;
+ import sisudoc.meta;
+ import sisudoc.io_in.paths_source;
+ import sisudoc.meta.rgx_files;
+ import sisudoc.meta.rgx;
+ mixin spineRgxIn;
+ static auto rgx = RgxI();
+ mixin spineRgxFiles;
+ static auto rgx_files = RgxFiles();
+ string[] _images=[];
+ string[] _extract_images(S)(S content_block) {
+ string[] images_;
+ string _content_block = content_block.to!string;
+ if (auto m = _content_block.matchAll(rgx.image)) {
+ images_ ~= m.captures[1].to!string;
+ }
+ return images_;
+ }
+ auto rawsrc = RawMarkupContent();
+ struct ST_contents_inserts_images {
+ char[][] contents;
+ string[] insert_files;
+ string[] images;
+ }
+ struct ST_header_content_inserts_images {
+ char[] header;
+ char[][] src_txt;
+ string[] insert_files;
+ string[] images;
+ }
+ struct ST_doc_digest {
+ ubyte[32] markup_doc;
+ ubyte[32] header;
+ ubyte[32] text;
+ }
+ struct ST_doc_parts {
+ char[] header_raw;
+ char[][] sourcefile_body_content;
+ string[] insert_file_list;
+ string[] images_list;
+ ST_doc_digest doc_digest;
+ }
+ ST_doc_parts spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
+ ST_doc_parts _0_header_1_body_content_2_insert_filelist_struct
+ = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
+ return _0_header_1_body_content_2_insert_filelist_struct;
+ }
+ struct RawMarkupContent {
+ final sourceContent(in string fn_src) {
+ auto raw = MarkupRawUnit();
+ string source_txt_str
+ = raw.markupSourceReadIn(fn_src);
+ return source_txt_str;
+ }
+ final ST_doc_parts sourceContentSplitIntoHeaderAndBody(O)(
+ O _opt_action,
+ in string source_txt_str,
+ in string fn_src=""
+ ) {
+ auto raw = MarkupRawUnit();
+ string[] insert_file_list_get;
+ string[] images_list_get;
+ ST_header_content_inserts_images st
+ = raw.markupSourceHeaderContentRawLineStructArray(source_txt_str);
+ char[] header_raw = st.header;
+ char[][] sourcefile_body_content = st.src_txt;
+ if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
+ auto ins = Inserts();
+ ST_contents_inserts_images _cii
+ = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
+ sourcefile_body_content = _cii.contents;
+ insert_file_list_get = _cii.insert_files.dup;
+ images_list_get = _cii.images.dup;
+ } else if (_opt_action.source_or_pod) {
+ auto ins = Inserts();
+ ST_contents_inserts_images _cii
+ = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
+ images_list_get = _cii.images.dup;
+ } // image_list, if path could take sha256 digests already here?
+ string header_type = "";
+ ST_doc_digest dig;
+ {
+ dig.markup_doc = source_txt_str.sha256Of;
+ dig.header = st.header.sha256Of;
+ dig.text = sourcefile_body_content.sha256Of;
+ }
+ ST_doc_parts ret;
+ {
+ ret.header_raw = st.header;
+ ret.sourcefile_body_content = sourcefile_body_content;
+ ret.insert_file_list = insert_file_list_get;
+ ret.images_list = images_list_get;
+ ret.doc_digest = dig;
+ }
+ return ret;
+ }
+ }
+ struct MarkupRawUnit {
+ import std.digest.sha;
+ import std.file;
+ final private string readInMarkupSource(in char[] fn_src) {
+ enforce(
+ exists(fn_src) != 0,
+ "file not found: «" ~
+ fn_src ~ "»"
+ );
+ string source_txt_str;
+ try {
+ if (exists(fn_src)) {
+ if (fn_src.getLinkAttributes.attrIsFile) {
+ source_txt_str = fn_src.readText;
+ } else {
+ }
+ }
+ } catch (ErrnoException ex) {
+ } catch (UTFException ex) {
+ // Handle validation errors
+ } catch (FileException ex) {
+ // Handle errors
+ }
+ std.utf.validate(source_txt_str);
+ return source_txt_str;
+ }
+ @trusted final private char[][] header0Content1(in string src_text) { // cast(char[])
+ /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/
+ char[][] header_and_content;
+ auto m = (cast(char[]) src_text).matchFirst(rgx.heading_a);
+ header_and_content ~= m.pre;
+ header_and_content ~= m.hit ~ m.post;
+ assert(header_and_content.length == 2,
+ "document markup is broken, header body split == "
+ ~ header_and_content.length.to!string
+ ~ "; (header / body array split should == 2 (split is on level A~))"
+ );
+ return header_and_content;
+ }
+ @trusted final private char[][] markupSourceLineArray(in char[] src_text) { // cast(char[])
+ char[][] source_line_arr
+ = (cast(char[]) src_text).split(rgx.newline_eol_strip_preceding);
+ return source_line_arr;
+ }
+ string markupSourceReadIn(in string fn_src) {
+ static auto rgx_files = RgxFiles();
+ enforce(
+ fn_src.match(rgx_files.src_pth_sst_or_ssm),
+ "not a dr markup filename: «" ~
+ fn_src ~ "»"
+ );
+ string source_txt_str = readInMarkupSource(fn_src);
+ return source_txt_str;
+ }
+ ST_header_content_inserts_images markupSourceHeaderContentRawLineStructArray(in string source_txt_str) {
+ string[] file_insert_list = [];
+ string[] images_list = [];
+ char[][] hc = header0Content1(source_txt_str);
+ char[] header = hc[0];
+ char[] source_txt = hc[1];
+ char[][] source_line_arr = markupSourceLineArray(source_txt);
+ ST_header_content_inserts_images ret;
+ {
+ ret.header = header;
+ ret.src_txt = source_line_arr;
+ ret.insert_files = file_insert_list;
+ ret.images = images_list;
+ }
+ return ret;
+ }
+ final char[][] getInsertMarkupSourceContentRawLineArray(
+ in char[] fn_src_insert,
+ Regex!(char) rgx_file
+ ) {
+ enforce(
+ fn_src_insert.match(rgx_file),
+ "not a dr markup filename: «" ~
+ fn_src_insert ~ "»"
+ );
+ string source_txt_str = readInMarkupSource(fn_src_insert);
+ char[][] source_line_arr = markupSourceLineArray(source_txt_str);
+ return source_line_arr;
+ }
+ }
+ struct Inserts {
+ struct ST_contents_and_images {
+ char[][] insert_contents;
+ string[] images;
+ }
+ ST_contents_and_images scan_subdoc_source(O)(
+ O _opt_action,
+ char[][] markup_sourcefile_insert_content,
+ string fn_src
+ ) {
+ char[][] contents_insert;
+ int code_block_status = 0;
+ enum codeBlock { off, curly, tic, quotemarks }
+ auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm);
+ auto markup_src_file_path = fn_pth_full.captures[1];
+ foreach (line; markup_sourcefile_insert_content) {
+ if (code_block_status == codeBlock.curly) {
+ if (line.matchFirst(rgx.block_curly_code_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents_insert ~= line;
+ } else if (line.matchFirst(rgx.block_curly_code_open)) {
+ code_block_status = codeBlock.curly;
+ contents_insert ~= line;
+ } else if (code_block_status == codeBlock.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents_insert ~= line;
+ } else if (code_block_status == codeBlock.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents_insert ~= line;
+ } else if (line.matchFirst(rgx.block_quotemarks_code_open)) {
+ code_block_status = codeBlock.quotemarks;
+ contents_insert ~= line;
+ } else if (line.matchFirst(rgx.block_tic_code_open)) {
+ code_block_status = codeBlock.tic;
+ contents_insert ~= line;
+ } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) {
+ auto insert_fn = m.captures[2];
+ auto insert_sub_pth = m.captures[1];
+ auto fn_src_insert
+ = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
+ auto raw = MarkupRawUnit();
+ auto markup_sourcesubfile_insert_content
+ = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts);
+ debug(insert_file) {
+ writeln(line);
+ writeln(fn_src_insert);
+ writeln(
+ " length contents insert array: ",
+ markup_sourcesubfile_insert_content.length
+ );
+ }
+ if (_opt_action.source_or_pod) {
+ _images ~= _extract_images(markup_sourcesubfile_insert_content);
+ }
+ auto ins = Inserts();
+ /+
+ - 1. load file
+ - 2. read lines
+ - 3. scan lines
+ - a. if filename insert, and insert filename
+ - repeat 1
+ - b. else
+ - add line to new array;
+ - build image list, search for any image files to add to image list
+ +/
+ } else {
+ contents_insert ~= line; // images to extract for image list?
+ if (_opt_action.source_or_pod) {
+ string[] _image_linelist = _extract_images(line);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
+ }
+ } // end src subdoc (inserts) loop
+ ST_contents_and_images ret;
+ {
+ ret.insert_contents = contents_insert;
+ ret.images = _images;
+ }
+ return ret;
+ }
+ ST_contents_inserts_images scan_master_src_for_insert_files_and_import_content(O)(
+ O _opt_action,
+ char[][] sourcefile_body_content,
+ string fn_src
+ ) {
+ import std.algorithm;
+ char[][] contents;
+ int code_block_status = 0;
+ enum codeBlock { off, curly, tic, quotemarks }
+ auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm);
+ auto markup_src_file_path = fn_pth_full.captures[1];
+ char[][] contents_insert;
+ string[] _images =[];
+ string[] insert_file_list =[];
+ foreach (line; sourcefile_body_content) {
+ if (code_block_status == codeBlock.curly) {
+ if (line.matchFirst(rgx.block_curly_code_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents ~= line;
+ } else if (line.matchFirst(rgx.block_curly_code_open)) {
+ code_block_status = codeBlock.curly;
+ contents ~= line;
+ } else if (code_block_status == codeBlock.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents ~= line;
+ } else if (code_block_status == codeBlock.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ code_block_status = codeBlock.off;
+ }
+ contents ~= line;
+ } else if (line.matchFirst(rgx.block_quotemarks_code_open)) {
+ code_block_status = codeBlock.quotemarks;
+ contents ~= line;
+ } else if (line.matchFirst(rgx.block_tic_code_open)) {
+ code_block_status = codeBlock.tic;
+ contents ~= line;
+ } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) {
+ auto insert_fn = m.captures[2];
+ auto insert_sub_pth = m.captures[1];
+ auto fn_src_insert
+ = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
+ insert_file_list ~= fn_src_insert.to!string;
+ auto raw = MarkupRawUnit();
+ /+ TODO +/
+ auto markup_sourcefile_insert_content
+ = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts);
+ debug(insert_file) {
+ writeln(line);
+ writeln(fn_src_insert);
+ writeln(
+ " length contents insert array: ",
+ markup_sourcefile_insert_content.length
+ );
+ }
+ auto ins = Inserts();
+ ST_contents_and_images contents_insert_st = ins.scan_subdoc_source(
+ _opt_action,
+ markup_sourcefile_insert_content,
+ fn_src_insert.to!string
+ );
+ contents ~= contents_insert_st.insert_contents;
+ if (_opt_action.source_or_pod) {
+ string[] _image_linelist = _extract_images(contents_insert_st.images);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
+ /+
+ - 1. load file
+ - 2. read lines
+ - 3. scan lines
+ - a. if filename insert, and insert filename
+ - repeat 1
+ - b. else
+ - add line to new array;
+ - build image list, search for any image files to add to image list
+ +/
+ } else {
+ contents ~= line;
+ if (_opt_action.source_or_pod) {
+ string[] _image_linelist = _extract_images(line);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
+ }
+ } // end src doc loop
+ string[] images = [];
+ foreach(i; uniq(_images.sort())) {
+ images ~= i;
+ }
+ debug(insert_file) {
+ writeln(__LINE__);
+ writeln(contents.length);
+ }
+ ST_contents_inserts_images ret;
+ {
+ ret.contents = contents;
+ ret.insert_files = insert_file_list;
+ ret.images = images;
+ }
+ return ret;
+ }
+ }
+}
diff --git a/src/sisudoc/ocda/io_in/read_zip_pod.d b/src/sisudoc/ocda/io_in/read_zip_pod.d
new file mode 100644
index 0000000..d228f4e
--- /dev/null
+++ b/src/sisudoc/ocda/io_in/read_zip_pod.d
@@ -0,0 +1,401 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 read_zip_pod;
+ - extract pod zip archives to temp directory for processing
+ - validate zip entries for security (path traversal, size limits)
++/
+module sisudoc.io_in.read_zip_pod;
+@safe:
+template spineExtractZipPod() {
+ import std.algorithm : canFind;
+ import std.array : array;
+ import std.conv : to;
+ import std.file;
+ import std.path;
+ import std.regex;
+ import std.stdio;
+ import std.string : indexOf;
+
+ /+ security limits for zip extraction +/
+ enum size_t MAX_ENTRY_SIZE = 50 * 1024 * 1024; /+ 50 MB per entry +/
+ enum size_t MAX_TOTAL_SIZE = 500 * 1024 * 1024; /+ 500 MB total +/
+ enum size_t MAX_ENTRY_COUNT = 500; /+ max entries in archive +/
+ enum size_t MAX_PATH_DEPTH = 10; /+ max path components +/
+
+ /+ allowed entry name pattern: alphanumeric, dots, dashes, underscores, forward slashes +/
+ static auto rgx_safe_entry_name = ctRegex!(`^[a-zA-Z0-9._/ -]+$`);
+
+ struct ZipPodResult {
+ string tmp_dir; /+ temp directory containing extracted pod +/
+ string pod_dir; /+ path to pod directory within tmp_dir +/
+ bool ok; /+ extraction succeeded +/
+ string error_msg; /+ error description if !ok +/
+ }
+
+ /+ ↓ validate a single zip entry name for security +/
+ string validateEntryName(string name) {
+ /+ reject empty names +/
+ if (name.length == 0)
+ return "empty entry name";
+ /+ reject absolute paths +/
+ if (name[0] == '/')
+ return "absolute path in zip entry: " ~ name;
+ /+ reject path traversal +/
+ if (name.canFind(".."))
+ return "path traversal in zip entry: " ~ name;
+ /+ reject null bytes +/
+ if (name.indexOf('\0') >= 0)
+ return "null byte in zip entry name: " ~ name;
+ /+ reject backslashes (windows path separator tricks) +/
+ if (name.canFind("\\"))
+ return "backslash in zip entry: " ~ name;
+ /+ check path depth +/
+ size_t depth = 0;
+ foreach (c; name) {
+ if (c == '/') depth++;
+ }
+ if (depth > MAX_PATH_DEPTH)
+ return "path too deep in zip entry: " ~ name;
+ /+ check allowed characters +/
+ if (!(name.matchFirst(rgx_safe_entry_name)))
+ return "disallowed characters in zip entry: " ~ name;
+ return ""; /+ empty string means valid +/
+ }
+
+ /+ ↓ extract zip pod to temp directory, returns ZipPodResult +/
+ @trusted ZipPodResult extractZipPod(string zip_path) {
+ import std.zip;
+ ZipPodResult result;
+ result.ok = false;
+ /+ ↓ verify zip file exists +/
+ if (!exists(zip_path) || !zip_path.isFile) {
+ result.error_msg = "zip file not found: " ~ zip_path;
+ return result;
+ }
+ /+ ↓ derive pod name from zip filename +/
+ string zip_basename = zip_path.baseName.stripExtension;
+ /+ ↓ read and parse zip archive +/
+ ZipArchive zip;
+ try {
+ zip = new ZipArchive(read(zip_path));
+ } catch (ZipException ex) {
+ result.error_msg = "failed to read zip archive: " ~ zip_path ~ " - " ~ ex.msg;
+ return result;
+ } catch (Exception ex) {
+ result.error_msg = "error reading zip file: " ~ zip_path ~ " - " ~ ex.msg;
+ return result;
+ }
+ /+ ↓ validate entry count +/
+ if (zip.directory.length > MAX_ENTRY_COUNT) {
+ result.error_msg = "zip archive has too many entries ("
+ ~ zip.directory.length.to!string ~ " > " ~ MAX_ENTRY_COUNT.to!string ~ "): " ~ zip_path;
+ return result;
+ }
+ /+ ↓ validate all entries before extracting any +/
+ size_t total_size = 0;
+ foreach (name, member; zip.directory) {
+ /+ validate entry name +/
+ string name_err = validateEntryName(name);
+ if (name_err.length > 0) {
+ result.error_msg = name_err;
+ return result;
+ }
+ /+ check per-entry size +/
+ if (member.expandedSize > MAX_ENTRY_SIZE) {
+ result.error_msg = "zip entry too large ("
+ ~ member.expandedSize.to!string ~ " bytes): " ~ name;
+ return result;
+ }
+ /+ check total size +/
+ total_size += member.expandedSize;
+ if (total_size > MAX_TOTAL_SIZE) {
+ result.error_msg = "zip archive total size exceeds limit ("
+ ~ MAX_TOTAL_SIZE.to!string ~ " bytes): " ~ zip_path;
+ return result;
+ }
+ }
+ /+ ↓ create temp directory +/
+ string tmp_base = tempDir.buildPath("spine-zip-pod");
+ try {
+ if (!exists(tmp_base))
+ mkdirRecurse(tmp_base);
+ } catch (FileException ex) {
+ result.error_msg = "failed to create temp base directory: " ~ ex.msg;
+ return result;
+ }
+ /+ pod directory inside temp: tmp_base/pod_name/ +/
+ string pod_dir = tmp_base.buildPath(zip_basename);
+ try {
+ if (exists(pod_dir))
+ rmdirRecurse(pod_dir);
+ mkdirRecurse(pod_dir);
+ } catch (FileException ex) {
+ result.error_msg = "failed to create temp pod directory: " ~ ex.msg;
+ return result;
+ }
+ /+ ↓ extract entries +/
+ /+ zip internal structure uses paths like:
+ pod.manifest, conf/dr_document_make,
+ pod/media/text/en/filename.sst, image/filename.png
+ but the extracted pod directory needs to look like a normal pod:
+ pod.manifest, conf/dr_document_make,
+ media/text/en/filename.sst, image/filename.png
+ The "pod/" prefix in zip entries for text files maps to the pod root.
+ +/
+ /+ ↓ pre-compute canonical pod path for containment checks +/
+ auto canonical_pod = (pod_dir.asNormalizedPath).array.to!string ~ "/";
+ foreach (name, member; zip.directory) {
+ /+ skip directory entries +/
+ if (name.length > 0 && name[$-1] == '/')
+ continue;
+ /+ ↓ map zip internal path to filesystem path +/
+ /+ entries with "pod/" prefix: strip it so media/text/en/file.sst ends up at pod_dir/media/text/en/file.sst +/
+ string entry_path = name;
+ if (entry_path.length > 4 && entry_path[0..4] == "pod/") {
+ entry_path = entry_path[4..$];
+ }
+ string out_path = pod_dir.buildPath(entry_path);
+ /+ ↓ verify resolved path is within pod_dir (defense in depth) +/
+ auto canonical_out = (out_path.asNormalizedPath).array.to!string;
+ if (canonical_out.length < canonical_pod.length
+ || canonical_out[0..canonical_pod.length] != canonical_pod)
+ {
+ result.error_msg = "zip entry escapes extraction directory: " ~ name;
+ try { rmdirRecurse(pod_dir); } catch (FileException) {}
+ return result;
+ }
+ /+ ↓ create parent directories +/
+ string parent = out_path.dirName;
+ try {
+ if (!exists(parent))
+ mkdirRecurse(parent);
+ } catch (FileException ex) {
+ result.error_msg = "failed to create directory for: " ~ name ~ " - " ~ ex.msg;
+ try { rmdirRecurse(pod_dir); } catch (FileException) {}
+ return result;
+ }
+ /+ ↓ decompress and write file +/
+ try {
+ auto data = zip.expand(member);
+ std.file.write(out_path, data);
+ } catch (Exception ex) {
+ result.error_msg = "failed to extract: " ~ name ~ " - " ~ ex.msg;
+ try { rmdirRecurse(pod_dir); } catch (FileException) {}
+ return result;
+ }
+ }
+ /+ ↓ verify no symlinks were created (defense in depth) +/
+ string symlink_err = checkForSymlinks(pod_dir);
+ if (symlink_err.length > 0) {
+ result.error_msg = symlink_err;
+ try { rmdirRecurse(pod_dir); } catch (FileException) {}
+ return result;
+ }
+ /+ ↓ verify pod.manifest exists in extracted content +/
+ if (!exists(pod_dir.buildPath("pod.manifest"))) {
+ result.error_msg = "zip archive does not contain pod.manifest: " ~ zip_path;
+ try { rmdirRecurse(pod_dir); } catch (FileException) {}
+ return result;
+ }
+ result.tmp_dir = tmp_base;
+ result.pod_dir = pod_dir;
+ result.ok = true;
+ return result;
+ }
+
+ /+ ↓ recursively check for symlinks in extracted directory +/
+ @trusted string checkForSymlinks(string dir_path) {
+ try {
+ foreach (entry; dirEntries(dir_path, SpanMode.depth)) {
+ if (entry.isSymlink) {
+ return "symlink found in zip extraction: " ~ entry.name;
+ }
+ }
+ } catch (FileException ex) {
+ return "error checking for symlinks: " ~ ex.msg;
+ }
+ return "";
+ }
+
+ /+ ↓ download a zip pod from a URL to a temp file +/
+ enum size_t MAX_DOWNLOAD_SIZE = 200 * 1024 * 1024; /+ 200 MB download limit +/
+ enum int DOWNLOAD_TIMEOUT = 120; /+ seconds +/
+
+ static auto rgx_url_zip = ctRegex!(`^https?://[a-zA-Z0-9._:/-]+[.]zip$`);
+
+ struct DownloadResult {
+ string local_path; /+ path to downloaded temp file +/
+ bool ok;
+ string error_msg;
+ }
+
+ bool isUrl(string arg) {
+ return arg.length > 8
+ && (arg[0..8] == "https://" || arg[0..7] == "http://");
+ }
+
+ @trusted DownloadResult downloadZipUrl(string url) {
+ import std.process : execute, environment;
+ DownloadResult result;
+ result.ok = false;
+ /+ ↓ validate URL scheme +/
+ if (url.length < 8 || (url[0..8] != "https://" && url[0..7] != "http://")) {
+ result.error_msg = "only http/https URLs are supported: " ~ url;
+ return result;
+ }
+ if (url[0..7] == "http://" && url[0..8] != "https://") {
+ stderr.writeln("WARNING: downloading over insecure http: ", url);
+ }
+ /+ ↓ validate URL format +/
+ if (!(url.matchFirst(rgx_url_zip))) {
+ result.error_msg = "URL does not match expected zip URL pattern: " ~ url;
+ return result;
+ }
+ /+ ↓ reject URLs that could target internal services +/
+ {
+ import std.uni : toLower;
+ string url_lower = url.toLower;
+ /+ strip scheme to get host portion +/
+ string after_scheme = (url_lower[0..8] == "https://")
+ ? url_lower[8..$]
+ : url_lower[7..$];
+ /+ extract host (up to first / or :) +/
+ string host;
+ foreach (i, c; after_scheme) {
+ if (c == '/' || c == ':') {
+ host = after_scheme[0..i];
+ break;
+ }
+ }
+ if (host.length == 0) host = after_scheme;
+ if (host == "localhost"
+ || host == "127.0.0.1"
+ || host == "::1"
+ || host == "[::1]"
+ || host == "0.0.0.0"
+ || host.canFind("169.254.")
+ || host.canFind("10.")
+ || host.canFind("192.168.")
+ ) {
+ result.error_msg = "URL targets a local/private address: " ~ url;
+ return result;
+ }
+ }
+ /+ ↓ derive filename from URL +/
+ string url_basename = url.baseName;
+ if (url_basename.length == 0 || url_basename.indexOf('.') < 0) {
+ result.error_msg = "cannot determine filename from URL: " ~ url;
+ return result;
+ }
+ /+ ↓ create temp directory for download +/
+ string tmp_base = tempDir.buildPath("spine-zip-pod");
+ try {
+ if (!exists(tmp_base))
+ mkdirRecurse(tmp_base);
+ } catch (FileException ex) {
+ result.error_msg = "failed to create temp directory: " ~ ex.msg;
+ return result;
+ }
+ string tmp_file = tmp_base.buildPath(url_basename);
+ /+ ↓ download using curl +/
+ auto curl_result = execute([
+ "curl",
+ "--silent", "--show-error",
+ "--fail", /+ fail on HTTP errors +/
+ "--location", /+ follow redirects +/
+ "--max-redirs", "5", /+ limit redirects +/
+ "--max-time", DOWNLOAD_TIMEOUT.to!string,
+ "--max-filesize", MAX_DOWNLOAD_SIZE.to!string,
+ "--proto", "=https,http", /+ restrict protocols +/
+ "--output", tmp_file,
+ url
+ ]);
+ if (curl_result.status != 0) {
+ result.error_msg = "download failed: " ~ url;
+ if (curl_result.output.length > 0)
+ result.error_msg ~= " - " ~ curl_result.output;
+ /+ clean up partial download +/
+ try { if (exists(tmp_file)) remove(tmp_file); } catch (FileException) {}
+ return result;
+ }
+ if (!exists(tmp_file) || !tmp_file.isFile) {
+ result.error_msg = "download produced no file: " ~ url;
+ return result;
+ }
+ result.local_path = tmp_file;
+ result.ok = true;
+ return result;
+ }
+
+ /+ ↓ clean up a downloaded temp file +/
+ void cleanupDownload(ref DownloadResult dlr) {
+ if (dlr.local_path.length > 0 && exists(dlr.local_path)) {
+ try {
+ remove(dlr.local_path);
+ } catch (FileException ex) {
+ stderr.writeln("WARNING: failed to clean up downloaded file: ", dlr.local_path);
+ }
+ }
+ dlr.ok = false;
+ }
+
+ /+ ↓ clean up extracted temp directory +/
+ void cleanupZipPod(ref ZipPodResult zpr) {
+ if (zpr.pod_dir.length > 0 && exists(zpr.pod_dir)) {
+ try {
+ rmdirRecurse(zpr.pod_dir);
+ } catch (FileException ex) {
+ stderr.writeln("WARNING: failed to clean up temp zip extraction: ", zpr.pod_dir);
+ }
+ }
+ zpr.ok = false;
+ }
+}
diff --git a/src/sisudoc/ocda/meta/conf_make_meta_json.d b/src/sisudoc/ocda/meta/conf_make_meta_json.d
new file mode 100644
index 0000000..c996b12
--- /dev/null
+++ b/src/sisudoc/ocda/meta/conf_make_meta_json.d
@@ -0,0 +1,693 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.meta.conf_make_meta_json;
+@safe:
+static template contentJSONtoSpineStruct() {
+ import std.algorithm;
+ import std.array;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.utf;
+ import std.conv : to;
+ import sisudoc.meta.conf_make_meta_structs;
+ import sisudoc.meta.conf_make_meta_json;
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ ConfComposite _struct_composite;
+ auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) {
+ mixin spineRgxIn;
+ 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/sisudoc/ocda/meta/conf_make_meta_structs.d b/src/sisudoc/ocda/meta/conf_make_meta_structs.d
new file mode 100644
index 0000000..6bfd8fb
--- /dev/null
+++ b/src/sisudoc/ocda/meta/conf_make_meta_structs.d
@@ -0,0 +1,309 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.conf_make_meta_structs;
+@safe:
+import std.exception;
+import std.json;
+import std.path;
+import std.regex;
+import std.stdio;
+import std.string;
+import std.typecons;
+import std.utf;
+import std.conv : to;
+import sisudoc.meta.defaults;
+import sisudoc.meta.rgx_yaml;
+import sisudoc.meta.rgx;
+mixin spineRgxIn;
+static auto rgx = RgxI();
+mixin spineRgxYamlTags;
+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 = "┥sisudoc.org┝┤https://sisudoc.org├"
+ ~ " ┥doc-reform.org┝┤https://doc-reform.org├"
+ ~ " ┥sources / git┝┤https://git.sisudoc.org/projects├";
+ 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) {
+ return _mk;
+ }
+ 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 = "┥sisudoc.org┝┤https://sisudoc.org├"
+ ~ " ┥doc-reform.org┝┤https://doc-reform.org├"
+ ~ " ┥sources / git┝┤https://git.sisudoc.org/projects├";
+ 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/sisudoc/ocda/meta/conf_make_meta_yaml.d b/src/sisudoc/ocda/meta/conf_make_meta_yaml.d
new file mode 100644
index 0000000..f4ee7d9
--- /dev/null
+++ b/src/sisudoc/ocda/meta/conf_make_meta_yaml.d
@@ -0,0 +1,964 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.meta.conf_make_meta_yaml;
+@safe:
+template contentYAMLtoSpineStruct() {
+ import std.algorithm;
+ import std.array;
+ import std.exception;
+ import std.path;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.utf;
+ import std.conv : to;
+ import sisudoc.meta.conf_make_meta_structs;
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx_yaml;
+ import sisudoc.meta.rgx;
+ ConfComposite _struct_composite;
+ @system ConfComposite contentYAMLtoSpineStruct(C,Y,M,O,Cfg)(
+ C _struct_composite,
+ 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;
+ }
+ @system string _get_yaml_node_string(Y)(
+ Y _yaml,
+ string _return,
+ string _title,
+ string _subtitle,
+ bool _munge=false
+ ) {
+ if ((_title in _yaml && _yaml[_title].type.sequence)
+ && (_yaml[_title].type.mapping
+ && _yaml[_title].tag.match(rgx_y.yaml_tag_is_map))
+ ) {
+ if (_subtitle in _yaml[_title]
+ && _yaml[_title][_subtitle].type.string
+ && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_str)
+ ) {
+ _return = (!(_munge))
+ ? _yaml[_title][_subtitle].get!string
+ : check_input_markup(_yaml[_title][_subtitle].get!string);
+ }
+ }
+ return _return;
+ }
+ @system int _get_yaml_node_int(Y)(
+ Y _yaml,
+ int _return,
+ string _title,
+ string _subtitle
+ ) {
+ if ((_title in _yaml && _yaml[_title].type.sequence)
+ && (_yaml[_title].type.mapping
+ && _yaml[_title].tag.match(rgx_y.yaml_tag_is_map))
+ ) {
+ if (_subtitle in _yaml[_title]
+ && _yaml[_title][_subtitle].type.string
+ && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_int)
+ ) {
+ _return = _yaml[_title][_subtitle].get!int;
+ } else if (_subtitle in _yaml[_title]
+ && _yaml[_title][_subtitle].type.string
+ && _yaml[_title][_subtitle].tag.match(rgx_y.yaml_tag_is_str)
+ ) {
+ _return = _yaml[_title][_subtitle].get!int;
+ }
+ }
+ return _return;
+ }
+ confCompositeMakeBuild _mk;
+ if (_identifier != "header") { // called only once per run anyway
+ string _init_string;
+ /+ 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 {
+ _init_string = (_cfg.http_request_type.empty) ? "http" : _cfg.http_request_type;
+ _struct_composite.conf.w_srv_http = _get_yaml_node_string(_yaml, _init_string, "webserv", "http");
+ }
+ if (_opt_action.cgi_search_title.length > 0) {
+ _struct_composite.conf.w_srv_cgi_search_form_title = _opt_action.cgi_search_title;
+ } else {
+ _init_string = (_cfg.cgi_search_form_title.empty) ? "≅ SiSU spine search form" : _cfg.cgi_search_form_title;
+ _struct_composite.conf.w_srv_cgi_search_form_title = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_search_form_title");
+ }
+ if (_opt_action.cgi_sqlite_search_filename.length > 0) {
+ _struct_composite.conf.w_srv_cgi_search_script = _opt_action.cgi_sqlite_search_filename;
+ } else {
+ _init_string = (_cfg.cgi_filename.empty) ? "spine_search" : _cfg.cgi_filename;
+ _struct_composite.conf.w_srv_cgi_search_script = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_search_script");
+ }
+ if (_opt_action.sqliteDB_filename.length > 0) {
+ _struct_composite.conf.w_srv_db_sqlite_filename = _opt_action.sqliteDB_filename;
+ } else {
+ _init_string = (_cfg.db_sqlite_filename.empty) ? "spine.search.db" : _cfg.db_sqlite_filename;
+ _struct_composite.conf.w_srv_db_sqlite_filename = _get_yaml_node_string(_yaml, _init_string, "webserv", "db_sqlite_filename");
+ }
+ if (_opt_action.sqliteDB_path.length > 0) {
+ _struct_composite.conf.w_srv_db_sqlite_path = _opt_action.sqliteDB_path;
+ } else {
+ _init_string = (_cfg.db_sqlite_path.empty) ? "/var/www/sqlite" : _cfg.db_sqlite_path;
+ _struct_composite.conf.w_srv_db_sqlite_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "db_sqlite_path");
+ }
+ if (_opt_action.cgi_url_action.length > 0) {
+ _struct_composite.conf.w_srv_cgi_action
+ = _opt_action.cgi_url_action;
+ } else {
+ _init_string = (_cfg.www_url_doc_root.empty) ? "http://locahost" : _cfg.www_url_doc_root; // "https://sisudoc.org"
+ _struct_composite.conf.w_srv_cgi_action = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_action");
+ 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; // not yet right
+ }
+ }
+ 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 {
+ _init_string = (_cfg.processing_path_doc_root.empty) ? "/var/www/spine" : _cfg.processing_path_doc_root;
+ _struct_composite.conf.w_srv_data_root_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_root_path");
+ }
+ }
+ if (_opt_action.cgi_bin_root.length > 0) {
+ _struct_composite.conf.w_srv_cgi_bin_path = _opt_action.cgi_bin_root;
+ } else {
+ _init_string = (_cfg.cgi_bin_root.empty) ? "/var/www/cgi/cgi-bin" : _cfg.cgi_bin_root;
+ _struct_composite.conf.w_srv_cgi_bin_path = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_bin_path");
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_root_part");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_data_root_part = _init_string; }
+ } {
+ _init_string = "image"; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "images_root_part");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_images_root_part = _init_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
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "data_http");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_data_http = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_http");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_http = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "host");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_host = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_bin_subpath");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_bin_subpath = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_port");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_port = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_user");
+ if (!(_init_string.empty)) { _struct_composite.conf.w_srv_cgi_user = _init_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";
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "webserv", "cgi_host");
+ _struct_composite.conf.w_srv_cgi_host = (!(_init_string.empty)) ? _init_string : _struct_composite.conf.w_srv_host;
+ }
+ 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)?
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "processing", "concord_max");
+ if (!(_init_string.empty)) { _struct_composite.conf.processing_concord_max = _init_string; }
+ }
+ if ("flag" in _yaml
+ && _yaml["flag"].type.sequence
+ ) {
+ if (_yaml["flag"].type.mapping
+ && _yaml["flag"].tag.match(rgx_y.yaml_tag_is_map)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act0");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act0 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act1");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act1 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act2");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act2 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act3");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act3 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act4");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act4 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act5");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act5 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act6");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act6 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act7");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act7 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act8");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act8 = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "flag", "act9");
+ if (!(_init_string.empty)) { _struct_composite.conf.flag_act9 = _init_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;
+ _init_string = _set_papersize; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "papersize");
+ if (!(_init_string.empty)) { _set_papersize = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "text_wrap");
+ if (!(_init_string.empty)) { _struct_composite.conf.set_text_wrap = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "emphasis");
+ if (!(_init_string.empty)) { _struct_composite.conf.set_emphasis = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "language");
+ if (!(_init_string.empty)) { _struct_composite.conf.set_language = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "default", "digest");
+ if (!(_init_string.empty)) { _struct_composite.conf.set_digest = _init_string; }
+ }
+ }
+ if ("search" in _yaml
+ && _yaml["search"].type.sequence
+ ) {
+ if (_yaml["search"].type.mapping
+ && _yaml["search"].tag.match(rgx_y.yaml_tag_is_map)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "flag");
+ if (!(_init_string.empty)) { _struct_composite.conf.search_flag = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "action");
+ if (!(_init_string.empty)) { _struct_composite.conf.search_action = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "db");
+ if (!(_init_string.empty)) { _struct_composite.conf.search_db = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "search", "title");
+ if (!(_init_string.empty)) { _struct_composite.conf.search_title = _init_string; }
+ }
+ }
+ }
+ } else { // !(_identifier != "header")
+ string _init_string;
+ int _init_int;
+ /+ make ------------------------------------------------------------------- +/
+ if ("make" in _yaml
+ && _yaml["make"].type.sequence
+ ) {
+ if (_yaml["make"].type.mapping
+ && _yaml["make"].tag.match(rgx_y.yaml_tag_is_map)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "doc_type");
+ if (!(_init_string.empty)) { _struct_composite.make_str.doc_type = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "breaks");
+ if (!(_init_string.empty)) { _struct_composite.make_str.breaks = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "bold");
+ if (!(_init_string.empty)) { _struct_composite.make_str.bold = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "cover_image");
+ if (!(_init_string.empty)) { _struct_composite.make_str.cover_image = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "css");
+ if (!(_init_string.empty)) { _struct_composite.make_str.css = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "make", "emphasis");
+ if (!(_init_string.empty)) { _struct_composite.make_str.emphasis = _init_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);
+ foreach(string hbt; __match_footer_array.to!(string[])) {
+ _struct_composite.make_str.footer ~= url_markup(hbt);
+ }
+ } else if ("footer" in _yaml["make"]
+ && _yaml["make"]["footer"].type.string
+ && _yaml["make"]["footer"].tag.match(rgx_y.yaml_tag_is_seq)
+ ) {
+ _struct_composite.make_str.footer = [];
+ foreach(string hbt; _yaml["make"]["footer"]) {
+ _struct_composite.make_str.footer ~= url_markup(hbt);
+ }
+ }
+ 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;
+ }
+ }
+ {
+ _init_int = _get_yaml_node_int(_yaml, 99, "make", "auto_num_depth");
+ if (!(_init_int == 99)) { _struct_composite.make_str.auto_num_depth = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "author");
+ if (!(_init_string.empty)) { _struct_composite.meta.creator_author = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "email");
+ if (!(_init_string.empty)) { _struct_composite.meta.creator_author_email = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "illustrator");
+ if (!(_init_string.empty)) { _struct_composite.meta.creator_illustrator = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "creator", "translator");
+ if (!(_init_string.empty)) { _struct_composite.meta.creator_translator = _init_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;
+ }
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "edition");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_edition = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "full");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_full = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "language");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_language = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "note");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_note = _init_string; }
+ }
+ if ("subtitle" in _yaml["title"]) {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "subtitle");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_subtitle = _init_string; }
+ } else if ("sub" in _yaml["title"]) {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "title", "sub");
+ if (!(_init_string.empty)) { _struct_composite.meta.title_subtitle = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "dewey");
+ if (!(_init_string.empty)) { _struct_composite.meta.classify_dewey = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "loc");
+ if (!(_init_string.empty)) { _struct_composite.meta.classify_loc = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "classify", "keywords");
+ if (!(_init_string.empty)) { _struct_composite.meta.classify_keywords = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "added_to_site");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_added_to_site = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "available");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_available = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "created");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_created = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "issued");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_issued = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "modified");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_modified = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "published");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_published = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "date", "valid");
+ if (!(_init_string.empty)) { _struct_composite.meta.date_valid = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "abstract");
+ if (!(_init_string.empty)) { _struct_composite.meta.notes_abstract = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "description");
+ if (!(_init_string.empty)) { _struct_composite.meta.notes_description = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "notes", "summary");
+ if (!(_init_string.empty)) { _struct_composite.meta.notes_summary = _init_string; }
+ }
+ }
+ }
+ if ("original" in _yaml
+ && _yaml["original"].type.sequence
+ ) {
+ if (_yaml["original"].type.mapping
+ && _yaml["original"].tag.match(rgx_y.yaml_tag_is_map)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "language");
+ if (!(_init_string.empty)) { _struct_composite.meta.original_language = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "language_char");
+ if (!(_init_string.empty)) { _struct_composite.meta.original_language_char = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "source");
+ if (!(_init_string.empty)) { _struct_composite.meta.original_source = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "original", "title");
+ if (!(_init_string.empty)) { _struct_composite.meta.original_title = _init_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)
+ ) {
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright", true);
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_text");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_text = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_audio");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_audio = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_cover");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_cover = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_illustrations");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_illustrations = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_photographs");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_photographs = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_translation");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_translation = _init_string; }
+ } {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "copyright_video");
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_copyright_video = _init_string; }
+ }
+ {
+ _init_string = ""; _init_string = _get_yaml_node_string(_yaml, _init_string, "rights", "license", true);
+ if (!(_init_string.empty)) { _struct_composite.meta.rights_license = _init_string; }
+ }
+ }
+ }
+ }
+ return _struct_composite;
+ }
+}
+template configParseYAMLreturnSpineStruct() {
+ import dyaml;
+ import sisudoc.meta.conf_make_meta_structs;
+ import sisudoc.meta.conf_make_meta_json;
+ mixin contentYAMLtoSpineStruct;
+ @system ConfComposite configParseYAMLreturnSpineStruct(T,M,O,Cfg)(
+ T _document_struct,
+ ConfComposite _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;
+ import std.regex;
+ import std.stdio;
+ // import std.traits;
+ import std.typecons;
+ import std.utf;
+ import std.conv : to;
+ import dyaml;
+ import sisudoc.meta.conf_make_meta_structs;
+ import sisudoc.meta.conf_make_meta_json;
+ import sisudoc.meta.rgx_yaml;
+ import sisudoc.meta.rgx;
+ mixin spineRgxIn;
+ mixin contentJSONtoSpineStruct;
+ static auto rgx = RgxI();
+ mixin spineRgxYamlTags;
+ static auto rgx_y = RgxYaml();
+ @system ConfComposite docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(Src,M,O,Cfg)(
+ Src header_src,
+ ConfComposite _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/sisudoc/ocda/meta/defaults.d b/src/sisudoc/ocda/meta/defaults.d
new file mode 100644
index 0000000..53a791e
--- /dev/null
+++ b/src/sisudoc/ocda/meta/defaults.d
@@ -0,0 +1,297 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.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/sisudoc/ocda/meta/doc_debugs.d b/src/sisudoc/ocda/meta/doc_debugs.d
new file mode 100644
index 0000000..40a0af5
--- /dev/null
+++ b/src/sisudoc/ocda/meta/doc_debugs.d
@@ -0,0 +1,250 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
+
++/
+/++
+ output debugs
++/
+module sisudoc.meta.doc_debugs;
+template spineDebugs() {
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx_files;
+ import std.algorithm;
+ import std.array;
+ import std.container;
+ import std.exception;
+ import std.json;
+ import std.stdio;
+ import std.file;
+ import std.path;
+ import std.range;
+ import std.regex;
+ import std.string;
+ import std.typecons;
+ import std.utf;
+ import std.conv : to;
+ auto spineDebugs(S,T)(
+ const S contents,
+ T doc_matters,
+ ) {
+ 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/sisudoc/ocda/meta/metadoc.d b/src/sisudoc/ocda/meta/metadoc.d
new file mode 100644
index 0000000..421ff78
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc.d
@@ -0,0 +1,307 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.metadoc;
+@safe:
+template spineAbstraction() {
+ import std.datetime;
+ import std.digest.crc;
+ import std.digest.sha;
+ import sisudoc.meta;
+ import sisudoc.meta.metadoc_from_src;
+ import sisudoc.meta.conf_make_meta_structs;
+ import sisudoc.meta.conf_make_meta_json;
+ import sisudoc.meta.defaults;
+ import sisudoc.io_in.paths_source;
+ import sisudoc.io_in.read_config_files;
+ import sisudoc.io_in.read_source_files;
+ mixin spineBiblio;
+ enum makeMeta { make, meta }
+ enum docAbst { doc_abstract_obj, doc_has }
+ @system auto spineAbstraction(E,P,O,Cfg,M)(
+ E _env,
+ P program_info,
+ O _opt_action,
+ Cfg _cfg,
+ M _manifest,
+ ConfComposite _make_and_meta_struct
+ ){
+ { /+ document config/make file +/
+ auto _config_document_struct = readConfigDoc!()(_manifest, _env);
+ import sisudoc.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);
+ auto doc_digests = _header_body_insertfilelist_imagelist.doc_digest; // CHECK, REVIEW, discard likely, other route taken
+ 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.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 sisudoc.meta.conf_make_meta_yaml;
+ _make_and_meta_struct =
+ docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()(
+ _header_body_insertfilelist_imagelist.header_raw,
+ _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.sourcefile_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 ST_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;
+ }
+ ConfComposite conf_make_meta() {
+ return _make_and_meta_struct;
+ }
+ auto doc_digest() {
+ return doc_digests;
+ }
+ 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.insert_file_list;
+ }
+ auto image_list() {
+ return _doc_has_struct.imagelist;
+ }
+ }
+ return SRC_();
+ }
+ }
+ auto doc_matters = ST_DocumentMatters();
+ if ((_opt_action.debug_do)
+ || (_opt_action.debug_do_stages)
+ ) {
+ writeln("- step4 complete for [", _manifest.src.filename, "]");
+ }
+ auto theDOC() {
+ struct ST_DOC {
+ const auto abstraction() {
+ return doc_abstraction;
+ }
+ auto matters() {
+ return doc_matters;
+ }
+ }
+ return ST_DOC();
+ }
+ auto the_doc = theDOC();
+ return the_doc;
+ }
+}
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d
new file mode 100644
index 0000000..4967c1f
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_from_src.d
@@ -0,0 +1,1537 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
+
++/
+// document abstraction:
+// abstraction of sisu markup for downstream processing
+// metadoc_from_src.d
+module sisudoc.meta.metadoc_from_src;
+@safe:
+template docAbstraction() {
+ // ↓ abstraction imports
+ import std.algorithm;
+ import std.container;
+ import std.digest.sha;
+ import std.file;
+ import std.json;
+ import std.path;
+ import sisudoc.meta;
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import sisudoc.meta.metadoc_object_setter;
+ import sisudoc.meta.rgx;
+ public import sisudoc.meta.metadoc_from_src_functions;
+ mixin docAbstractionFunctions;
+ @system auto docAbstraction(CMM,Opt,Mf) (
+ 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;
+ int[string] node_para_int_ = node_metadata_para_int;
+ string[string] node_para_str_ = node_metadata_para_str;
+ ObjGenericComposite comp_obj_;
+ line_occur = [
+ "heading" : 0,
+ "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]);
+ }
+ }
+ _loopMarkupSrcByLineStruct 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);
+ {
+ ST_txt_by_line_block_generic _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");
+ {
+ ST_txt_by_line_block_generic _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 ]));
+ }
+ {
+ ST_txt_by_line_block_generic _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) {
+ {
+ ST_txt_by_line_block_poem _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg);
+ {
+ an_object = _get.this_object;
+ pith = _get.pith;
+ 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;
+ }
+ {
+ ST_txt_by_line_block_start _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
+ ST_flow_book_index _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);
+ {
+ an_object = _get.this_object;
+ pith = _get.pith;
+ 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;
+ {
+ ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
+ {
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ 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
+ {
+ ST_flow_heading_found _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith);
+ {
+ heading_match_str = _get.heading_match_str;
+ heading_match_rgx = _get.heading_match_rgx;
+ 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
+ {
+ ST_flow_heading_make_set _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith);
+ {
+ line = _get.line;
+ an_object = _get.this_object;
+ 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);
+ {
+ ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
+ {
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ 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
+ {
+ ST_flow_block_flag_line_empty _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!
+ {
+ ST_flow_table_of_contents_gather_headings _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"];
+ }
+ ObjGenericComposite 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
+ {
+ ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
+ {
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ 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";
+ ObjGenericComposite 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);
+ {
+ ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
+ {
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ 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
+ _loopMarkupSrcByLineStruct _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith);
+ the_document_toc_section = _doc_by_line.toc;
+ the_document_body_section = _doc_by_line.body;
+ the_document_glossary_section = _doc_by_line.glossary;
+ 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) { // writeln("toc"); // 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) { // writeln("body");
+ 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.metainfo.sha256 = obj.obj_digest;
+ obj = _links(obj);
+ }
+ }
+ auto image_list = (_images.sort()).uniq;
+ // endnotes optional only one 1~ level
+ if (the_document_endnotes_section.length > 1) { // writeln("endnotes");
+ 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) { // writeln("glossary");
+ 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.metainfo.sha256 = obj.obj_digest;
+ obj = _links(obj);
+ }
+ }
+ // bibliography optional only one 1~ level
+ if (the_document_bibliography_section.length > 1) { // writeln("bibliography");
+ 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.metainfo.sha256 = obj.obj_digest;
+ 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) { // writeln("book index"); // 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.metainfo.sha256 = obj.obj_digest;
+ 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) { // writeln("blurb");
+ 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.metainfo.sha256 = obj.obj_digest;
+ 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];
+ }
+ }
+ }
+ }
+ }
+ }
+ /+ ↓ compute children_headings for heading objects +/
+ {
+ int[][int] heading_children;
+ foreach (obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading" && obj.metainfo.parent_ocn != 0) {
+ heading_children[obj.metainfo.parent_ocn] ~= obj.metainfo.ocn;
+ }
+ }
+ foreach (ref obj; the_document_head_section) {
+ if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) {
+ obj.metainfo.children_headings = heading_children[obj.metainfo.ocn];
+ }
+ }
+ foreach (ref obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) {
+ obj.metainfo.children_headings = heading_children[obj.metainfo.ocn];
+ }
+ }
+ }
+ // 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",],
+ "text": ["head", "toc", "body",],
+ ];
+ if (document_the["endnotes"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "endnotes";
+ document_section_keys_sequenced["seg"] ~= "endnotes";
+ document_section_keys_sequenced["latex"] ~= "endnotes";
+ document_section_keys_sequenced["text"] ~= "endnotes";
+ }
+ if (document_the["glossary"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "glossary";
+ document_section_keys_sequenced["seg"] ~= "glossary";
+ document_section_keys_sequenced["sql"] ~= "glossary";
+ document_section_keys_sequenced["latex"] ~= "glossary";
+ document_section_keys_sequenced["text"] ~= "glossary";
+ }
+ if (document_the["bibliography"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "bibliography";
+ document_section_keys_sequenced["seg"] ~= "bibliography";
+ document_section_keys_sequenced["sql"] ~= "bibliography";
+ document_section_keys_sequenced["latex"] ~= "bibliography";
+ document_section_keys_sequenced["text"] ~= "bibliography";
+ }
+ if (document_the["bookindex"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "bookindex";
+ document_section_keys_sequenced["seg"] ~= "bookindex";
+ document_section_keys_sequenced["sql"] ~= "bookindex";
+ document_section_keys_sequenced["latex"] ~= "bookindex";
+ document_section_keys_sequenced["text"] ~= "bookindex";
+ }
+ if (document_the["blurb"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "blurb";
+ document_section_keys_sequenced["seg"] ~= "blurb";
+ document_section_keys_sequenced["sql"] ~= "blurb";
+ document_section_keys_sequenced["latex"] ~= "blurb";
+ document_section_keys_sequenced["text"] ~= "blurb";
+ }
+ if ((opt_action.html)
+ || (opt_action.html_scroll)
+ || (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;
+ }
+ }
+ DocHas_ 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/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d
new file mode 100644
index 0000000..bb3cd4e
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d
@@ -0,0 +1,5432 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
+
++/
+// document abstraction:
+// abstraction of sisu markup for downstream processing
+// metadoc_from_src.d
+module sisudoc.meta.metadoc_from_src_functions;
+@safe:
+template docAbstractionFunctions() {
+ // ↓ abstraction imports
+ // ↓ 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_quotemarks_code_open)) {
+ dochas["codeblock"]++;
+ an_object["lang"] = "";
+ an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
+ an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : "";
+ debug(codequotemarks) { writefln( "* [code quotemarks] %s", line); }
+ pith["block_is"] = eN.blk_is.code;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks; //
+ } else if (auto m = line.matchFirst(rgx.block_quotemarks_poem_open)) {
+ dochas["poem"]++;
+ an_object["syntax"] = "";
+ an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
+ an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
+ debug(poem) { writefln( "* [poem quotemarks] %s", line); }
+ object_number_poem["start"] = obj_cite_digits.object_number.to!string;
+ pith["block_is"] = eN.blk_is.poem;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks; //
+ pith["verse_new"] = eN.bi.on;
+ } else if (auto m = line.matchFirst(rgx.block_quotemarks_group_open)) {
+ dochas["group"]++;
+ an_object["syntax"] = "";
+ an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
+ an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
+ debug(group) { writefln( "* [group quotemarks] %s", line); }
+ pith["block_is"] = eN.blk_is.group;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks;
+ } else if (auto m = line.matchFirst(rgx.block_quotemarks_block_open)) {
+ dochas["block"]++;
+ an_object["syntax"] = "";
+ an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
+ an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
+ debug(block) { writefln( "* [block quotemarks] %s", line); }
+ pith["block_is"] = eN.blk_is.block;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks;
+ } else if (auto m = line.matchFirst(rgx.block_quotemarks_quote_open)) {
+ dochas["quote"]++;
+ an_object["syntax"] = "";
+ an_object["attrib"] = m["attrib"].to!string;
+ an_object["lang"] = m["lang"].to!string;
+ debug(quote) { writefln( "* [quote quotemarks] %s", line); // quote (quotemarks) open
+ }
+ pith["block_is"] = eN.blk_is.quote;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks;
+ } else if (auto m = line.matchFirst(rgx.block_quotemarks_table_open)) { // quotemarks table open
+ debug(table) { writefln( "* [table quotemarks] %s", line); }
+ dochas["table"] ++;
+ an_object["table_head"] = m["attrib"].to!string;
+ an_object["block_type"] = "quotemarks";
+ pith["block_is"] = eN.blk_is.table;
+ pith["block_state"] = eN.blk_state.on;
+ pith["block_delim"] = eN.blk_delim.quotemarks;
+ } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) {
+ dochas["codeblock"]++;
+ an_object["lang"] = "";
+ 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.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ debug(group) { writeln(line); }
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
+ pith["block_is"] = eN.blk_is.group;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ debug(group) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ debug(group) { writeln(line); }
+ 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.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ debug(block) { writeln(line); }
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
+ pith["block_is"] = eN.blk_is.block;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ debug(block) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ debug(block) { writeln(line); }
+ 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.quotemarks) {
+ if (auto m = line.matchFirst(rgx.block_quotemarks_close)) {
+ an_object[an_object_key] = "verse";
+ debug(poem) { writefln( "* [poem quotemarks] %s", line); }
+ if (processing.length > 0) {
+ an_object[an_object_key] = processing["verse"];
+ }
+ if (an_object.length > 0) {
+ debug(poem) { writeln(__LINE__); writeln(obj_cite_digits.object_number, line); }
+ processing.remove("verse");
+ an_object["is"] = "verse";
+ ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
+ = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
+ an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
+ anchor_tag = substantive_obj_misc_struct.anchor_tag;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
+ tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
+ object_number_poem["end"] = obj_cite_digits.object_number.to!string;
+ object_reset(an_object);
+ processing.remove("verse");
+ ++cntr;
+ }
+ pith["block_is"] = eN.blk_is.poem;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ processing["verse"] ~= line ~= "\n";
+ if (pith["verse_new"] == eN.bi.on) {
+ obj_cite_digits = ocn_emit(pith["ocn"]);
+ pith["verse_new"] = eN.bi.off;
+ } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) {
+ processing["verse"] = processing["verse"].stripRight;
+ pith["verse_new"] = eN.bi.on;
+ verse_line = eN.bi.off;
+ }
+ if (pith["verse_new"] == eN.bi.on) {
+ verse_line = 1;
+ an_object[an_object_key] = processing["verse"];
+ debug(poem) { writefln(
+ "* %s tic\n%s",
+ obj_cite_digits.object_number,
+ an_object[an_object_key]
+ );
+ }
+ processing.remove("verse");
+ an_object["is"] = "verse";
+ auto comp_obj_location
+ = node_construct.node_location_emitter(
+ content_non_header,
+ tag_in_seg,
+ lev_anchor_tag,
+ tag_assoc,
+ obj_cite_digits,
+ cntr,
+ heading_ptr-1,
+ an_object["is"]
+ );
+ ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
+ = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
+ an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
+ anchor_tag = substantive_obj_misc_struct.anchor_tag;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
+ tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
+ object_reset(an_object);
+ processing.remove("verse");
+ ++cntr;
+ }
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (auto m = line.matchFirst(rgx.block_tic_close)) {
+ an_object[an_object_key] = "verse";
+ 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.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ debug(codequotemarks) { writeln(line); }
+ an_object[an_object_key] = an_object[an_object_key]
+ .replaceFirst(rgx.newline_eol_delimiter_only, "")
+ .stripRight;
+ pith["block_is"] = eN.blk_is.code;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ debug(codequotemarks) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ debug(codetic) { writeln(line); }
+ 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.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ debug(table) { writeln(line); }
+ pith["block_is"] = eN.blk_is.table;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ debug(table) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ debug(table) { writeln(line); }
+ 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.quotemarks) {
+ if (line.matchFirst(rgx.block_quotemarks_close)) {
+ debug(quote) { writeln(line); }
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
+ pith["block_is"] = eN.blk_is.quote;
+ pith["block_state"] = eN.blk_state.closing;
+ pith["block_delim"] = eN.blk_delim.off;
+ } else {
+ debug(quote) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ }
+ } else if (pith["block_delim"] == eN.blk_delim.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ debug(quote) { writeln(line); }
+ 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
+ // ↓ - object digest
+ pure ubyte[32] obj_digest()(
+ ObjGenericComposite obj,
+ ) {
+ obj.metainfo.sha256 = obj.text.sha256Of;
+ return obj.metainfo.sha256;
+ }
+ // ↑ - object digest
+ // ↓ - 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
+ {
+ ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
+ {
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ 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)) {
+ {
+ ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
+ {
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ 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,
+ ) {
+ string[string][string] notes_;
+ if (the_document_body_section.length > 1) {
+ string _notes;
+ foreach (ref obj; the_document_body_section) {
+ if (obj.has.inline_notes_reg) {
+ if ((obj.text).matchFirst(rgx.inline_notes_al_gen)) {
+ foreach (m; (obj.text).matchAll(rgx.inline_notes_al_regular_number_note)) {
+ _notes ~= "\n\n" ~ m["num"] ~ ". " ~ m["note"];
+ notes_[(m["num"])]["ocn"] = obj.metainfo.ocn.to!string;
+ }
+ }
+ }
+ }
+ }
+ if (the_document_endnotes_section.length > 1) {
+ segnames["html"] ~= "endnotes";
+ segnames["epub"] ~= "endnotes";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_endnotes_section) {
+ auto matches = (obj.text).matchAll(rgx.endnote_section_note);
+ foreach (m; matches) {
+ obj.metainfo.parent_ocn = notes_[(m["notenumber"])]["ocn"].to!int;
+ }
+ }
+ foreach (ref obj; the_document_endnotes_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
+ 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"];
+ }
+ string[] text() {
+ return document_section_keys_sequenced["text"];
+ }
+ }
+ return doc_sect_keys_seq();
+ }
+}
diff --git a/src/sisudoc/ocda/meta/metadoc_object_setter.d b/src/sisudoc/ocda/meta/metadoc_object_setter.d
new file mode 100644
index 0000000..018c51b
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_object_setter.d
@@ -0,0 +1,429 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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/]
+
++/
+/++
+ object setter:
+ setting of sisu objects for downstream processing
+ metadoc_object_setter.d
++/
+module sisudoc.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;
+ int[] children_headings;
+ ubyte[32] sha256;
+ }
+ 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,
+ quotemarks,
+ }
+ }
+ return _e();
+ }
+}
diff --git a/src/sisudoc/ocda/meta/metadoc_show_config.d b/src/sisudoc/ocda/meta/metadoc_show_config.d
new file mode 100644
index 0000000..c4be08a
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_show_config.d
@@ -0,0 +1,230 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.metadoc_show_config;
+@safe:
+template spineShowSiteConfig() {
+ void spineShowSiteConfig(O,T)(
+ O opt_action,
+ T config,
+ ) {
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import std.array;
+ import std.digest.crc;
+ import std.digest.sha;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.uni;
+ import std.utf;
+ import std.conv : to;
+ mixin InternalMarkup;
+ auto markup = InlineMarkup();
+ auto char_repeat_number = 66;
+ 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 sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import std.array;
+ import std.digest.crc;
+ import std.digest.sha;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.uni;
+ import std.utf;
+ import std.conv : to;
+ mixin InternalMarkup;
+ auto markup = InlineMarkup();
+ auto min_repeat_number = 66;
+ 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/sisudoc/ocda/meta/metadoc_show_make.d b/src/sisudoc/ocda/meta/metadoc_show_make.d
new file mode 100644
index 0000000..4001e15
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_show_make.d
@@ -0,0 +1,121 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.metadoc_show_make;
+@safe:
+template spineShowMake() {
+ void spineShowMake(T)(T doc_matters) {
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import std.array;
+ import std.digest.crc;
+ import std.digest.sha;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.uni;
+ import std.utf;
+ import std.conv : to;
+ mixin InternalMarkup;
+ auto markup = InlineMarkup();
+ auto min_repeat_number = 66;
+ 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/sisudoc/ocda/meta/metadoc_show_metadata.d b/src/sisudoc/ocda/meta/metadoc_show_metadata.d
new file mode 100644
index 0000000..4159bc3
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_show_metadata.d
@@ -0,0 +1,169 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.metadoc_show_metadata;
+@safe:
+template spineShowMetaData() {
+ void spineShowMetaData(T)(T doc_matters) {
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import std.array;
+ import std.digest.crc;
+ import std.digest.sha;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.uni;
+ import std.utf;
+ import std.conv : to;
+ mixin InternalMarkup;
+ auto markup = InlineMarkup();
+ auto min_repeat_number = 66;
+ 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/sisudoc/ocda/meta/metadoc_show_summary.d b/src/sisudoc/ocda/meta/metadoc_show_summary.d
new file mode 100644
index 0000000..037b34a
--- /dev/null
+++ b/src/sisudoc/ocda/meta/metadoc_show_summary.d
@@ -0,0 +1,164 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta.metadoc_show_summary;
+@safe:
+template spineMetaDocSummary() {
+ void spineMetaDocSummary(D)(D doc) {
+ auto doc_matters = doc.matters;
+ import sisudoc.meta.defaults;
+ import sisudoc.meta.rgx;
+ import std.array;
+ import std.digest.crc;
+ import std.digest.sha;
+ import std.exception;
+ import std.regex;
+ import std.stdio;
+ import std.string;
+ import std.typecons;
+ import std.uni;
+ import std.utf;
+ import std.conv : to;
+ mixin InternalMarkup;
+ auto markup = InlineMarkup();
+ auto min_repeat_number = 66;
+ 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_gt_2
+ || 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%s - %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),
+ doc_matters.doc_digest.markup_doc.toHexString,
+ 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/sisudoc/ocda/meta/package.d b/src/sisudoc/ocda/meta/package.d
new file mode 100644
index 0000000..99de2f3
--- /dev/null
+++ b/src/sisudoc/ocda/meta/package.d
@@ -0,0 +1,62 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+module sisudoc.meta;
+public import sisudoc.meta.defaults;
+/+ std +/
+public import std.array;
+public import std.exception;
+public import std.range;
+public import std.regex;
+public import std.stdio;
+public import std.string;
+public import std.typecons;
+// public import std.uni;
+public import std.utf;
+public import std.conv : to;
diff --git a/src/sisudoc/ocda/meta/rgx.d b/src/sisudoc/ocda/meta/rgx.d
new file mode 100644
index 0000000..db485eb
--- /dev/null
+++ b/src/sisudoc/ocda/meta/rgx.d
@@ -0,0 +1,280 @@
+/+
+- Name: SisuDoc Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 (continuously updated, current 2026) 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 sisudoc.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