From 90873fabd7451e1dd8c4b39303906e19bdc481f7 Mon Sep 17 00:00:00 2001
From: Ralph Amissah
+ - read config files
+ meta_config_files.d
++/
+module sisudoc.io_in.paths_source;
+@safe:
+import
+ std.array,
+ std.file,
+ std.path,
+ std.regex,
+ std.stdio,
+ std.conv : to;
+import
+ sisudoc.meta.defaults,
+ sisudoc.meta.rgx_files;
+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_gt1 || _opt_action.debug_do) {
+ writeln("WARNING, src is not a pod, issue with manifest_path: ", _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,
+ std.path;
+import
+ sisudoc.meta,
+ sisudoc.io_in.paths_source,
+ sisudoc.meta.rgx_files,
+ 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_gt1 || _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,
+ std.path;
+ import
+ sisudoc.meta,
+ sisudoc.io_in.paths_source,
+ sisudoc.meta.rgx_files,
+ 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,
+ std.path;
+ import
+ sisudoc.meta,
+ sisudoc.io_in.paths_source,
+ sisudoc.meta.rgx_files,
+ 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,
+ std.path;
+ import
+ sisudoc.meta,
+ 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
new file mode 100644
index 0000000..4ba0b4f
--- /dev/null
+++ b/src/sisudoc/io_in/read_source_files.d
@@ -0,0 +1,396 @@
+/+
+- 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 - 2024 Ralph Amissah, All Rights Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.sisudoc.org]
+ [https://www.doc-reform.org]
+
+ - Git
+ [https://git.sisudoc.org/]
+
++/
+/++
+ module 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.file,
+ std.path;
+ import
+ sisudoc.meta,
+ sisudoc.io_in.paths_source,
+ sisudoc.meta.rgx_files,
+ 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();
+ alias ContentsInsertsImages = Tuple!(
+ char[][], "contents",
+ string[], "insert_files",
+ string[], "images"
+ );
+ alias HeaderContentInsertsImages = Tuple!(
+ char[], "header",
+ char[][], "src_txt",
+ string[], "insert_files",
+ string[], "images"
+ );
+ auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
+ auto _0_header_1_body_content_2_insert_filelist_tuple
+ = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
+ return _0_header_1_body_content_2_insert_filelist_tuple;
+ }
+ struct RawMarkupContent {
+ final sourceContent(in string fn_src) {
+ auto raw = MarkupRawUnit();
+ string source_txt_str
+ = raw.markupSourceReadIn(fn_src);
+ return source_txt_str;
+ }
+ final auto sourceContentSplitIntoHeaderAndBody(O)(
+ O _opt_action,
+ in string source_txt_str,
+ in string fn_src=""
+ ) {
+ auto raw = MarkupRawUnit();
+ string[] insert_file_list;
+ string[] images_list;
+ HeaderContentInsertsImages t
+ = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str);
+ char[] header_raw = t.header;
+ char[][] sourcefile_body_content = t.src_txt;
+ if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
+ auto ins = Inserts();
+ ContentsInsertsImages tu
+ = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
+ sourcefile_body_content = tu.contents;
+ insert_file_list = tu.insert_files.dup;
+ images_list = tu.images.dup;
+ } else if (_opt_action.source || _opt_action.pod) {
+ auto ins = Inserts();
+ ContentsInsertsImages tu
+ = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
+ images_list = tu.images.dup;
+ }
+ string header_type = "";
+ t = tuple(
+ header_raw,
+ sourcefile_body_content,
+ insert_file_list,
+ images_list
+ );
+ return t;
+ }
+ }
+ struct MarkupRawUnit {
+ 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;
+ }
+ HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(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);
+ HeaderContentInsertsImages t = tuple(
+ header,
+ source_line_arr,
+ file_insert_list,
+ images_list
+ );
+ return t;
+ }
+ 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 {
+ alias ContentsAndImages = Tuple!(
+ char[][], "insert_contents",
+ string[], "images"
+ );
+ ContentsAndImages 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, }
+ 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.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ code_block_status = codeBlock.off;
+ }
+ 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 || _opt_action.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 || _opt_action.pod) {
+ string[] _image_linelist = _extract_images(line);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
+ }
+ } // end src subdoc (inserts) loop
+ ContentsAndImages t = tuple(
+ contents_insert,
+ _images
+ );
+ return t;
+ }
+ ContentsInsertsImages 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, }
+ 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.tic) {
+ if (line.matchFirst(rgx.block_tic_close)) {
+ code_block_status = codeBlock.off;
+ }
+ 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();
+ ContentsAndImages contents_insert_tu = ins.scan_subdoc_source(
+ _opt_action,
+ markup_sourcefile_insert_content,
+ fn_src_insert.to!string
+ );
+ contents ~= contents_insert_tu.insert_contents;
+ if (_opt_action.source || _opt_action.pod) {
+ string[] _image_linelist = _extract_images(contents_insert_tu.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 || _opt_action.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);
+ }
+ ContentsInsertsImages t = tuple(
+ contents,
+ insert_file_list,
+ images
+ );
+ return t;
+ }
+ }
+}
diff --git a/src/sisudoc/io_out/cgi_sqlite_search_form.d b/src/sisudoc/io_out/cgi_sqlite_search_form.d
new file mode 100644
index 0000000..e835b07
--- /dev/null
+++ b/src/sisudoc/io_out/cgi_sqlite_search_form.d
@@ -0,0 +1,1959 @@
+/+
+- Name: Spine, Doc Reform [a part of]
+ - Description: documents, structuring, processing, publishing, search
+ - static content generator
+
+ - Author: Ralph Amissah
+ [ralph.amissah@gmail.com]
+
+ - Copyright: (C) 2015 - 2022 Ralph Amissah, All Rights
+ Reserved.
+
+ - License: AGPL 3 or later:
+
+ Spine (SiSU), a framework for document structuring, publishing and
+ search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU AFERO General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see [https://www.gnu.org/licenses/].
+
+ If you have Internet connection, the latest version of the AGPL should be
+ available at these locations:
+ [https://www.fsf.org/licensing/licenses/agpl.html]
+ [https://www.gnu.org/licenses/agpl.html]
+
+ - Spine (by Doc Reform, related to SiSU) uses standard:
+ - docReform markup syntax
+ - standard SiSU markup syntax with modified headers and minor modifications
+ - docReform object numbering
+ - standard SiSU object citation numbering & system
+
+ - Homepages:
+ [https://www.doc_reform.org]
+ [https://www.sisudoc.org]
+
+ - Git
+ [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary]
+
++/
+module doc_reform.io_out.cgi_sqlite_search_form;
+template CGIsearchSQLite() {
+ void CGIsearchSQLite(E,O,M)(E env, O opt_action, M make_and_meta_struct) {
+ import
+ std.file,
+ std.format;
+ import doc_reform.io_out;
+ string _sqlite_db_fn = (opt_action.sqliteDB_filename.empty)
+ ? make_and_meta_struct.conf.w_srv_db_sqlite_filename
+ : opt_action.sqliteDB_filename;
+ string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty)
+ ? make_and_meta_struct.conf.w_srv_cgi_search_script
+ : opt_action.cgi_sqlite_search_filename;
+ string _cgi_search_script_raw_fn_d = (opt_action.cgi_sqlite_search_filename_d.empty)
+ ? make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d
+ : opt_action.cgi_sqlite_search_filename_d;
+ string get_doc_collection_subroot(string output_path) {
+ string web_doc_root_path = environment.get("DOCUMENT_ROOT", "/var/www/html");
+ auto m = output_path.matchFirst(regex("^(" ~ web_doc_root_path ~ ")"));
+ return m.post;
+ }
+ string the_cgi_search_form = format(q"≓
+/+ dub.sdl
+ name "spine search"
+ description "spine cgi search"
++/
+import std.format;
+import std.range;
+import std.regex;
+import arsd.cgi;
+import d2sqlite3;
+import std.process : environment;
+void cgi_function_intro(Cgi cgi) {
+ string header;
+ string table;
+ string form;
+ struct Config {
+ string http_request_type;
+ string http_host;
+ // string server_name;
+ string web_doc_root_path;
+ string doc_collection_subroot;
+ string cgi_root;
+ string cgi_script;
+ string data_path_html;
+ string db_path;
+ string query_string;
+ string http_url;
+ string request_method;
+ }
+ auto conf = Config();
+ conf.http_request_type = environment.get("REQUEST_SCHEME", "http");
+ conf.http_host = environment.get("HTTP_HOST", "localhost");
+ // conf.server_name = environment.get("SERVER_NAME", "localhost");
+ conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", "/var/www/html");
+ conf.doc_collection_subroot = "%s"; // (output_path - web_doc_root_path)
+ conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", "/usr/lib/cgi-bin/");
+ // conf.cgi_script = environment.get("SCRIPT_NAME", "/cgi-bin/spine-search");
+ conf.query_string = environment.get("QUERY_STRING", "");
+ conf.http_url = environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string);
+ conf.db_path = "%s"; // (output_path + /sqlite)
+ conf.request_method = environment.get("REQUEST_METHOD", "POST");
+ struct CGI_val {
+ string db_selected = "";
+ string sql_match_limit = ""; // radio: ( 1000 | 2500 )
+ string sql_match_offset = "";
+ string search_text = "";
+ string results_type = ""; // index
+ bool checked_echo = false;
+ bool checked_stats = false;
+ bool checked_url = false;
+ bool checked_searched = false;
+ bool checked_tip = false;
+ bool checked_sql = false;
+ }
+ auto cv = CGI_val();
+ cv.db_selected = "%s";
+ auto text_fields() {
+ string canned_query_str = environment.get("QUERY_STRING", "");
+ if ("query_string" in cgi.post) {
+ canned_query_str = environment.get("QUERY_STRING", "");
+ }
+ string[string] canned_query;
+ if (conf.request_method == "POST") {
+ } else if (conf.request_method == "GET") {
+ foreach (pair_str; canned_query_str.split("&")) {
+ // cgi.write(pair_str ~ "
");
+ string[] pair = pair_str.split("=");
+ canned_query[pair[0]] = pair[1];
+ }
+ // foreach (field, content; canned_query) {
+ // cgi.write(field ~ ": " ~ content ~ "
");
+ // }
+ }
+ static struct Rgx {
+ // static canned_query = ctRegex!(`\A(?P
");
+ } else if (environment.get("REQUEST_METHOD", "POST") == "GET") {
+ got.canned_query = environment.get("QUERY_STRING", "");
+ // cgi.write("f.canned_query: " ~ got.canned_query ~ "
");
+ got.search_text_area = "";
+ if ("sf" in canned_query && !(canned_query["sf"]).empty) {
+ got.text = canned_query["sf"].split("%%20").join(" ");
+ got.search_text_area ~= "text: " ~ got.text ~ "\n";
+ }
+ if ("au" in canned_query && !(canned_query["au"]).empty) {
+ got.author = canned_query["au"].split("%%20").join(" ");
+ got.search_text_area ~= "author: " ~ got.author ~ "\n";
+ }
+ if ("ti" in canned_query && !(canned_query["ti"]).empty) {
+ got.title = canned_query["ti"].split("%%20").join(" ");
+ got.search_text_area ~= "title: " ~ got.title ~ "\n";
+ }
+ if ("uid" in canned_query && !(canned_query["uid"]).empty) {
+ got.uid = canned_query["uid"].split("%%20").join(" ");
+ got.search_text_area ~= "uid: " ~ got.uid ~ "\n";
+ }
+ if ("fn" in canned_query && !(canned_query["fn"]).empty) {
+ got.fn = canned_query["fn"].split("%%20").join(" ");
+ got.search_text_area ~= "fn: " ~ got.fn ~ "\n";
+ }
+ if ("kw" in canned_query && !(canned_query["kw"]).empty) {
+ got.keywords = canned_query["kw"].split("%%20").join(" ");
+ got.search_text_area ~= "keywords: " ~ got.keywords ~ "\n";
+ }
+ if ("tr" in canned_query && !(canned_query["tr"]).empty) {
+ got.topic_register = canned_query["tr"].split("%%20").join(" ");
+ got.search_text_area ~= "topic_register: " ~ got.topic_register ~ "\n";
+ }
+ if ("su" in canned_query && !(canned_query["su"]).empty) {
+ got.subject = canned_query["su"].split("%%20").join(" ");
+ got.search_text_area ~= "subject: " ~ got.subject ~ "\n";
+ }
+ if ("de" in canned_query && !(canned_query["de"]).empty) {
+ got.description = canned_query["de"].split("%%20").join(" ");
+ got.search_text_area ~= "description: " ~ got.description ~ "\n";
+ }
+ if ("pb" in canned_query && !(canned_query["pb"]).empty) {
+ got.publisher = canned_query["pb"].split("%%20").join(" ");
+ got.search_text_area ~= "publisher: " ~ got.publisher ~ "\n";
+ }
+ if ("ed" in canned_query && !(canned_query["ed"]).empty) {
+ got.editor = canned_query["ed"].split("%%20").join(" ");
+ got.search_text_area ~= "editor: " ~ got.editor ~ "\n";
+ }
+ if ("ct" in canned_query && !(canned_query["ct"]).empty) {
+ got.contributor = canned_query["ct"].split("%%20").join(" ");
+ got.search_text_area ~= "contributor: " ~ got.contributor ~ "\n";
+ }
+ if ("dt" in canned_query && !(canned_query["dt"]).empty) {
+ got.date = canned_query["dt"].split("%%20").join(" ");
+ got.search_text_area ~= "date: " ~ got.date ~ "\n";
+ }
+ if ("rt" in canned_query && !(canned_query["rt"]).empty) {
+ got.results_type = canned_query["rt"].split("%%20").join(" ");
+ // got.search_text_area ~= "results_type: " ~ got.results_type ~ "\n";
+ }
+ if ("fmt" in canned_query && !(canned_query["fmt"]).empty) {
+ got.format = canned_query["fmt"].split("%%20").join(" ");
+ got.search_text_area ~= "format: " ~ got.format ~ "\n";
+ }
+ if ("src" in canned_query && !(canned_query["src"]).empty) {
+ got.source = canned_query["src"].split("%%20").join(" ");
+ got.search_text_area ~= "source: " ~ got.source ~ "\n";
+ }
+ if ("lng" in canned_query && !(canned_query["lng"]).empty) {
+ got.language = canned_query["lng"].split("%%20").join(" ");
+ got.search_text_area ~= "language: " ~ got.language ~ "\n";
+ }
+ if ("rl" in canned_query && !(canned_query["rl"]).empty) {
+ got.relation = canned_query["rl"].split("%%20").join(" ");
+ got.search_text_area ~= "relation: " ~ got.relation ~ "\n";
+ }
+ if ("cv" in canned_query && !(canned_query["cv"]).empty) {
+ got.coverage = canned_query["cv"].split("%%20").join(" ");
+ got.search_text_area ~= "coverage: " ~ got.coverage ~ "\n";
+ }
+ if ("rgt" in canned_query && !(canned_query["rgt"]).empty) {
+ got.rights = canned_query["rgt"].split("%%20").join(" ");
+ got.search_text_area ~= "rights: " ~ got.rights ~ "\n";
+ }
+ if ("cmt" in canned_query && !(canned_query["cmt"]).empty) {
+ got.comment = canned_query["cmt"].split("%%20").join(" ");
+ got.search_text_area ~= "comment: " ~ got.comment ~ "\n";
+ }
+ // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) {
+ // got.abstract = canned_query["abstract"];
+ // }
+ if ("bfn" in canned_query && !(canned_query["bfn"]).empty) { // search_field
+ got.src_filename_base = canned_query["bfn"].split("%%20").join(" ");
+ got.search_text_area ~= "src_filename_base: " ~ got.src_filename_base ~ "\n";
+ }
+ if ("sml" in canned_query && !(canned_query["sml"]).empty) {
+ got.sql_match_limit = canned_query["sml"].split("%%20").join(" ");
+ // got.search_text_area ~= "sql_match_limit: " ~ got.sql_match_limit ~ "\n";
+ }
+ // cgi.write("f.search_text_area: " ~ got.search_text_area ~ "
");
+ }
+ return got;
+ }
+ auto tf = text_fields; //
+ struct SQL_select {
+ string the_body = "";
+ string the_range = "";
+ }
+ auto sql_select = SQL_select();
+ string canned_url () {
+ string _url = "";
+ if (environment.get("REQUEST_METHOD", "POST") == "POST") {
+ _url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query;
+ } else if (environment.get("REQUEST_METHOD", "POST") == "GET") {
+ _url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", "");
+ }
+ return _url;
+ }
+ auto regex_canned_search () {
+ static struct RgxCS {
+ static track_offset = ctRegex!(`(?P
" ~ arrow_previous ~ arrow_next;
+ return _previous_next;
+ }
+ {
+ header = format(q"┃
+
+
+
+
+
+
+┃");
+ }
+ {
+ string post_value(string field_name, string type="box", string set="on") {
+ string val = "";
+ switch (type) {
+ case "field":
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? cgi.post[field_name]
+ : (field_name in cgi.get)
+ ? cgi.get[field_name]
+ : "");
+ val = tf.search_text_area;
+ break;
+ case "box": // generic for checkbox or radio; checkbox set == "on" radio set == "name set"
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "off");
+ break;
+ case "radio": // used generic bo
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "checked");
+ break;
+ case "checkbox": // used generic bo
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "checked");
+ break;
+ default:
+ }
+ return val;
+ }
+ string the_can(string fv) {
+ string show_the_can = post_value("url");
+ string _the_can = "";
+ if (show_the_can == "checked") {
+ tf = text_fields;
+ string method_get_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", "");
+ string method_post_url_construct = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query;
+ // assert(method_get_url == environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string));
+ if (conf.request_method == "POST") {
+ _the_can =
+ ""
+ ~ "POST: "
+ ~ ""
+ ~ method_post_url_construct
+ ~ ""
+ ~ "
+
+
+
+
+
+
+ %s
+
+
";
+ } else if (conf.request_method == "GET") {
+ _the_can =
+ ""
+ ~ "GET: "
+ ~ ""
+ ~ method_get_url
+ ~ "";
+ }
+ conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
+ }
+ return _the_can;
+ }
+ string provide_tip() {
+ string searched_tip = post_value("se");
+ string tip = "";
+ if (searched_tip == "checked") {
+ string search_field = post_value("sf", "field");
+ tf = text_fields;
+ tip = format(q"┃
+
+database: %%s; selected view: index
+search string: %%s %%s %%s %%s %%s %%s
+%%s %%s %%s %%s %%s %%s
+
+┃",
+ cv.db_selected,
+ (tf.text.empty ? "" : "\"text: " ~ tf.text ~ "; "),
+ (tf.title.empty ? "" : "\"title: " ~ tf.title ~ "; "),
+ (tf.author.empty ? "" : "\"author: " ~ tf.author ~ "; "),
+ (tf.date.empty ? "" : "\"date " ~ tf.date ~ "; "),
+ (tf.uid.empty ? "" : "\"uid: " ~ tf.uid ~ "; "),
+ (tf.fn.empty ? "" : "\"fn: " ~ tf.fn ~ "; "),
+ (tf.text.empty ? "" : "text: " ~ tf.text ~ "
"),
+ (tf.title.empty ? "" : "title: " ~ tf.title ~ "
"),
+ (tf.author.empty ? "" : "author: " ~ tf.author ~ "
"),
+ (tf.date.empty ? "" : "date: " ~ tf.date ~ "
"),
+ (tf.uid.empty ? "" : "\"uid: " ~ tf.uid ~ "; "),
+ (tf.fn.empty ? "" : "\"fn: " ~ tf.fn ~ "; "),
+ );
+ }
+ return tip;
+ }
+ form = format(q"┃
+
+┃",
+ "%s",
+ (post_value("ec") == "checked") ? post_value("sf", "field") : "",
+ provide_tip,
+ search_note,
+ the_can(post_value("sf", "field")),
+ cv.db_selected,
+ post_value("rt", "box", "idx"),
+ post_value("rt", "box", "txt"),
+ post_value("sml", "box", "1000"),
+ post_value("sml", "box", "2500"),
+ post_value("ec"),
+ post_value("url"),
+ post_value("se"),
+ post_value("sql"),
+ );
+ {
+ string set_value(string field_name, string default_val) {
+ string val;
+ if (field_name in cgi.post) {
+ val = cgi.post[field_name];
+ } else if (field_name in cgi.get) {
+ val = cgi.get[field_name];
+ } else { val = default_val; }
+ return val;
+ }
+ bool set_bool(string field_name) {
+ bool val;
+ if (field_name in cgi.post
+ && cgi.post[field_name] == "on") {
+ val = true;
+ } else if (field_name in cgi.get
+ && cgi.get[field_name] == "on") {
+ val = true;
+ } else { val = false; }
+ return val;
+ }
+ cv.db_selected = set_value("selected_db", "%s"); // selected_db_name == db (spine.search.db or whatever)
+ cv.sql_match_limit = set_value("sml", "1000");
+ cv.sql_match_offset = set_value("smo", "0");
+ cv.search_text = set_value("sf", "");
+ cv.results_type = set_value("rt", "idx");
+ cv.checked_echo = set_bool("ec");
+ cv.checked_stats = set_bool("sts");
+ cv.checked_url = set_bool("url");
+ cv.checked_searched = set_bool("se");
+ cv.checked_tip = set_bool("tip");
+ cv.checked_sql = set_bool("sql");
+ tf = text_fields;
+ }
+ }
+ {
+ cgi.write(header);
+ cgi.write(table);
+ cgi.write(form);
+ // cgi.write(previous_next);
+ { // debug environment
+ // foreach (k, d; environment.toAA) {
+ // cgi.write(k ~ ": " ~ d ~ "
");
+ // }
+ }
+ { // debug cgi info
+ // cgi.write("db_selected: " ~ cv.db_selected ~ "
\n");
+ // cgi.write("search_text: " ~ cv.search_text ~ "
\n");
+ // cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n");
+ // cgi.write("sql_match_offset: " ~ cv.sql_match_offset ~ ";\n");
+ // cgi.write("results_type: " ~ cv.results_type ~ "
\n");
+ // cgi.write("cv.checked_echo: " ~ (cv.checked_echo ? "checked" : "off") ~ "; \n");
+ // cgi.write("cv.checked_stats: " ~ (cv.checked_stats ? "checked" : "off") ~ "; \n");
+ // cgi.write("cv.checked_url: " ~ (cv.checked_url ? "checked" : "off") ~ "; \n");
+ // cgi.write("cv.checked_searched: " ~ (cv.checked_searched ? "checked" : "off") ~ ";
\n");
+ // cgi.write("cv.checked_tip: " ~ (cv.checked_tip ? "checked" : "off") ~ "; \n");
+ // cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "
\n");
+ }
+ }
+ auto db = Database(conf.db_path ~ cv.db_selected);
+ {
+ uint sql_match_offset_counter(T)(T cv) {
+ sql_match_offset_count += cv.sql_match_limit.to!uint;
+ return sql_match_offset_count;
+ }
+ void sql_search_query() {
+ string highlight_text_matched(string _txt, string search_field) {
+ string _mark_open = "┤";
+ string _mark_close = "├";
+ string _span_match = "";
+ string _span_close = "";
+ string _sf_str = search_field.strip.split("%%20").join(" ").strip;
+ string[] _sf_arr = _sf_str.split(regex(r"\s+AND\s+|\s+OR\s+"));
+ auto rgx_url = regex(r"]+?>");
+ foreach (_sf; _sf_arr) {
+ auto rgx_matched_text = regex(_sf, "i");
+ auto rgx_marked_pair = regex(r"┤(?P
"
+ ~ sql_select.the_body.strip.split("\n ").join(" ").split("\n").join("
")
+ ~ "\n"
+ )
+ : "";
+ cgi.write(previous_next);
+ auto select_query_results = db.execute(sql_select.the_body).cached;
+ string _old_uid = "";
+ if (!select_query_results.empty) {
+ string _date_published = "0000";
+ string _close_para = "";
+ string _matched_ocn_open = "";
+ foreach (idx, row; select_query_results) {
+ if (row["uid"].as!string != _old_uid) {
+ _close_para = (idx == 1) ? "" : "
"; + _old_uid = row["uid"].as!string; + _date_published = (row["date_published"].as!string.match(regex(r"^([0-9]{4})"))) + ? row["date_published"].as!string : "0000"; // used in regex that breaks if no match + auto m = _date_published.match(regex(r"^([0-9]{4})")); + string _date = (m.hit == "0000") ? "(year?) " : "(" ~ m.hit ~ ") "; + cgi.write( + _close_para + ~ "
\"" + ~ row["title"].as!string ~ "\"" + ~ " " + ~ _date + ~ "[" ~ row["language_document_char"].as!string ~ "] " + ~ row["creator_author_last_first"].as!string + ~ " " + ~ show_matched_objects(row["src_filename_base"].as!string) + ~ "
" + ~ "\n");
+ }
+ cgi.write("
Title: " ~ doc_matters.conf_make_meta.meta.title_full ~ "
"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + writeln("ERROR no Title information provided in document header ", doc_matters.src.filename_base); + } + if (!(doc_matters.conf_make_meta.meta.creator_author.empty)) { + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= "Author: " + ~ doc_matters.conf_make_meta.meta.creator_author ~ "
"; + } else { + metadata_ ~= "Author: " + ~ doc_matters.conf_make_meta.meta.creator_author ~ "
"; + } + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + writeln("ERROR no Author information provided in document header ", doc_matters.src.filename_base); + } + metadata_ ~= "Published: " ~ doc_matters.conf_make_meta.meta.date_published ~ "
"; + if (!(doc_matters.conf_make_meta.meta.rights_copyright.empty)) { + metadata_ ~= "Copyright: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright) ~ "
"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + writeln("WARNING no Copyright information provided in document header ", doc_matters.src.filename_base); + } + if (!(doc_matters.conf_make_meta.meta.rights_license.empty)) { + metadata_ ~= "License: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_license) ~ "
"; + } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { + writeln("WARNING no License information provided in document header ", doc_matters.src.filename_base); + } + if (!(doc_matters.conf_make_meta.meta.notes_summary.empty)) { + metadata_ ~= "Summary:
" ~ special_characters_text(doc_matters.conf_make_meta.meta.notes_summary) ~ "
"; + } else if (doc_matters.opt.action.debug_do) { + writeln("WARNING no summary of text provided in document header ", doc_matters.src.filename_base); + } + metadata_ ~= "source: " ~ doc_matters.src.filename_base ~ "
"; + if (doc_matters.opt.action.html_link_markup_source) { + metadata_ ~= "● markup source: the pod [" + ~ " 🫛 zipped | " + ~ "" + ~ " 🫛 tree ] "; + } + metadata_ ~= "
● 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) ] "; + } + metadata_ ~= "
"; + if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { + metadata_ ~= "Topics:
"; + string[] _top = ["", "", "", "", ""]; + foreach (topic; doc_matters.conf_make_meta.meta.classify_topic_register_arr.sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable)) { + string[] subject_tree = topic.split(mkup.sep); + if (subject_tree.length > 0) { + if (subject_tree[0] != _top[0]) { + _top[0] = subject_tree[0]; + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= + ""; + } else { + metadata_ ~= + "" ~ subject_tree[0] ~ "
"; + } + } + if (subject_tree.length > 1) { + if (subject_tree[1] != _top[1]) { + _top[1] = subject_tree[1]; + _top[2] = ""; _top[3] = ""; _top[4] = ""; + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= + ""; + } else { + metadata_ ~= + "" ~ subject_tree[1] ~ "
"; + } + } + if (subject_tree.length > 2) { + if (subject_tree[2] != _top[2]) { + _top[2] = subject_tree[2]; + _top[3] = ""; _top[4] = ""; + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= + ""; + } else { + metadata_ ~= + "" ~ subject_tree[2] ~ "
"; + } + } + if (subject_tree.length > 3) { + if (subject_tree[3] != _top[3]) { + _top[3] = subject_tree[3]; + _top[4] = ""; + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= + ""; + } else { + metadata_ ~= + "" ~ subject_tree[3] ~ "
"; + } + } + if (subject_tree.length > 4) { + if (subject_tree[4] != _top[4]) { + _top[4] = subject_tree[4]; + if (doc_matters.opt.action.html_link_curate) { + metadata_ ~= + ""; + } else { + metadata_ ~= + "" ~ subject_tree[4] ~ "
"; + } + } + } + } + } + } + } + } + } else if (doc_matters.opt.action.debug_do) { + writeln("WARNING no topic_register classification of text provided in document header ", doc_matters.src.filename_base); + } + metadata_write_output(doc_matters, metadata_); + } +} diff --git a/src/sisudoc/io_out/odt.d b/src/sisudoc/io_out/odt.d new file mode 100644 index 0000000..d6ac27d --- /dev/null +++ b/src/sisudoc/io_out/odt.d @@ -0,0 +1,2162 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.odt; +@safe: +template formatODT() { + import + sisudoc.io_out, + sisudoc.io_out.rgx, + sisudoc.io_out.rgx_xhtml; + import + std.digest.sha, + std.file, + std.outbuffer, + std.uri, + std.zip, + std.conv : to; + import + sisudoc.io_out.create_zip_file, + sisudoc.io_out.xmls, + sisudoc.io_out.xmls_css; + mixin spineRgxOut; + mixin spineRgxXHTML; + struct formatODT { + static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); + string _tags(O)(const O obj) { + string _tags = ""; + if (obj.tags.anchor_tags.length > 0) { + foreach (tag_; obj.tags.anchor_tags) { + if (tag_.length > 0) { + _tags ~= format(q"┃┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P \d+)h(?P \d+))\s*(?P .*?┝┤.*?├)`, "mg"); + static inline_image_without_dimensions = ctRegex!(`(?P ┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P 0)h(?P 0))\s*(?P .*?┝┤.*?├)`, "mg"); + static inline_image_info = ctRegex!(`☼?(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P \d+)h(?P \d+)`, "mg"); + static inline_link_anchor = ctRegex!(`┃(?P \S+?)┃`, "mg"); // TODO *~text_link_anchor + static inline_link = ctRegex!(`┥(?P .+?)┝┤(?P#?(\S+?))├`, "mg"); + static inline_link_empty = ctRegex!(`┥(?P .+?)┝┤├`, "mg"); + static inline_link_number = ctRegex!(`┥(?P .+?)┝┤(?P [0-9]+)├`, "mg"); // not used + static inline_link_number_only = ctRegex!(`(?P ┥.+?┝)┤(?P [0-9]+)├`, "mg"); + static inline_link_stow_uri = ctRegex!(`┥(?P .+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links + static inline_link_hash = ctRegex!(`┥(?P .+?)┝┤(?P#(?P \S+?))├`, "mg"); + static inline_link_seg_and_hash = ctRegex!(`┥(?P .+?)┝┤(?P(?P [^/#├]*)#(?P .+?))├`, "mg"); + static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); + static inline_link_toc_to_backmatter = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static url = ctRegex!(`https?://`, "mg"); + static uri = ctRegex!(`(?:https?|git)://`, "mg"); + static uri_identify_components = ctRegex!(`(?P (?:https?|git)://)(?P \S+?/)(?P [^/]+)$`, "mg"); + static inline_link_subtoc = ctRegex!(`^(?P [5-7])~ ┥(?P .+?)┝┤(?P.+?)├`, "mg"); + static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); + static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); + static mark_internal_site_lnk = ctRegex!(`¤`, "mg"); + static quotation_mark_sql_insert_delimiter = ctRegex!("[']", "mg"); + /+ inline markup font face mod +/ + static inline_emphasis = ctRegex!(`⑆[*]┨(?P .+?)┣[*]`, "mg"); + static inline_bold = ctRegex!(`⑆[!]┨(?P .+?)┣[!]`, "mg"); + static inline_underscore = ctRegex!(`⑆[_]┨(?P .+?)┣[_]`, "mg"); + static inline_italics = ctRegex!(`⑆[/]┨(?P .+?)┣[/]`, "mg"); + static inline_superscript = ctRegex!(`⑆\^┨(?P .+?)┣\^`, "mg"); + static inline_subscript = ctRegex!(`⑆[,]┨(?P .+?)┣[,]`, "mg"); + static inline_strike = ctRegex!(`⑆[-]┨(?P .+?)┣[-]`, "mg"); + static inline_insert = ctRegex!(`⑆[+]┨(?P .+?)┣[+]`, "mg"); + static inline_mono = ctRegex!(`⑆[■]┨(?P .+?)┣[■]`, "mg"); + static inline_cite = ctRegex!(`⑆[‖]┨(?P .+?)┣[‖]`, "mg"); + /+ table delimiters +/ + static table_delimiter_col = ctRegex!("[ ]*[┊][ ]*", "mg"); + static table_delimiter_row = ctRegex!("[ ]*\n", "mg"); + /+ paragraph operators +/ + static grouped_para_indent_1 = ctRegex!(`^_1[ ]`, "m"); + static grouped_para_indent_2 = ctRegex!(`^_2[ ]`, "m"); + static grouped_para_indent_3 = ctRegex!(`^_3[ ]`, "m"); + static grouped_para_indent_4 = ctRegex!(`^_4[ ]`, "m"); + static grouped_para_indent_5 = ctRegex!(`^_5[ ]`, "m"); + static grouped_para_indent_6 = ctRegex!(`^_6[ ]`, "m"); + static grouped_para_indent_7 = ctRegex!(`^_7[ ]`, "m"); + static grouped_para_indent_8 = ctRegex!(`^_8[ ]`, "m"); + static grouped_para_indent_9 = ctRegex!(`^_9[ ]`, "m"); + static grouped_para_bullet = ctRegex!(`^_[*] `, "m"); + static grouped_para_bullet_indent_1 = ctRegex!(`^_1[*] `, "m"); + static grouped_para_bullet_indent_2 = ctRegex!(`^_2[*] `, "m"); + static grouped_para_bullet_indent_3 = ctRegex!(`^_3[*] `, "m"); + static grouped_para_bullet_indent_4 = ctRegex!(`^_4[*] `, "m"); + static grouped_para_bullet_indent_5 = ctRegex!(`^_5[*] `, "m"); + static grouped_para_bullet_indent_6 = ctRegex!(`^_6[*] `, "m"); + static grouped_para_bullet_indent_7 = ctRegex!(`^_7[*] `, "m"); + static grouped_para_bullet_indent_8 = ctRegex!(`^_8[*] `, "m"); + static grouped_para_bullet_indent_9 = ctRegex!(`^_9[*] `, "m"); + static grouped_para_bullet_indent = ctRegex!(`^_(?P [1-9])[*] `, "m"); + static grouped_para_indent_hang = ctRegex!(`^_(?P [0-9])_(?P [0-9])[ ]`, "m"); + } +} diff --git a/src/sisudoc/io_out/rgx_latex.d b/src/sisudoc/io_out/rgx_latex.d new file mode 100644 index 0000000..826455c --- /dev/null +++ b/src/sisudoc/io_out/rgx_latex.d @@ -0,0 +1,68 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + regex: regular expressions used in sisu document parser ++/ +module sisudoc.io_out.rgx_latex; +@safe: +static template spineRgxLSC() { + static struct RgxLSC { + static latex_special_char = ctRegex!(`([%${}_#&\\])`); + static latex_special_char_for_escape = ctRegex!(`([%${}_#\\])`); + static latex_special_char_for_escape_and_braces = ctRegex!(`([&])`); + static latex_special_char_for_escape_url = ctRegex!(`([%])`); + static latex_special_char_escaped = ctRegex!(`\\([%${}_#\\])`); + static latex_special_char_escaped_braced = ctRegex!(`[{]\\([&])[}]`); + static latex_identify_inline_link = ctRegex!(`┥.+?┝┤\S+?├`, "mg"); + static latex_identify_inline_fontface = ctRegex!(`\\([_#$]┨.+?┣)\\([_#$])`, "mg"); + static latex_clean_internal_link = ctRegex!(`^(?:#|¤\S+?#)`, "m"); + static latex_clean_bookindex_linebreak = ctRegex!(`\s*\\\\\\\\\s*`, "m"); + } +} diff --git a/src/sisudoc/io_out/rgx_xhtml.d b/src/sisudoc/io_out/rgx_xhtml.d new file mode 100644 index 0000000..1c33b0e --- /dev/null +++ b/src/sisudoc/io_out/rgx_xhtml.d @@ -0,0 +1,63 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + regex: regular expressions used in sisu document parser ++/ +module sisudoc.io_out.rgx_xhtml; +@safe: +static template spineRgxXHTML() { + static struct RgxXHTML { + static ampersand = ctRegex!(`[&]`, "m"); // & + static quotation = ctRegex!(`["]`, "m"); // " + static less_than = ctRegex!(`[<]`, "m"); // < + static greater_than = ctRegex!(`[>]`, "m"); // > + static line_break = ctRegex!(` [\\]{2}`, "m"); //
+ } +} diff --git a/src/sisudoc/io_out/source_pod.d b/src/sisudoc/io_out/source_pod.d new file mode 100644 index 0000000..97e31af --- /dev/null +++ b/src/sisudoc/io_out/source_pod.d @@ -0,0 +1,424 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.source_pod; +@system: // is not @safe: use: @system: or @trusted: +template spinePod() { + import + sisudoc.meta.rgx_files, + sisudoc.io_out; + import + std.digest.sha, + std.file, + std.outbuffer, + std.zip, + std.conv : to; + import + sisudoc.io_out.create_zip_file, + sisudoc.io_out.xmls; + void spinePod(T)(T doc_matters) { + debug(asserts) { + // static assert(is(typeof(doc_matters) == tuple)); + } + mixin spineRgxFiles; + string pwd = doc_matters.env.pwd; + auto src_path_info = doc_matters.src_path_info; + auto pth_dr_doc_src = doc_matters.src_path_info; + 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)); + @system auto pod_archive(Z)( + string _source_type, + string _data_in, + string _pth_out, + Z zip + ) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = _pth_out; + auto zip_data = new OutBuffer(); + switch (_source_type) { + case "file_path_bin": + zip_data.write(cast(char[]) ((_data_in).read)); + goto default; + case "file_path_text": + zip_data.write((_data_in).readText); + goto default; + case "string": + zip_data.write(_data_in); + goto default; + default: + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + } + return zip; + } + try { + /+ 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_gt0) { + 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 (!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", + )); + } + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + writeln(__LINE__, ": ", + doc_matters.src.filename, " -> ", + pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod + ); + } + auto zip = new ZipArchive(); + auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod; + { /+ bundle images +/ + foreach (image; doc_matters.srcs.image_list) { + debug(podimages) { + 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); + } + if (doc_matters.opt.action.source_or_pod) { + fn_src_in.copy(fn_src_out_filesystem); + } + if (doc_matters.opt.action.pod) { + zip = pod_archive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (image): ", 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.pod) { + zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + 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_gt1) { + 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.pod) { + zip = pod_archive("string", _pm, fn_src_out_pod_zip_base, zip); + } + } + } + } { /+ bundle primary file (.ssm/.sst) +/ + 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 (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; + string _pod_to_markup_file = doc_matters.src.pod_name ~ "/" ~ "media/text/" ~ doc_matters.src.language ~ "/" ~ doc_matters.src.filename; + if (doc_matters.opt.action.source_or_pod) { + fn_src_in.copy(fn_src_out_filesystem); + } + if (doc_matters.opt.action.pod) { + auto _rgx = regex(r"(?P\S+?)(?P [a-z_-]+)/(?P media/text/)(?P \S+?)/(?P \S+?\.ss[mt])"); + if (auto _x = fn_src_in.match(_rgx)){ + if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) { + string _path_to_pod = _x.captures["path_to_pod"]; + string _podname = _x.captures["podname"]; + string _root_to_lang = _x.captures["from_root"]; + string _language = _x.captures["language"]; + string _filename = _x.captures["filename"]; + foreach (_lang; doc_matters.pod.manifest_list_of_languages) { + string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename; + string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename; + zip = pod_archive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip); + } + } + } else { + zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); + } + } + } else { + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src in NOT found (markup source): ", fn_src_in); + } + } + } { /+ bundle insert files (.ssi) +/ + if (doc_matters.srcs.file_insert_list.length > 0) { + auto _rgx = regex(r"(?P \S+?)(?P [a-z_-]+)/(?P media/text/)(?P \S+?)/(?P \S+?\.ss[i])"); + foreach (insert_file; doc_matters.srcs.file_insert_list) { + debug(pod) { + writeln( + insert_file, " -> ", + pths_pod.fn_doc_insert( + doc_matters.src.filename, + insert_file, + doc_matters.src.language, + ).zpod + ); + } + if (auto _x = insert_file.match(_rgx)){ + if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) { + string _path_to_pod = _x.captures["path_to_pod"]; + string _podname = _x.captures["podname"]; + string _root_to_lang = _x.captures["from_root"]; + string _language = _x.captures["language"]; + string _filename = _x.captures["filename"]; + foreach (_lang; doc_matters.pod.manifest_list_of_languages) { + string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename; + string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename; + if (exists(_pth_mkup_src_in)) { + if (doc_matters.opt.action.source_or_pod) { + auto fn_src_out_filesystem // you need to change language sources + = pths_pod.fn_doc_insert( + doc_matters.src.filename, // doc_matters.src.filename + _pth_mkup_src_in, // insert_file + _lang, + ).filesystem_open_zpod.to!string; + _pth_mkup_src_in.copy(fn_src_out_filesystem); // check why here, thought dealt with elsewhere + } + if (doc_matters.opt.action.pod) { + zip = pod_archive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (insert file): ", _pth_mkup_src_in); + } + } + } + } + } else { + auto fn_src_in = insert_file; + auto fn_src_out_pod_zip_base + = pths_pod.fn_doc_insert( + doc_matters.src.filename, + insert_file, + doc_matters.src.language, + ).zpod.to!string; + auto fn_src_out_filesystem + = pths_pod.fn_doc_insert( + doc_matters.src.filename, + insert_file, + doc_matters.src.language, + ).filesystem_open_zpod.to!string; + 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.pod) { + zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod + && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); + } + } + } + } + } + } { + auto fn_src_in = doc_matters.src.filename; + if (doc_matters.opt.action.pod) { + if (exists(doc_matters.src.file_with_absolute_path)) { + createZipFile!()(fn_pod, zip.build()); + } else { + writeln("WARNING check missing source file(s): ", doc_matters.opt.action.pod); + } + if (!(exists(fn_pod))) { + writeln("WARNING failed to create pod zip archive: ", fn_pod); + } + } + } + if (exists(fn_pod)) { + try { + if (doc_matters.opt.action.vox_gt0 + && doc_matters.opt.action.pod) { + auto data = (cast(byte[]) (fn_pod).read); + if (doc_matters.opt.action.vox_gt1) { + writeln(" ", doc_matters.src.filename, " > "); + } + if (doc_matters.opt.action.pod) { + writefln("%s\n. %-(%02x%)::%s . %s.zip", fn_pod, data.sha256Of, data.length, doc_matters.src.filename_base); + } + } + if (doc_matters.opt.action.debug_do_pod) { + try { + auto zipped = new ZipArchive((fn_pod).read); + foreach (filename, member; zipped.directory) { + auto data = zipped.expand(member); + writeln(". ", ((data).sha256Of).toHexString, "::", data.length, " . ", filename); + } + } catch (ZipException ex) { + // Handle errors + } + } + } catch (ErrnoException ex) { + // Handle errors + } + } + // source pod zip + } catch (ErrnoException ex) { + // Handle error + } + } +} diff --git a/src/sisudoc/io_out/sqlite.d b/src/sisudoc/io_out/sqlite.d new file mode 100644 index 0000000..bee9cad --- /dev/null +++ b/src/sisudoc/io_out/sqlite.d @@ -0,0 +1,1761 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.sqlite; +import + sisudoc.io_out, + sisudoc.io_out.rgx, + sisudoc.io_out.rgx_xhtml; +import + std.file, + std.uri; +import std.conv : to; +import std.typecons : Nullable; +import d2sqlite3; +mixin spineRgxOut; +mixin spineRgxXHTML; +mixin InternalMarkup; +static auto rgx = RgxO(); +static auto rgx_xhtml = RgxXHTML(); +static auto mkup = InlineMarkup(); +long _metadata_tid_lastrowid; +template SQLiteHubBuildTablesAndPopulate() { + void SQLiteHubBuildTablesAndPopulate(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path); + if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { + } else { + try { + pth_sqlite.base.mkdirRecurse; + } catch (FileException ex) { } + } + template SQLiteDbStatementComposite() { + void SQLiteDbStatementComposite(Db,D,M)( + Db db, + const D doc_abstraction, + M doc_matters, + ) { + string _db_statement; + if ((doc_matters.opt.action.sqlite_db_create)) { + auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path); + if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { + } else { + try { + pth_sqlite.base.mkdirRecurse; + } catch (FileException ex) { } + } + _db_statement ~= SQLiteTablesReCreate!()(); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "TABLE RE-CREATE"); + _db_statement = []; + } + if (doc_matters.opt.action.sqlite_delete) { + _db_statement ~= SQLiteDeleteDocument!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "DELETE Document"); + _db_statement = []; + } + if (doc_matters.opt.action.sqlite_update) { + _db_statement ~= SQLiteDeleteDocument!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "DELETE Document"); + _db_statement = []; + _db_statement ~= SQLiteInsertMetadata!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT MetaData"); + _db_statement = []; + /+ get tid (lastrowid or max) for use in doc_objects table +/ + _db_statement ~= doc_abstraction.SQLiteInsertDocObjectsLoop!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT DocObjects"); + _db_statement = []; + _db_statement ~= SQLiteInsertMetadataTopics!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT MetaDataTopics"); + _db_statement = []; + } + db.close; + if (doc_matters.opt.action.vox_gt0) { + writeln(" ", pth_sqlite.sqlite_file); + } + } + } + try { + auto db = Database(pth_sqlite.sqlite_file); + SQLiteDbStatementComposite!()(db, doc_abstraction, doc_matters); + } + catch (FileException e) { + writeln("Failed (FileException): ", e.msg, " ", pth_sqlite.sqlite_file); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (ErrnoException e) { + writeln("Failed (ErrnoException): ", e.msg, " ", pth_sqlite.sqlite_file); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Exception e) { + writeln("Failed (Exception): ", e.msg, " ", pth_sqlite.sqlite_file); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Throwable) { + writeln("Failed (Trowable): ", pth_sqlite.sqlite_file); + import core.runtime; + core.runtime.Runtime.terminate(); + } + } +} +template SQLiteHubDiscreteBuildTablesAndPopulate() { + void SQLiteHubDiscreteBuildTablesAndPopulate(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); + auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); // doc_matters.db_path + if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { + } else { + try { + pth_sqlite.base.mkdirRecurse; + } catch (FileException ex) { } + } + auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); + template SQLiteDiscreteDbStatementComposite() { + void SQLiteDiscreteDbStatementComposite(Db,D,M)( + Db db, + const D doc_abstraction, + M doc_matters, + ) { + try { + { + string _db_statement; + _db_statement ~= SQLiteTablesReCreate!()(); + _db_statement ~= SQLiteInsertMetadata!()(doc_matters); + _db_statement ~= SQLiteInsertMetadataTopics!()(doc_matters); + _db_statement ~= doc_abstraction.SQLiteInsertDocObjectsLoop!()(doc_matters); + SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "table CREATE Tables, INSERT DocObjects"); + } + db.close; + } + catch (FileException e) { + writeln("Failed (FileException): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (ErrnoException e) { + writeln("Failed (ErrnoException): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Exception e) { + writeln("Failed (Exception): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Throwable) { + import core.runtime; + core.runtime.Runtime.terminate(); + } + if (doc_matters.opt.action.vox_gt0) { + writeln(" ", pth_sqlite.sqlite_file(doc_matters.src.filename)); + } + } + } + SQLiteDiscreteDbStatementComposite!()(db, doc_abstraction, doc_matters); + } +} +template SQLiteDbRun() { + void SQLiteDbRun(Db,St,O)( + Db db, + St db_statement, + O opt_action, + string note, + ) { + debug(sql_statement) { + writeln(db_statement); + } + try { + db.run( + "\nBEGIN TRANSACTION;\n" ~ + db_statement ~ + "\nCOMMIT TRANSACTION;\n" + ); + } catch (ErrnoException ex) { + writeln("ERROR SQLite : ", ex); + } catch (Exception ex) { + writeln("ERROR SQLite : ", ex); + } + { /+ debug +/ + if (opt_action.debug_do_sqlite) { + writeln(note); + if (opt_action.vox_gt2) { + writeln(db_statement); + } + } + } + } +} +template SQLinsertDelimiter() { + string SQLinsertDelimiter(string _txt) { + _txt = _txt + .replaceAll(rgx.quotation_mark_sql_insert_delimiter, "$0$0"); + return _txt; + } +} +template SQLiteFormatAndLoadObject() { + auto SQLiteFormatAndLoadObject(M)( + M doc_matters, + ) { + mixin spineRgxOut; + mixin spineRgxXHTML; + struct sqlite_format_and_load_objects { + string generic_munge_sanitize_text_for_search( + string _txt, + ) { + string _notes; + string _urls; + if (_txt.matchFirst(rgx.inline_notes_al_gen)) { + foreach (m; _txt.matchAll(rgx.inline_notes_al_gen_text)) { + _notes ~= "\n" ~ m["text"]; + } + _txt = _txt.replaceAll(rgx.inline_notes_al_gen, ""); + } + if (_txt.matchFirst(rgx.inline_link)) { + foreach (m; _txt.matchAll(rgx.inline_link)) { + if (m["link"].match(rgx.url)) { + _urls ~= "\n" ~ m["link"]; + } + } + _txt = _txt.replaceAll(rgx.inline_link_clean, ""); + } + if (_notes.length > 0) { + _txt ~= _notes; + } + if (_urls.length > 0) { + _txt ~= _urls; + } + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(_txt, "\n"); + } + } + debug(sql_text_clean) { + writeln(_txt); + } + return _txt; + } + string munge_html(M,O)( + M doc_matters, + const O obj, + ) { + 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_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_gt0) { + 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"] + ~ ""; + } + _txt = replaceAll!(m => + (" " ~ "" ~ m["num"] ~ "")) + (_txt, rgx.inline_notes_al_regular_number_note) + ~ _endnotes.join("\n"); + } + debug(markup_endnotes) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); + } + } + debug(markup) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); + } + } + return _txt; + } + string xml_type="seg"; /+ set html document type to be linked to here (seg|scroll) +/ + string inline_markup(M,O)( + M doc_matters, + const O obj, + string _txt, + ) { + if (obj.metainfo.is_a == "group") { + _txt = inline_grouped_text_bullets_indents(doc_matters, obj, _txt, xml_type); + } + _txt = inline_images(doc_matters, obj, _txt, xml_type); + _txt = inline_links(doc_matters, obj, _txt, xml_type); + _txt = inline_notes_scroll(doc_matters, obj, _txt); + return _txt; + } + string html_heading(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 == "heading"); + 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_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 ~= ""; + 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 { + string _col_is = (row_idx == 0 && obj.table.heading) ? "th" : "td"; + string _align = ("style=\"text-align:" + ~ ((obj.table.column_aligns[col_idx] == "l") + ? "left\"" : "right\"")); + _table ~= "<" + ~ _col_is + ~ " width=\"" + ~ obj.table.column_widths[col_idx].to!string + ~ "%\" " + ~ _align + ~ ">"; + _table ~= cell; + _table ~= "" + ~ _col_is + ~ ">"; + } + } + _table ~= " "; + } + Tuple!(string, string) t = tuple( + _table, + _tablenote, + ); + return t; + } + string _txt = munge_html(doc_matters, obj); + Tuple!(string, string) t = _tablarize(obj, _txt); + _txt = t[0]; + string _note = t[1]; + string o = format(q"┃+
+ %s +
+ %s + ┃", + obj.metainfo.is_a, + _txt, + _note + ); + return o; + } + string sqlite_load_string(M,O)( + M doc_matters, + const O obj, + ) { + string o; + return o; + } + string sqlite_statement(O)( + const O obj, + string _txt, + string _html, + ) { + void _sql_exe(O)( + string _sql, + ) { + writeln(_html); + writeln(_sql); + } + string _sql; + return _sql; + } + string[string] heading(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_heading(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] para(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_para(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] quote(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_quote(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] group(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_group(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] block(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_block(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] verse(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_verse(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] code(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_code(obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + string[string] table(M,O)( + M doc_matters, + const O obj, + ) { + string[string] obj_txt = [ + "text": generic_munge_sanitize_text_for_search(obj.text), + "html": html_table(doc_matters, obj) + ]; + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql + } + } + return obj_txt; + } + } + return sqlite_format_and_load_objects(); + } +} +template SQLiteTablesReCreate() { + string SQLiteTablesReCreate()() { + string _sql_instruct; + _sql_instruct = format(q"┃ + DROP INDEX IF EXISTS idx_ocn; + DROP INDEX IF EXISTS idx_uid; + DROP INDEX IF EXISTS idx_digest_clean; + DROP INDEX IF EXISTS idx_digest_all; + DROP INDEX IF EXISTS idx_clean; + DROP INDEX IF EXISTS idx_title; + DROP INDEX IF EXISTS idx_author; + DROP INDEX IF EXISTS src_filename_base; + DROP INDEX IF EXISTS idx_language_document_char; + DROP INDEX IF EXISTS idx_classify_topic_register; + DROP INDEX IF EXISTS idx_topic_list; + DROP TABLE IF EXISTS metadata_and_text; + DROP TABLE IF EXISTS topic_register; + DROP TABLE IF EXISTS doc_objects; + DROP TABLE IF EXISTS urls; + CREATE TABLE IF NOT EXISTS metadata_and_text ( + uid VARCHAR(256) UNIQUE, -- filename, language char, pod/txt (decide on delimiter [,;:/]) + src_composite_id_per_txt VARCHAR(256) NOT NULL, -- UNIQUE, z pod name if any + src filename + language code + src_composite_id_per_pod VARCHAR(256) NOT NULL, -- z pod name if any + src filename + title VARCHAR(800) NOT NULL, + title_main VARCHAR(400) NOT NULL, + title_sub VARCHAR(400) NULL, + title_short VARCHAR(400) NULL, + title_edition VARCHAR(10) NULL, + title_language VARCHAR(100) NULL, + title_language_char VARCHAR(6) NULL, + creator_author VARCHAR(600) NOT NULL, + creator_author_last_first VARCHAR(600) NOT NULL, + creator_author_email VARCHAR(100) NULL, + creator_author_hon VARCHAR(100) NULL, + creator_author_nationality VARCHAR(100) NULL, + creator_editor VARCHAR(600) NULL, + creator_contributor VARCHAR(600) NULL, + creator_illustrator VARCHAR(600) NULL, + creator_photographer VARCHAR(600) NULL, + creator_translator VARCHAR(600) NULL, + creator_prepared_by VARCHAR(600) NULL, + creator_digitized_by VARCHAR(600) NULL, + creator_audio VARCHAR(600) NULL, + creator_video VARCHAR(600) NULL, + language_document VARCHAR(100) NULL, + language_document_char VARCHAR(6) NOT NULL, + language_original VARCHAR(100) NULL, + language_original_char VARCHAR(6) NULL, + date_added_to_site VARCHAR(10) NULL, + date_available VARCHAR(10) NULL, + date_created VARCHAR(10) NULL, + date_issued VARCHAR(10) NULL, + date_modified VARCHAR(10) NULL, + date_published VARCHAR(10) NULL, + date_valid VARCHAR(10) NULL, + date_translated VARCHAR(10) NULL, + date_original_publication VARCHAR(10) NULL, + date_generated VARCHAR(10) NULL, + original_title VARCHAR(800) NULL, + original_publisher VARCHAR(600) NULL, + original_language VARCHAR(100) NULL, + original_language_char VARCHAR(6) NULL, + original_source VARCHAR(600) NULL, + original_institution VARCHAR(600) NULL, + original_nationality VARCHAR(100) NULL, + rights_copyright VARCHAR(2500) NULL, + rights_copyright_audio VARCHAR(2500) NULL, + rights_copyright_cover VARCHAR(2500) NULL, + rights_copyright_illustrations VARCHAR(2500) NULL, + rights_copyright_photographs VARCHAR(2500) NULL, + rights_copyright_text VARCHAR(2500) NULL, + rights_copyright_translation VARCHAR(2500) NULL, + rights_copyright_video VARCHAR(2500) NULL, + rights_license VARCHAR(2500) NULL, + identifier_oclc VARCHAR(30) NULL, + identifier_isbn VARCHAR(16) NULL, + classify_topic_register VARCHAR(2500) NULL, + classify_subject VARCHAR(600) NULL, + classify_loc VARCHAR(30) NULL, + classify_dewey VARCHAR(30) NULL, + classify_keywords VARCHAR(600) NULL, + notes_abstract TEXT NULL, + notes_description TEXT NULL, + notes_comment TEXT NULL, + notes_coverage VARCHAR(200) NULL, + notes_relation VARCHAR(200) NULL, + notes_history VARCHAR(600) NULL, + notes_type VARCHAR(600) NULL, + notes_format VARCHAR(600) NULL, + notes_prefix TEXT NULL, + notes_prefix_a TEXT NULL, + notes_prefix_b TEXT NULL, + notes_suffix TEXT NULL, + publisher VARCHAR(600) NULL, + src_filename_base VARCHAR(256) NOT NULL, + src_filename_suffix VARCHAR(6) NOT NULL, + src_fingerprint VARCHAR(256) NULL, + src_filesize VARCHAR(10) NULL, + src_wordcount VARCHAR(10) NULL, + pod_name VARCHAR(256) NULL, -- zipped pod, work to be done here + pod_fingerprint VARCHAR(256) NULL, -- zipped pod, work to be done here + pod_size VARCHAR(10) NULL, -- zipped pod, work to be done here + site_url_doc_root VARCHAR(256) NULL, -- url path to doc root + site_url_html_toc VARCHAR(256) NULL, + site_url_html_scroll VARCHAR(256) NULL, + site_url_epub VARCHAR(256) NULL, + links TEXT NULL + ); + CREATE TABLE IF NOT EXISTS topic_register ( + -- tid BIGINT PRIMARY KEY, + uid_metadata_and_text VARCHAR(256) REFERENCES metadata_and_text(uid) ON DELETE CASCADE, + -- src_composite_id_per_txt VARCHAR(256) NOT NULL, - UNIQUE, - z pod name if any + src filename + language code + -- src_composite_id_per_pod VARCHAR(256) NOT NULL, - z pod name if any + src filename + topic_register VARCHAR(250) NOT NULL, + site_url_doc_root VARCHAR(256) NULL, -- url path to doc root + site_url_html_toc VARCHAR(256) NULL, + site_url_html_scroll VARCHAR(256) NULL + ); + CREATE TABLE IF NOT EXISTS doc_objects ( + lid BIGINT PRIMARY KEY, + uid_metadata_and_text VARCHAR(256) REFERENCES metadata_and_text(uid) ON DELETE CASCADE, + ocn SMALLINT, + obj_id VARCHAR(6) NULL, + clean TEXT NULL, + body TEXT NULL, + seg VARCHAR(256) NULL, + lev_an VARCHAR(1), + is_of_type VARCHAR(16), + is_a VARCHAR(16), + lev SMALLINT NULL, + node VARCHAR(16) NULL, + parent VARCHAR(16) NULL, + last_descendant VARCHAR(16) NULL, -- headings only + digest_clean CHAR(256), + digest_all CHAR(256), + seg_name CHAR(256), + types CHAR(1) NULL + ); + CREATE INDEX IF NOT EXISTS idx_ocn ON doc_objects(ocn); + CREATE INDEX IF NOT EXISTS idx_digest_clean ON doc_objects(digest_clean); + CREATE INDEX IF NOT EXISTS idx_digest_all ON doc_objects(digest_all); + CREATE INDEX IF NOT EXISTS idx_clean ON doc_objects(clean); + CREATE INDEX IF NOT EXISTS idx_title ON metadata_and_text(title); + CREATE INDEX IF NOT EXISTS idx_author ON metadata_and_text(creator_author_last_first); + CREATE INDEX IF NOT EXISTS idx_uid ON metadata_and_text(uid); + CREATE INDEX IF NOT EXISTS idx_filename ON metadata_and_text(src_filename_base); + CREATE INDEX IF NOT EXISTS idx_language ON metadata_and_text(language_document_char); + CREATE INDEX IF NOT EXISTS idx_topics ON metadata_and_text(classify_topic_register); + CREATE INDEX IF NOT EXISTS idx_topic_list ON topic_register(topic_register); + ┃",); + return _sql_instruct; + } +} +template SQLiteDeleteDocument() { + string SQLiteDeleteDocument(M)( + M doc_matters, + ) { + string _uid = doc_matters.src.doc_uid; + string _delete_uid = format(q"┃ + DELETE FROM metadata_and_text + WHERE uid = '%s'; + DELETE FROM doc_objects + WHERE uid_metadata_and_text = '%s'; + ┃", + _uid, + _uid, + ); + return _delete_uid; + } +} +template SQLiteInsertMetadata() { + string SQLiteInsertMetadata(M)( + M doc_matters, + ) { + string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); + string _insert_metadata = format(q"┃ + INSERT INTO metadata_and_text ( + uid, + src_filename_base, + src_filename_suffix, + src_composite_id_per_txt, + src_composite_id_per_pod, + title, + title_main, + title_sub, + title_short, + title_edition, + title_language, + creator_author, + creator_author_last_first, + creator_author_email, + creator_illustrator, + creator_translator, + language_document, + language_document_char, + date_added_to_site, + date_available, + date_created, + date_issued, + date_modified, + date_published, + date_valid, + rights_copyright, + rights_copyright_audio, + rights_copyright_cover, + rights_copyright_illustrations, + rights_copyright_photographs, + rights_copyright_text, + rights_copyright_translation, + rights_copyright_video, + rights_license, + identifier_oclc, + identifier_isbn, + classify_dewey, + classify_keywords, + classify_loc, + classify_subject, + classify_topic_register, + original_title, + original_publisher, + original_language, + original_language_char, + original_source, + notes_abstract, + notes_description, + publisher, + site_url_doc_root + ) + VALUES ( + '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' + ); + ┃", + _uid, + SQLinsertDelimiter!()(doc_matters.src.filename_base), + SQLinsertDelimiter!()(doc_matters.src.filename_extension), + SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_doc), + SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_pod), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_full), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_main), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_subtitle), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_short), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_edition), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_language), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_surname_fn), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_email), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_illustrator), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_translator), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.language_document), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.language_document_char), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_added_to_site), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_available), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_created), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_issued), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_modified), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_published), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.date_valid), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_audio), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_cover), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_illustrations), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_photographs), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_text), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_translation), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_copyright_video), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.rights_license), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.identifier_oclc), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.identifier_isbn), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.classify_dewey), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.classify_keywords), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.classify_loc), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.classify_subject), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.classify_topic_register), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.notes_abstract), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.notes_description), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_title), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_publisher), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_language), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_language_char), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_source), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.publisher), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html) + ); + return _insert_metadata; + } +} +template SQLiteInsertMetadataTopics() { + string SQLiteInsertMetadataTopics(M)( + M doc_matters, + ) { + string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); + string[] _insert_topics; + foreach (topic_line; doc_matters.conf_make_meta.meta.classify_topic_register_expanded_arr) { + // writeln(topic_line); + _insert_topics ~= format(q"┃ + INSERT INTO topic_register ( + uid_metadata_and_text, + topic_register + ) + VALUES ( + '%s', + '%s' + ); + ┃", + _uid, + SQLinsertDelimiter!()(topic_line) + ); + } + return _insert_topics.join.to!(char[]).toUTF8; + } +} +template SQLiteInsertDocObjectsLoop() { + string SQLiteInsertDocObjectsLoop(D,M)( + const D doc_abstraction, + M doc_matters, + ) { + string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); + string insertDocObjectsRow(O)(O obj) { + string _insert_doc_objects_row = format(q"┃ + INSERT INTO doc_objects ( + uid_metadata_and_text, + ocn, + obj_id, + clean, + body, + lev, + is_of_type, + is_a, + seg_name + ) + VALUES ( + '%s', %s, '%s', '%s', '%s', %s, '%s', '%s', '%s' + ); + ┃", + _uid, + obj.metainfo.ocn, + obj.metainfo.identifier, + SQLinsertDelimiter!()(obj_txt["text"]), + SQLinsertDelimiter!()(obj_txt["html"]), + obj.metainfo.heading_lev_markup, + obj.metainfo.is_of_type, + obj.metainfo.is_a, + obj.tags.html_segment_anchor_tag_is + ); + return _insert_doc_objects_row; + } + auto format_and_sqlite_load = SQLiteFormatAndLoadObject!()(doc_matters); + string[string] obj_txt; + string doc_text; + string[] _insert_doc_objects; + foreach (part; doc_matters.has.keys_seq.sql) { + foreach (obj; doc_abstraction[part]) { + switch (obj.metainfo.is_of_part) { + case "frontmatter": assert(part == "head", part); + switch (obj.metainfo.is_of_type) { + case "para": + switch (obj.metainfo.is_a) { + case "heading": + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } + } + break; + } + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } + } + break; + } + break; + case "body": // assert(part == "body", part); + switch (obj.metainfo.is_of_type) { + case "para": + switch (obj.metainfo.is_a) { + case "heading": + debug (asserts) { + if (part != "body") { + writeln(__LINE__, ": ", obj.text); + } + } + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + break; + case "para": + obj_txt = format_and_sqlite_load.para(doc_matters, obj); + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } + } + break; + } + break; + case "block": + switch (obj.metainfo.is_a) { + case "quote": + obj_txt = format_and_sqlite_load.quote(doc_matters, obj); + break; + case "group": + obj_txt = format_and_sqlite_load.group(doc_matters, obj); + break; + case "block": + obj_txt = format_and_sqlite_load.block(doc_matters, obj); + break; + case "poem": // double check on keeping both poem & verse + break; + case "verse": + obj_txt = format_and_sqlite_load.verse(doc_matters, obj); + break; + case "code": + obj_txt = format_and_sqlite_load.code(doc_matters, obj); + break; + case "table": + obj_txt = format_and_sqlite_load.table(doc_matters, obj); + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } + } + break; + } + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } + } + break; + } + break; + case "backmatter": + assert(part == "glossary" || "bibliography" || "bookindex" || "blurb" || "tail", part); + switch (obj.metainfo.is_of_type) { + case "para": + switch (obj.metainfo.is_a) { + case "heading": + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); + break; + case "glossary": assert(part == "glossary", part); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); + break; + case "bibliography": assert(part == "bibliography", part); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); + break; + case "bookindex": assert(part == "bookindex", part); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); + break; + case "blurb": assert(part == "blurb", part); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } + } + break; + } + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } + } + break; + } + break; + case "comment": + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do_sqlite) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from + } + } + break; + } + if (obj.metainfo.is_a == "heading") { + if (doc_matters.opt.action.show_sqlite) { + if (obj.metainfo.heading_lev_markup == 0) { + writeln(doc_matters.src.filename); + } + writeln( + "markup: ", obj.metainfo.heading_lev_markup, + "> ", obj.metainfo.dom_structure_markedup_tags_status, + "; collapsed: ", obj.metainfo.heading_lev_collapsed, + "> ", obj.metainfo.dom_structure_collapsed_tags_status, + "; ocn: ", obj.metainfo.ocn, + " node: ", obj.metainfo.node, + "; parent: ", obj.metainfo.parent_lev_markup, + "; ocn: ", obj.metainfo.parent_ocn, + "; ", + ); + } + } + if (!(obj.metainfo.is_a == "comment")) { + _insert_doc_objects ~= insertDocObjectsRow(obj); + } + } // loop closes + } + return _insert_doc_objects.join.to!(char[]).toUTF8; + } +} +template SQLiteTablesCreate() { + void SQLiteTablesCreate(E,O,C)(E env, O opt_action, C config) { + import d2sqlite3; + template SQLiteTablesReCreate() { + string SQLiteTablesReCreate()() { + string _sql_instruct; + _sql_instruct = format(q"┃ + DROP INDEX IF EXISTS idx_ocn; + DROP INDEX IF EXISTS idx_uid; + DROP INDEX IF EXISTS idx_digest_clean; + DROP INDEX IF EXISTS idx_digest_all; + DROP INDEX IF EXISTS idx_clean; + DROP INDEX IF EXISTS idx_title; + DROP INDEX IF EXISTS idx_author; + DROP INDEX IF EXISTS src_filename_base; + DROP INDEX IF EXISTS idx_language_document_char; + DROP INDEX IF EXISTS idx_classify_topic_register; + DROP INDEX IF EXISTS idx_topic_list; + DROP TABLE IF EXISTS metadata_and_text; + DROP TABLE IF EXISTS topic_register; + DROP TABLE IF EXISTS doc_objects; + DROP TABLE IF EXISTS urls; + CREATE TABLE IF NOT EXISTS metadata_and_text ( + uid VARCHAR(256) UNIQUE, -- filename, language char, pod/txt (decide on delimiter [,;:/]) + src_composite_id_per_txt VARCHAR(256) NOT NULL, -- UNIQUE, z pod name if any + src filename + language code + src_composite_id_per_pod VARCHAR(256) NOT NULL, -- z pod name if any + src filename + title VARCHAR(800) NOT NULL, + title_main VARCHAR(400) NOT NULL, + title_sub VARCHAR(400) NULL, + title_short VARCHAR(400) NULL, + title_edition VARCHAR(10) NULL, + title_language VARCHAR(100) NULL, + title_language_char VARCHAR(6) NULL, + creator_author VARCHAR(600) NOT NULL, + creator_author_last_first VARCHAR(600) NOT NULL, + creator_author_email VARCHAR(100) NULL, + creator_author_hon VARCHAR(100) NULL, + creator_author_nationality VARCHAR(100) NULL, + creator_editor VARCHAR(600) NULL, + creator_contributor VARCHAR(600) NULL, + creator_illustrator VARCHAR(600) NULL, + creator_photographer VARCHAR(600) NULL, + creator_translator VARCHAR(600) NULL, + creator_prepared_by VARCHAR(600) NULL, + creator_digitized_by VARCHAR(600) NULL, + creator_audio VARCHAR(600) NULL, + creator_video VARCHAR(600) NULL, + language_document VARCHAR(100) NULL, + language_document_char VARCHAR(6) NOT NULL, + language_original VARCHAR(100) NULL, + language_original_char VARCHAR(6) NULL, + date_added_to_site VARCHAR(10) NULL, + date_available VARCHAR(10) NULL, + date_created VARCHAR(10) NULL, + date_issued VARCHAR(10) NULL, + date_modified VARCHAR(10) NULL, + date_published VARCHAR(10) NULL, + date_valid VARCHAR(10) NULL, + date_translated VARCHAR(10) NULL, + date_original_publication VARCHAR(10) NULL, + date_generated VARCHAR(10) NULL, + original_title VARCHAR(800) NULL, + original_publisher VARCHAR(600) NULL, + original_language VARCHAR(100) NULL, + original_language_char VARCHAR(6) NULL, + original_source VARCHAR(600) NULL, + original_institution VARCHAR(600) NULL, + original_nationality VARCHAR(100) NULL, + rights_copyright VARCHAR(2500) NULL, + rights_copyright_audio VARCHAR(2500) NULL, + rights_copyright_cover VARCHAR(2500) NULL, + rights_copyright_illustrations VARCHAR(2500) NULL, + rights_copyright_photographs VARCHAR(2500) NULL, + rights_copyright_text VARCHAR(2500) NULL, + rights_copyright_translation VARCHAR(2500) NULL, + rights_copyright_video VARCHAR(2500) NULL, + rights_license VARCHAR(2500) NULL, + identifier_oclc VARCHAR(30) NULL, + identifier_isbn VARCHAR(16) NULL, + classify_topic_register VARCHAR(2500) NULL, + classify_subject VARCHAR(600) NULL, + classify_loc VARCHAR(30) NULL, + classify_dewey VARCHAR(30) NULL, + classify_keywords VARCHAR(600) NULL, + notes_abstract TEXT NULL, + notes_description TEXT NULL, + notes_comment TEXT NULL, + notes_coverage VARCHAR(200) NULL, + notes_relation VARCHAR(200) NULL, + notes_history VARCHAR(600) NULL, + notes_type VARCHAR(600) NULL, + notes_format VARCHAR(600) NULL, + notes_prefix TEXT NULL, + notes_prefix_a TEXT NULL, + notes_prefix_b TEXT NULL, + notes_suffix TEXT NULL, + publisher VARCHAR(600) NULL, + src_filename_base VARCHAR(256) NOT NULL, + src_filename_suffix VARCHAR(6) NOT NULL, + src_fingerprint VARCHAR(256) NULL, + src_filesize VARCHAR(10) NULL, + src_wordcount VARCHAR(10) NULL, + pod_name VARCHAR(256) NULL, -- zipped pod, work to be done here + pod_fingerprint VARCHAR(256) NULL, -- zipped pod, work to be done here + pod_size VARCHAR(10) NULL, -- zipped pod, work to be done here + site_url_doc_root VARCHAR(256) NULL, -- url path to doc root + site_url_html_toc VARCHAR(256) NULL, + site_url_html_scroll VARCHAR(256) NULL, + site_url_epub VARCHAR(256) NULL, + links TEXT NULL + ); + CREATE TABLE IF NOT EXISTS topic_register ( + -- tid BIGINT PRIMARY KEY, + uid_metadata_and_text VARCHAR(256) REFERENCES metadata_and_text(uid) ON DELETE CASCADE, + -- src_composite_id_per_txt VARCHAR(256) NOT NULL, - UNIQUE, - z pod name if any + src filename + language code + -- src_composite_id_per_pod VARCHAR(256) NOT NULL, - z pod name if any + src filename + topic_register VARCHAR(250) NOT NULL, + site_url_doc_root VARCHAR(256) NULL, -- url path to doc root + site_url_html_toc VARCHAR(256) NULL, + site_url_html_scroll VARCHAR(256) NULL + ); + CREATE TABLE IF NOT EXISTS doc_objects ( + lid BIGINT PRIMARY KEY, + uid_metadata_and_text VARCHAR(256) REFERENCES metadata_and_text(uid) ON DELETE CASCADE, + ocn SMALLINT, + obj_id VARCHAR(6) NULL, + clean TEXT NULL, + body TEXT NULL, + seg VARCHAR(256) NULL, + lev_an VARCHAR(1), + is_of_type VARCHAR(16), + is_a VARCHAR(16), + lev SMALLINT NULL, + node VARCHAR(16) NULL, + parent VARCHAR(16) NULL, + last_descendant VARCHAR(16) NULL, -- headings only + digest_clean CHAR(256), + digest_all CHAR(256), + seg_name CHAR(256), + types CHAR(1) NULL + ); + CREATE INDEX IF NOT EXISTS idx_ocn ON doc_objects(ocn); + CREATE INDEX IF NOT EXISTS idx_digest_clean ON doc_objects(digest_clean); + CREATE INDEX IF NOT EXISTS idx_digest_all ON doc_objects(digest_all); + CREATE INDEX IF NOT EXISTS idx_clean ON doc_objects(clean); + CREATE INDEX IF NOT EXISTS idx_title ON metadata_and_text(title); + CREATE INDEX IF NOT EXISTS idx_author ON metadata_and_text(creator_author_last_first); + CREATE INDEX IF NOT EXISTS idx_uid ON metadata_and_text(uid); + CREATE INDEX IF NOT EXISTS idx_filename ON metadata_and_text(src_filename_base); + CREATE INDEX IF NOT EXISTS idx_language ON metadata_and_text(language_document_char); + CREATE INDEX IF NOT EXISTS idx_topics ON metadata_and_text(classify_topic_register); + CREATE INDEX IF NOT EXISTS idx_topic_list ON topic_register(topic_register); + ┃",); + return _sql_instruct; + } + } + try { + if (opt_action.sqlite_db_create) { + string _db_statement; + string db_filename = (opt_action.sqliteDB_filename.length > 0) + ? opt_action.sqliteDB_filename + : (config.conf.w_srv_db_sqlite_filename.length > 0) + ? config.conf.w_srv_db_sqlite_filename + : ""; + string db_path = (opt_action.sqliteDB_path.length > 0) + ? opt_action.sqliteDB_path + : (config.conf.w_srv_db_sqlite_path.length > 0) + ? config.conf.w_srv_db_sqlite_path + : ""; + if (db_filename.length > 0 && db_path.length > 0) { + if (opt_action.vox_gt2) { + writeln("db name: ", db_filename); + writeln("db path: ", db_path); + writeln("db name & path: ", db_path, "/", db_filename); + } + if (opt_action.vox_gt1) { + writeln("attempting to create db: ", db_path, "/", db_filename); + } + auto pth_sqlite = spinePathsSQLite!()(db_filename, db_path); + if ((isValidPath(pth_sqlite.base) && exists(pth_sqlite.base) != 0 && pth_sqlite.base.isDir)) { + } else { + try { + pth_sqlite.base.mkdirRecurse; + } catch (FileException ex) { } + } + auto db = Database(pth_sqlite.sqlite_file); + { + _db_statement ~= SQLiteTablesReCreate!()(); + } + SQLiteDbRun!()(db, _db_statement, opt_action, "TABLE RE-CREATE"); + } else { + writeln("must provide db name & output root path either on the command line or in configuration file"); + writeln("db name: ", db_filename); + writeln("db path: ", db_path); + } + } + } + catch (FileException e) { + writeln("Failed (FileException): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (ErrnoException e) { + writeln("Failed (ErrnoException): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Exception e) { + writeln("Failed (Exception): ", e.msg); + writeln(e.file, " line: ", e.line); + import core.runtime; + core.runtime.Runtime.terminate(); + } + catch (Throwable) { + import core.runtime; + core.runtime.Runtime.terminate(); + } + } +} +template SQLiteDbDrop() { + void SQLiteDbDrop(O,C)(O opt_action, C config) { + writeln("db drop"); + if ((opt_action.sqlite_db_drop)) { + string db_filename = (opt_action.sqliteDB_filename.length > 0) + ? opt_action.sqliteDB_filename + : (config.conf.w_srv_db_sqlite_filename.length > 0) + ? config.conf.w_srv_db_sqlite_filename + : ""; + string db_path = (opt_action.sqliteDB_path.length > 0) // + ? opt_action.sqliteDB_path + : (config.conf.w_srv_db_sqlite_path.length > 0) + ? config.conf.w_srv_db_sqlite_path + : ""; + if (db_filename.length > 0 && db_path.length > 0) { + auto pth_sqlite = spinePathsSQLite!()(db_filename, db_path); + writeln("remove(", pth_sqlite.sqlite_file, ")"); + try { + remove(pth_sqlite.sqlite_file); + } catch (FileException ex) { + // handle error + } + } else { + writeln("must provide db name & output root path either on the command line or in configuration file"); + writeln("db name: ", db_filename); + writeln("db path: ", db_path); + } + } + } +} diff --git a/src/sisudoc/io_out/xmls.d b/src/sisudoc/io_out/xmls.d new file mode 100644 index 0000000..c268bb7 --- /dev/null +++ b/src/sisudoc/io_out/xmls.d @@ -0,0 +1,1424 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.io_out.xmls; +@safe: +template outputXHTMLs() { + import + std.file, + std.outbuffer, + std.uri, + std.conv : to; + import + sisudoc.io_out, + sisudoc.io_out.rgx, + sisudoc.meta.rgx_files, + sisudoc.io_out.rgx_xhtml, + sisudoc.io_out.create_zip_file, + sisudoc.io_out.xmls, + sisudoc.io_out.xmls_css; + mixin spineRgxOut; + mixin spineRgxXHTML; + struct outputXHTMLs { + static auto rgx = RgxO(); + static auto rgx_xhtml = RgxXHTML(); + string div_delimit( + string section, + return ref string previous_section + ) { + string delimit = ""; + string delimit_ = ""; + if (section != previous_section) { + switch (section) { + case "head": + delimit_ ~= "\n\n" ; + break; + case "toc": + delimit_ ~= "\n\n" ; + break; + case "bookindex": + delimit_ ~= "\n\n" ; + break; + default: + delimit_ ~= "\n┃"); + return o; +} +string tail(M)(M doc_matters) { + string o; + o = format(q"┃\n" ; + break; + } + if (previous_section.length > 0) { + delimit ~= "\n"; + } + previous_section = section; + delimit ~= delimit_; + } + // you also need to close the last div, introduce a footer? + return delimit; + } + 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 special_characters_date(string _txt) { + _txt = _txt + .replaceAll(regex(r"(?:-00)+"), "") + .replaceAll(rgx.br_line, "
") + .replaceAll(rgx.br_line_inline, "
") + .replaceAll(rgx.br_line_spaced, "
\n
") + .replaceAll(rgx.nbsp_char, " "); + return _txt; + } + string special_characters_breaks_indents_bullets(O)( + const O obj, + ) { + string _txt = special_characters_text(obj.text); + 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, + " ● "); + } + if (!(obj.metainfo.is_a == "code")) { + _txt = (_txt) + .replaceAll(rgx_xhtml.line_break, "
"); + } + return _txt; + } + string 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 _xhtml_anchor_tags(O)(O obj) { + string tags=""; + if (obj.tags.anchor_tags.length > 0) { + foreach (tag; obj.tags.anchor_tags) { + if (!(tag.empty)) { + tags ~= ""; + } + } + } + return tags; + } + string header_metadata(M)( + M doc_matters, + ) { + string _publisher="Publisher"; // TODO + string o; + o = format(q"┃ + + + + + + + + + + + + + + + ┃", + special_characters_text(doc_matters.conf_make_meta.meta.title_full), + special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + _publisher, + special_characters_date(doc_matters.conf_make_meta.meta.date_published), + special_characters_text(doc_matters.conf_make_meta.meta.date_created), + special_characters_text(doc_matters.conf_make_meta.meta.date_issued), + special_characters_text(doc_matters.conf_make_meta.meta.date_available), + special_characters_text(doc_matters.conf_make_meta.meta.date_valid), + special_characters_text(doc_matters.conf_make_meta.meta.date_modified), + doc_matters.src.language, + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + doc_matters.opt.action.generated_by ? special_characters_text(doc_matters.generator_program.name_and_version) : "", + special_characters_text(doc_matters.generator_program.url_home), + ); + return o; + } + string site_info_button(M)( + M doc_matters, + ) { + string _locations; + if (doc_matters.conf_make_meta.make.home_button_text.length > 0) { + _locations = (doc_matters.conf_make_meta.make.home_button_text) + .replaceAll( + rgx.inline_link, + ("")) + .replaceAll( + rgx.br_line, "") + .replaceAll( + rgx.br_line_inline, ""); + } else { + _locations = "\n\n"; + } + string o; + o = format(q"┃ ┃", + _locations, + ); + return o; + } + 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; + } + string html_head(M)( + M doc_matters, + string type, + ) { + string o; + string metadata_links = ((doc_matters.opt.action.html_link_curate) + ? format(q"┃┃", + (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 + , // HOME index.html equivalent _cfg.www_url_doc_root, + (type == "seg") + ? "../" ~ doc_matters.src.filename_base ~ ".html" + : "./" ~ doc_matters.src.filename_base ~ "/toc.html", + (type == "seg") ? "▤" : "※", + (type == "seg") ? "../../" : "../", + doc_matters.src.filename_base, + doc_matters.src.lng, + (doc_matters.opt.action.html_link_pdf || doc_matters.opt.action.html_link_pdf_a4) + ? (" □ ") + : "", + (doc_matters.opt.action.html_link_pdf || doc_matters.opt.action.html_link_pdf_letter) + ? (" □ ") + : "", + (type == "seg") ? "../" : "", + doc_matters.src.filename_base, + (type == "seg") ? "../" : "", + (type == "seg") ? "../" : "", + (type == "seg") ? "../" : "", + ) + : ""); + o = format(q"┃ + + + ++ %s%s + + + %s + + + + + + + ++┃", + special_characters_text(doc_matters.conf_make_meta.meta.title_full), + (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + header_metadata(doc_matters), + ((type == "seg") ? "../" : ""), + ((type == "seg") + ? "../../../css/html_seg.css" + : "../../css/html_scroll.css"), + doc_matters.src.language, + site_info_button(doc_matters), + metadata_links, + inline_search_form(doc_matters), + ); + return o; + } + string epub3_seg_head(M)( + M doc_matters, + ) { + string html_base = format(q"┃ + ┃", + ); + string html_simple = format(q"┃ + ┃", + doc_matters.src.language, + doc_matters.src.language, + ); + string html_strict = format(q"┃ + ┃", + doc_matters.src.language, + doc_matters.src.language, + ); + string o; + o = format(q"┃%s + + ++ %s%s + + + + + + + + + + + + + + + + + + + + ┃", + html_simple, + special_characters_text(doc_matters.conf_make_meta.meta.title_full), + (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + special_characters_text(doc_matters.conf_make_meta.meta.title_full), + (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" + : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), + special_characters_date(doc_matters.conf_make_meta.meta.date_published), + special_characters_text(doc_matters.conf_make_meta.meta.date_created), + special_characters_text(doc_matters.conf_make_meta.meta.date_issued), + special_characters_text(doc_matters.conf_make_meta.meta.date_available), + special_characters_text(doc_matters.conf_make_meta.meta.date_valid), + special_characters_text(doc_matters.conf_make_meta.meta.date_modified), + doc_matters.src.language, + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + special_characters_text(doc_matters.generator_program.name_and_version), + special_characters_text(doc_matters.generator_program.url_home), + doc_matters.src.language, + ); + return o; + } +string dom_close() { + string o; + o = format(q"┃
+ + %s + +
+++ + + + +┃", + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + ((doc_matters.conf_make_meta.meta.rights_license).empty) ? "" : "+ ≅ SiSU Spine ፨ (object numbering & object search) +
++ (web 1993, object numbering 1997, object search 2002 ...) 2024 +
+
", + ((doc_matters.conf_make_meta.meta.rights_license).empty) ? "" + : "License: " ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_license) + ); + return o; +} + string inline_images(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "seg", + ) { + string _img_pth; + switch (_xml_type) { + case "epub": _img_pth = "image/"; break; + case "scroll": _img_pth = format(q"┃%s/image/┃", "../.."); break; + case "seg": _img_pth = format(q"┃%s/image/┃", "../../.."); break; + default: break; + } + if (_txt.match(rgx.inline_image)) { + _txt = _txt + .replaceAll(rgx.inline_image, + ("$1 $6")) + .replaceAll( + rgx.inline_link_empty, + ("$1")); + } + return _txt; + } + string inline_links(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "seg", + ) { + string seg_lvs; + if (obj.has.inline_links) { + if (obj.metainfo.is_a != "code") { + _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); + } + 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"); + } + if (_xml_type == "seg" || _xml_type == "epub") { + seg_lvs = (_xml_type == "epub") ? "seg_lv1to4" : "seg_lv4"; + foreach (m; _txt.match(rgx.inline_link_hash)) { + if (m.captures["hash"] in doc_matters.has.tag_associations) { + if ( + m.captures["hash"] + == doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] + ) { + _txt = _txt.replaceFirst( + rgx.inline_link_hash, + "┥$1┝┤$3" ~ _suffix ~ "├" + ); + } else { + _txt = _txt.replaceFirst( + rgx.inline_link_hash, + "┥$1┝┤" + ~ doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] + ~ _suffix ~ "#" ~ "$3" + ~ "├" + ); + } + } else { + if (doc_matters.opt.action.vox_gt0) { + 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 + ); + } + } + } + } + _txt = _txt + .replaceAll( + rgx.inline_link_fn_suffix, + ("$1" ~ _suffix)) + .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 + ); + } + } + debug(markup) { + if (_txt.match(rgx.inline_link)) { + writeln(__LINE__, + " (missed) markup link identified (", + obj.has.inline_links, + "): ", obj.metainfo.is_a, ": ", + obj.text + ); + } + } + return _txt; + } + string inline_notes_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + if (obj.has.inline_notes_reg) { + _txt = font_face(_txt); + _txt = _txt.replaceAll( + rgx.inline_notes_al_regular_number_note, + ("$1 ") + ); + } + if (obj.has.inline_notes_star) { + _txt = font_face(_txt); + _txt = _txt.replaceAll( + rgx.inline_notes_al_special_char_note, + ("$1 ") + ); + } + debug(markup_endnotes) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); + } + } + debug(markup) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { + writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); + } + } + return _txt; + } + Tuple!(string, string[]) inline_notes_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + string[] _endnotes; + if (obj.has.inline_notes_star) { + _txt = font_face(_txt); + /+ need markup for text, and separated footnote +/ + foreach(m; _txt.matchAll(rgx.inline_notes_al_special_char_note)) { + _endnotes ~= format( + "%s%s%s%s\n %s%s%s%s%s %s\n%s", + "", + "", + "
" + ); + } + _txt = _txt.replaceAll( + rgx.inline_notes_al_special_char_note, + ("", + m.captures[1], + ". ", + m.captures[2], + "$1 ") + ); + } + if (obj.has.inline_notes_reg) { + _txt = font_face(_txt); + /+ need markup for text, and separated footnote +/ + foreach(m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { + _endnotes ~= format( + "%s%s%s%s\n %s%s%s%s%s %s\n%s", + "", + "", + "
" + ); + } + _txt = _txt.replaceAll( + rgx.inline_notes_al_regular_number_note, + ("", + m.captures[1], + ". ", + m.captures[2], + "$1 ") + ); + } else if (_txt.match(rgx.inline_notes_al_regular_number_note)) { + debug(markup) { + writeln(__LINE__, " endnote: ", obj.metainfo.is_a, ": ", obj.text); + } + } + Tuple!(string, string[]) t = tuple( + _txt, + _endnotes, + ); + return t; + } + string inline_markup_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + ) { + if (obj.metainfo.dummy_heading + && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { + _txt = ""; + } else { + _txt = inline_images(_txt, obj, doc_matters, _suffix, "scroll"); + _txt = inline_links(_txt, obj, doc_matters, _suffix, "scroll"); + _txt = inline_notes_scroll(_txt, obj, doc_matters); + } + return _txt; + } + Tuple!(string, string[]) inline_markup_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "seg", + ) { + if (obj.metainfo.dummy_heading + && ((_xml_type == "epub" + && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) + || obj.metainfo.is_a == "heading") + ) { + _txt = ""; + } else { + _txt = inline_images(_txt, obj, doc_matters, _suffix, _xml_type); // TODO + _txt = inline_links(_txt, obj, doc_matters, _suffix, _xml_type); // TODO + } + Tuple!(string, string[]) t = inline_notes_seg(_txt, obj, doc_matters); + return t; + } + string lev4_heading_subtoc(O,M)( + const O obj, + M doc_matters, + ) { + char[] lev4_subtoc; + lev4_subtoc ~= "\n"; + foreach (subtoc; obj.tags.lev4_subtoc) { + if (auto m = subtoc.match(rgx.inline_link_subtoc)) { + auto indent = (m.captures[1].to!int - 3).to!string; // css assumptions based on use of em for left margin & indent + auto text = m.captures[2].to!string; + text = font_face(text); + auto link = m.captures[3].to!string; + lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc, + format(q"┃\n"; + return lev4_subtoc.to!string; + } + auto nav_pre_next_svg(O,M)( + const O obj, + M doc_matters, + ) { + string prev, next, toc; + if (obj.tags.segment_anchor_tag_epub == "toc") { + toc = ""; + prev = ""; + } else { + toc = format(q"┃ + ┃", + ); + } + if (obj.tags.segname_prev == "") { + prev = ""; + } else { + prev = format(q"┃ + + ┃", + obj.tags.segname_prev, + ); + } + if (obj.tags.segname_next == "") { + next = ""; + } else { + next = format(q"┃ + + ┃", + obj.tags.segname_next, + ); + } + string _toc_pre_next = format(q"┃ + ┃", + toc, + prev, + next, + ); + string _pre_next = format(q"┃ ┃", + prev, + next, + ); + struct bar { + string toc_pre_next() { + return _toc_pre_next; + } + string pre_next() { + return _pre_next; + } + } + return bar(); + } + string heading(O,M)( + string _txt, + const O obj, + M doc_matters, + string _xml_type = "html", + ) { + 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 == "heading"); + string tags = _xhtml_anchor_tags(obj); + string heading_lev_anchor_tag; + string _horizontal_rule = "+ ۰ %s +
+ ┃", + indent, + indent, + link, + text, + )); + } + } + lev4_subtoc ~= "
"; + if ((_xml_type != "html") + || (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) { + _horizontal_rule = ""; + } + _txt = font_face(_txt); + string o; + heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) + ? "" + : ""; + if (_txt.empty) { + o = format(q"┃%s + ┃", + _horizontal_rule, + ); + } else { + o = ""; + if (obj.metainfo.is_of_section == "toc") { + o ~= format(q"┃ + ┃", + special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), + special_characters_text(doc_matters.conf_make_meta.meta.rights_license) + ); + } + } + if (!(obj.metainfo.identifier.empty)) { + o ~= format(q"┃%s + ┃", + _horizontal_rule, + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) + ? "" : ((obj.metainfo.object_number.empty) + ? "" : obj.metainfo.identifier), + ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1 + : obj.metainfo.heading_lev_markup), + obj.metainfo.is_a, + obj.metainfo.identifier, + obj.metainfo.identifier, + tags, + heading_lev_anchor_tag, + _txt, + ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1 + : obj.metainfo.heading_lev_markup), + ); + } else { + o ~= format(q"┃%s ++┃", + _horizontal_rule, + ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1 + : obj.metainfo.heading_lev_markup), + obj.metainfo.is_a, + tags, + heading_lev_anchor_tag, + _txt, + ((_xml_type == "epub" && obj.metainfo.heading_lev_markup == 0) ? 1 + : obj.metainfo.heading_lev_markup), + ); + } + return o; + } + string heading_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + ) { + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = heading(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) heading_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0]; + string[] _endnotes = t[1]; + string o = heading(_txt, obj, doc_matters, _xml_type); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + string para(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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 tags = _xhtml_anchor_tags(obj); + _txt = font_face(_txt); + string o; + _txt = (obj.attrib.bullet) ? ("● " ~ _txt) : _txt; + _txt = _txt.replaceFirst(rgx.inline_link_anchor, + ""); + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃%s%s + %s + ++ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) + ? "" + : ((obj.metainfo.object_number.empty) + ? "" + : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.attrib.indent_hang, + obj.attrib.indent_base, + obj.metainfo.identifier, + tags, + _txt + ); + } else { + o = format(q"┃%s + %s +
++┃", + obj.metainfo.is_a, + obj.attrib.indent_hang, + obj.attrib.indent_base, + tags, + _txt + ); + } + return o; + } + string para_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + ) { + if (obj.metainfo.is_a == "toc" && _txt.match(rgx.inline_link_toc_to_backmatter)) { + _txt = _txt.replaceAll(rgx.inline_link_toc_to_backmatter, "┤#section_$1├"); + } + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = para(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) para_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0].to!string; + string[] _endnotes = t[1]; + string o = para(_txt, obj, doc_matters); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + string quote(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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"); + _txt = font_face(_txt); + string o; + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃%s + %s +
++ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.identifier, + _txt + ); + } else { + o = format(q"┃+ %s +
++┃", + obj.metainfo.is_a, + _txt + ); + } + return o; + } + string quote_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + ) { + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = quote(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) quote_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0].to!string; + string[] _endnotes = t[1]; + string o = quote(_txt, obj, doc_matters); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + string group(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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"); + _txt = font_face(_txt); + string o; + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃+ %s +
++ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) ? "" + : ((obj.metainfo.object_number.empty) ? "" + : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.identifier, + _txt + ); + } else { + o = format(q"┃+ %s +
++┃", + obj.metainfo.is_a, + _txt + ); + } + return o; + } + string group_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = group(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) group_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0].to!string; + string[] _endnotes = t[1]; + string o = group(_txt, obj, doc_matters); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + string block(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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"); + _txt = font_face(_txt); + string o; + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃+ %s +
++ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) ? "" + : ((obj.metainfo.object_number.empty) ? "" + : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.identifier, + _txt.stripRight + ); + } else { + o = format(q"┃%s
++┃", + obj.metainfo.is_a, + _txt.stripRight + ); + } + return o; + } + string block_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = block(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) block_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0].to!string; + string[] _endnotes = t[1]; + string o = block(_txt, obj, doc_matters); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + string verse(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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"); + _txt = font_face(_txt); + string o; + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃%s
++ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.identifier, + _txt + ); + } else { + o = format(q"┃%s
++┃", + obj.metainfo.is_a, + _txt + ); + } + return o; + } + string verse_scroll(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); + string o = verse(_txt, obj, doc_matters); + return o; + } + Tuple!(string, string[]) verse_seg(O,M)( + string _txt, + const O obj, + M doc_matters, + string _suffix = ".html", + string _xml_type = "html", + ) { + Tuple!(string, string[]) t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); + _txt = t[0].to!string; + string[] _endnotes = t[1]; + string o = verse(_txt, obj, doc_matters); + Tuple!(string, string[]) u = tuple( + o, + _endnotes, + ); + return u; + } + Tuple!(string, string) 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 ~= "%s
+"; + foreach(col_idx, cell; _table_cols) { + if ((_table_cols.length == 1) + && (_table_rows.length <= row_idx+2)) { + _tablenote ~= cell; + } else { + string _col_is = (row_idx == 0 && obj.table.heading) ? "th" : "td"; + string _align = ("style=\"text-align:" + ~ ((obj.table.column_aligns[col_idx] == "l") + ? "left\"" : "right\"")); + _table ~= "<" ~ _col_is ~ " width=\"" ~ obj.table.column_widths[col_idx].to!string ~ "%\" " ~ _align ~ ">"; + _table ~= cell; + _table ~= "" ~ _col_is ~ ">"; + } + } + _table ~= " "; + } + Tuple!(string, string) t = tuple( + _table, + _tablenote, + ); + return t; + } + string table(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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"); + string tags = _xhtml_anchor_tags(obj); + _txt = font_face(_txt); + auto t = tablarize(_txt, obj); + _txt = t[0]; + string _note = t[1]; + string o; + o = format(q"┃+ +┃", + obj.metainfo.object_number, + (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.object_number, + tags, + _txt, + _note + ); + return o; + } + string code(O,M)( + string _txt, + const O obj, + M doc_matters, + ) { + 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 o; + string codelines(string _txt) { + string _codelines; + if (obj.code_block.linenumbers) { + string[] _block_lines = (_txt).split(rgx.br_linebreaks_newlines); + _codelines = "%s +
+ %s +
+ %s + +\n"; + foreach (k, _line; _block_lines) { + if (k == 1) { + _codelines ~= format(q"┃"; + } else { + _codelines = "%s + ┃", + _line, + ); + } else { + _codelines ~= format(q"┃%s + ┃", + _line, + ); + } + } + _codelines ~= "\n"; + _codelines ~= _txt; + _codelines ~= ""; + } + return _codelines; + } + if (!(obj.metainfo.identifier.empty)) { + o = format(q"┃+ +┃", + obj.metainfo.identifier, + (doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier), + obj.metainfo.is_a, + obj.metainfo.identifier, + codelines(_txt) + ); + } else { + o = format(q"┃%s
++┃", + obj.metainfo.is_a, + codelines(_txt) + ); + } + return o; + } + } +} diff --git a/src/sisudoc/io_out/xmls_css.d b/src/sisudoc/io_out/xmls_css.d new file mode 100644 index 0000000..e9f38e6 --- /dev/null +++ b/src/sisudoc/io_out/xmls_css.d @@ -0,0 +1,4451 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + default css settings ++/ +module sisudoc.io_out.xmls_css; +@safe: +template spineCss() { + import std.format; + auto spineCss(M)(M doc_matters) { + string _css_indent = format(q"┃ +/* indent */ +p.norm { } +p.i1 { padding-left : 1em; } +p.i2 { padding-left : 2em; } +p.i3 { padding-left : 3em; } +p.i4 { padding-left : 4em; } +p.i5 { padding-left : 5em; } +p.i6 { padding-left : 6em; } +p.i7 { padding-left : 7em; } +p.i8 { padding-left : 8em; } +p.i9 { padding-left : 9em; } +/* hanging indent */ +p[indent="h0i0"] { + padding-left : 0em; + text-indent : 0em; +} +p[indent="h0i1"] { + padding-left : 1em; + text-indent : -1em; +} +p[indent="h0i2"] { + padding-left : 2em; + text-indent : -2em; +} +p[indent="h0i3"] { + padding-left : 3em; + text-indent : -3em; +} +p[indent="h0i4"] { + padding-left : 4em; + text-indent : -4em; +} +p[indent="h0i5"] { + padding-left : 5em; + text-indent : -5em; +} +p[indent="h0i6"] { + padding-left : 6em; + text-indent : -6em; +} +p[indent="h0i7"] { + padding-left : 7em; + text-indent : -7em; +} +p[indent="h0i8"] { + padding-left : 8em; + text-indent : -8em; +} +p[indent="h0i9"] { + padding-left : 9em; + text-indent : -9em; +} +p[indent="h1i0"] { + padding-left : 0em; + text-indent : 1em; +} +p[indent="h1i1"] { + padding-left : 1em; + text-indent : 0em; +} +p[indent="h1i2"] { + padding-left : 2em; + text-indent : -1em; +} +p[indent="h1i3"] { + padding-left : 3em; + text-indent : -2em; +} +p[indent="h1i4"] { + padding-left : 4em; + text-indent : -3em; +} +p[indent="h1i5"] { + padding-left : 5em; + text-indent : -4em; +} +p[indent="h1i6"] { + padding-left : 6em; + text-indent : -5em; +} +p[indent="h1i7"] { + padding-left : 7em; + text-indent : -6em; +} +p[indent="h1i8"] { + padding-left : 8em; + text-indent : -7em; +} +p[indent="h1i9"] { + padding-left : 9em; + text-indent : -8em; +} +p[indent="h2i0"] { + padding-left : 0em; + text-indent : 2em; +} +p[indent="h2i1"] { + padding-left : 1em; + text-indent : 1em; +} +p[indent="h2i2"] { + padding-left : 2em; + text-indent : 0em; +} +p[indent="h2i3"] { + padding-left : 3em; + text-indent : -1em; +} +p[indent="h2i4"] { + padding-left : 4em; + text-indent : -2em; +} +p[indent="h2i5"] { + padding-left : 5em; + text-indent : -3em; +} +p[indent="h2i6"] { + padding-left : 6em; + text-indent : -4em; +} +p[indent="h2i7"] { + padding-left : 7em; + text-indent : -5em; +} +p[indent="h2i8"] { + padding-left : 8em; + text-indent : -6em; +} +p[indent="h2i9"] { + padding-left : 9em; + text-indent : -7em; +} +p[indent="h3i0"] { + padding-left : 0em; + text-indent : 3em; +} +p[indent="h3i1"] { + padding-left : 1em; + text-indent : 2em; +} +p[indent="h3i2"] { + padding-left : 2em; + text-indent : 1em; +} +p[indent="h3i3"] { + padding-left : 3em; + text-indent : 0em; +} +p[indent="h3i4"] { + padding-left : 4em; + text-indent : -1em; +} +p[indent="h3i5"] { + padding-left : 5em; + text-indent : -2em; +} +p[indent="h3i6"] { + padding-left : 6em; + text-indent : -3em; +} +p[indent="h3i7"] { + padding-left : 7em; + text-indent : -4em; +} +p[indent="h3i8"] { + padding-left : 8em; + text-indent : -5em; +} +p[indent="h3i9"] { + padding-left : 9em; + text-indent : -6em; +} +p[indent="h4i0"] { + padding-left : 0em; + text-indent : 4em; +} +p[indent="h4i1"] { + padding-left : 1em; + text-indent : 3em; +} +p[indent="h4i2"] { + padding-left : 2em; + text-indent : 2em; +} +p[indent="h4i3"] { + padding-left : 3em; + text-indent : 1em; +} +p[indent="h4i4"] { + padding-left : 4em; + text-indent : 0em; +} +p[indent="h4i5"] { + padding-left : 5em; + text-indent : -1em; +} +p[indent="h4i6"] { + padding-left : 6em; + text-indent : -2em; +} +p[indent="h4i7"] { + padding-left : 7em; + text-indent : -3em; +} +p[indent="h4i8"] { + padding-left : 8em; + text-indent : -4em; +} +p[indent="h4i9"] { + padding-left : 9em; + text-indent : -5em; +} +p[indent="h5i0"] { + padding-left : 0em; + text-indent : 5em; +} +p[indent="h5i1"] { + padding-left : 1em; + text-indent : 4em; +} +p[indent="h5i2"] { + padding-left : 2em; + text-indent : 3em; +} +p[indent="h5i3"] { + padding-left : 3em; + text-indent : 2em; +} +p[indent="h5i4"] { + padding-left : 4em; + text-indent : 1em; +} +p[indent="h5i5"] { + padding-left : 5em; + text-indent : 0em; +} +p[indent="h5i6"] { + padding-left : 6em; + text-indent : -1em; +} +p[indent="h5i7"] { + padding-left : 7em; + text-indent : -2em; +} +p[indent="h5i8"] { + padding-left : 8em; + text-indent : -3em; +} +p[indent="h5i9"] { + padding-left : 9em; + text-indent : -4em; +} +p[indent="h6i0"] { + padding-left : 0em; + text-indent : 6em; +} +p[indent="h6i1"] { + padding-left : 1em; + text-indent : 5em; +} +p[indent="h6i2"] { + padding-left : 2em; + text-indent : 4em; +} +p[indent="h6i3"] { + padding-left : 3em; + text-indent : 3em; +} +p[indent="h6i4"] { + padding-left : 4em; + text-indent : 2em; +} +p[indent="h6i5"] { + padding-left : 5em; + text-indent : 1em; +} +p[indent="h6i6"] { + padding-left : 6em; + text-indent : 0em; +} +p[indent="h6i7"] { + padding-left : 7em; + text-indent : -1em; +} +p[indent="h6i8"] { + padding-left : 8em; + text-indent : -2em; +} +p[indent="h6i9"] { + padding-left : 9em; + text-indent : -3em; +} +p[indent="h7i0"] { + padding-left : 0em; + text-indent : 7em; +} +p[indent="h7i1"] { + padding-left : 1em; + text-indent : 6em; +} +p[indent="h7i2"] { + padding-left : 2em; + text-indent : 5em; +} +p[indent="h7i3"] { + padding-left : 3em; + text-indent : 4em; +} +p[indent="h7i4"] { + padding-left : 4em; + text-indent : 3em; +} +p[indent="h7i5"] { + padding-left : 5em; + text-indent : 2em; +} +p[indent="h7i6"] { + padding-left : 6em; + text-indent : 1em; +} +p[indent="h7i7"] { + padding-left : 7em; + text-indent : 0em; +} +p[indent="h7i8"] { + padding-left : 8em; + text-indent : -1em; +} +p[indent="h7i9"] { + padding-left : 9em; + text-indent : -2em; +} +p[indent="h8i0"] { + padding-left : 0em; + text-indent : 8em; +} +p[indent="h8i1"] { + padding-left : 1em; + text-indent : 7em; +} +p[indent="h8i2"] { + padding-left : 2em; + text-indent : 6em; +} +p[indent="h8i3"] { + padding-left : 3em; + text-indent : 5em; +} +p[indent="h8i4"] { + padding-left : 4em; + text-indent : 4em; +} +p[indent="h8i5"] { + padding-left : 5em; + text-indent : 3em; +} +p[indent="h8i6"] { + padding-left : 6em; + text-indent : 2em; +} +p[indent="h8i7"] { + padding-left : 7em; + text-indent : 1em; +} +p[indent="h8i8"] { + padding-left : 8em; + text-indent : 0em; +} +p[indent="h8i9"] { + padding-left : 9em; + text-indent : -1em; +} +p[indent="h9i0"] { + padding-left : 0em; + text-indent : 9em; +} +p[indent="h9i1"] { + padding-left : 1em; + text-indent : 8em; +} +p[indent="h9i2"] { + padding-left : 2em; + text-indent : 7em; +} +p[indent="h9i3"] { + padding-left : 3em; + text-indent : 6em; +} +p[indent="h9i4"] { + padding-left : 4em; + text-indent : 5em; +} +p[indent="h9i5"] { + padding-left : 5em; + text-indent : 4em; +} +p[indent="h9i6"] { + padding-left : 6em; + text-indent : 3em; +} +p[indent="h9i7"] { + padding-left : 7em; + text-indent : 2em; +} +p[indent="h9i8"] { + padding-left : 8em; + text-indent : 1em; +} +p[indent="h9i9"] { + padding-left : 9em; + text-indent : 0em; +} +┃"); +string _color_ocn_light = (doc_matters.opt.action.ocn_hidden) ? "#FFFFFF" : "#777777"; +string _color_ocn_dark = (doc_matters.opt.action.ocn_hidden) ? "#000000" : "#BBBBBB"; + string _css_light_html_seg = 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%%; +} +.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 : #CCCCCC; + fill : #333333; + box-shadow : 0 2px 5px #AAAAAA 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 : #CCCCCC; + 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 : #333333; +} +.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 : #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; +} +┃", + _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; +} +┃", + _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; +} +┃", + _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; +} +┃", + _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 new file mode 100644 index 0000000..5330799 --- /dev/null +++ b/src/sisudoc/meta/conf_make_meta_json.d @@ -0,0 +1,695 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + json headers%s
+
+ extract json header return json ++/ +module sisudoc.meta.conf_make_meta_json; +@safe: +static template contentJSONtoSpineStruct() { + import + std.algorithm, + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.utf, + std.conv : to; + import + sisudoc.meta.conf_make_meta_structs, + sisudoc.meta.conf_make_meta_json, + sisudoc.meta.defaults, + sisudoc.meta.rgx; + 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 new file mode 100644 index 0000000..5322220 --- /dev/null +++ b/src/sisudoc/meta/conf_make_meta_structs.d @@ -0,0 +1,316 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.conf_make_meta_structs; +@safe: +import + std.exception, + std.json, + std.path, + std.regex, + std.stdio, + std.string, + std.typecons, + std.utf, + std.conv : to; +import + sisudoc.meta.defaults, + sisudoc.meta.rgx_yaml, + sisudoc.meta.rgx; +mixin spineRgxIn; +static auto rgx = RgxI(); +mixin spineRgxYamlTags; +static auto rgx_y = RgxYaml(); +mixin InternalMarkup; +static auto mkup = InlineMarkup(); +string url_markup(string line) { + string line_ = line + .replaceAll( + rgx.smid_inline_link_markup_regular, + ("$1" + ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c + ~ mkup.url_o ~ "$3" ~ mkup.url_c + ) // ("$1{ $2 }$3$4") + ) + .replaceAll( + rgx.smid_inline_link_naked_url, + ("$1" + ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ) // ("$1{ $2 }$2$3") + ) + .replaceAll( + rgx.arr_delimiter, + mkup.br_line + ); + return line_; +} +struct ConfCompositeMakeStr { + string doc_type = "book"; // book, article + string breaks; + string bold; + string cover_image; + string css; + string emphasis; + string[] footer; + string[] headings; + string[] home_button_image; + string home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├" + ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├" + ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├"; + string italics; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int auto_num_depth = 2; + string[][] substitute; + string texpdf_font; +} +@trusted struct confCompositeMakeBuild { + string[] bold(string _mk) { + string[] _out; + if (_mk) { + _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "*{$1}*", "$1"]; + } + return _out; + } + string doc_type(string _mk) { + return _mk; + } + string breaks(string _mk) { + return _mk; + } + string cover_image(string _mk) { + return _mk; + } + string css(string _mk) { + return _mk; + } + string[] emphasis(string _mk) { + string[] _out; + if (_mk) { + _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "!{$1}!", "$1" ]; + } + return _out; + } + string[] footer(string[] _mk) { + string line_; + string[] _mk2; + foreach (line; _mk) { + _mk2 ~= url_markup(line); + } + return _mk2; + } + string[] headings(string[] _mk) { + return _mk; + } + string[] home_button_image(string[] _mk) { + return _mk; + } + string home_button_text(string _mk) { + return url_markup(_mk); + } + string[] italics(string _mk) { + string[] _out; + if (_mk) { + _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "/{$1}/", "$1" ]; + } + return _out; + } + string auto_num_top_at_level(string _mk) { + return _mk; + } + int auto_num_top_lv(int _mk) { + return _mk; + } + int auto_num_depth(int _mk) { + return _mk; + } + string[][] substitute(string[][] _mk) { + return _mk; + } + string texpdf_font(string _mk) { + return _mk; + } +} +struct ConfCompositeMakeInit { + string doc_type; + string breaks; + string cover_image; + string css; + string[] bold; + string[] emphasis; + string[] footer; + string[] headings; + string[] home_button_image; + string home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├" + ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├" + ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├"; + string[] italics; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int auto_num_depth = 2; + string[][] substitute; + string texpdf_font; +} +struct ConfCompositeSiteLocal { + string w_srv_http; + string w_srv_host; + string w_srv_data_http; // if not set same as webserv_http + string w_srv_data_host; // if not set same as webserv_host + string w_srv_data_root_part; + string w_srv_data_root_url; + string w_srv_data_root_url_html; + string w_srv_data_root_path; + string w_srv_images_root_part; + // string w_srv_url_doc_path; + string w_srv_cgi_search_form_title; + string w_srv_cgi_http; // if not set same as webserv_http + string w_srv_cgi_host; // if not set same as webserv_host + string w_srv_cgi_bin_subpath; + string w_srv_cgi_bin_path; + string w_srv_cgi_search_script; + string w_srv_cgi_search_script_raw_fn_d; + string w_srv_cgi_port; + string w_srv_cgi_user; + string w_srv_cgi_action; + string w_srv_cgi_bin_url; + string w_srv_db_sqlite_filename; + string w_srv_db_sqlite_path; + // string w_srv_db_pg; + string w_srv_db_pg_table; + string w_srv_db_pg_user; + // string webserv_cgi_file_links; + string output_path; + string processing_path; + string processing_dir; + string processing_concord_max; + string flag_act0; + string flag_act1; + string flag_act2; + string flag_act3; + string flag_act4; + string flag_act5; + string flag_act6; + string flag_act7; + string flag_act8; + string flag_act9; + string[] set_papersize; + string set_text_wrap; + string set_emphasis; + string set_language; + string set_digest; + string permission_share_source; + string search_flag; + string search_action; + string search_db; + string search_title; +} +struct MetaComposite { + string classify_dewey; + string classify_keywords; + string classify_loc; + string classify_subject; + string classify_topic_register; + string[] classify_topic_register_arr; + string[] classify_topic_register_expanded_arr; // experimental use in sqlite topics table + string[] creator_author_arr; + string creator_author; + string creator_author_surname_fn; + string creator_author_surname; + string creator_author_email; + string creator_illustrator; + string creator_translator; + string date_added_to_site; + string date_available; + string date_created; + string date_issued; + string date_modified; + string date_published; + string date_valid; + string identifier_isbn; + string identifier_oclc; + string identifier_pg; + string language_document; + string language_document_char; + string links; + string notes_abstract; + string notes_description; + string notes_summary; + string original_language; + string original_language_char; + string original_publisher; + string original_source; + string original_title; + string publisher; + string rights_copyright; + string rights_copyright_audio; + string rights_copyright_cover; + string rights_copyright_illustrations; + string rights_copyright_photographs; + string rights_copyright_text; + string rights_copyright_translation; + string rights_copyright_video; + string rights_license; + string title_edition; + string title_full; + string title_language; + string title_main; + string title_note; + string title_short; + string title_sub; + string title_subtitle; +} +struct ConfComposite { + MetaComposite meta; + ConfCompositeMakeInit make; + ConfCompositeMakeStr make_str; + ConfCompositeSiteLocal conf; +} +JSONValue config_jsonstr = `{ +}`; diff --git a/src/sisudoc/meta/conf_make_meta_yaml.d b/src/sisudoc/meta/conf_make_meta_yaml.d new file mode 100644 index 0000000..ac97a21 --- /dev/null +++ b/src/sisudoc/meta/conf_make_meta_yaml.d @@ -0,0 +1,1277 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + yaml headers
+ extract yaml header return struct ++/ +module sisudoc.meta.conf_make_meta_yaml; +@safe: +template contentYAMLtoSpineStruct() { + import + std.algorithm, + std.array, + std.exception, + std.path, + std.regex, + std.stdio, + std.string, + std.typecons, + std.utf, + std.conv : to; + import + sisudoc.meta.conf_make_meta_structs, + sisudoc.meta.defaults, + sisudoc.meta.rgx_yaml, + sisudoc.meta.rgx; + ConfComposite _struct_composite; + @system auto contentYAMLtoSpineStruct(C,Y,M,O,Cfg)( + C _struct_composite, + Y _yaml, + M _manifested, + O _opt_action, + Cfg _cfg, + string _identifier + ) { + mixin spineRgxIn; + static auto rgx = RgxI(); + mixin spineRgxYamlTags; + static auto rgx_y = RgxYaml(); + string check_input_markup()( + string _txt, + ) { + _txt = _txt + .replaceAll(regex(r"\\"), mkup.br_line_inline) + .strip; + return _txt; + } + confCompositeMakeBuild _mk; + if (_identifier != "header") { // called only once per run anyway + /+ conf ------------------------------------------------------------------- +/ + /+ + _cfg. build defaults (else program runtime defaults) + local_site_configuration defaults + command line overrides + +/ + { + if (_opt_action.webserver_http.length > 0) { + _struct_composite.conf.w_srv_http + = _opt_action.webserver_http; + } else { + _struct_composite.conf.w_srv_http + = (_cfg.http_request_type.empty) + ? "http" + : _cfg.http_request_type; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("http" in _yaml["webserv"] + && _yaml["webserv"]["http"].type.string + && _yaml["webserv"]["http"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_http + = _yaml["webserv"]["http"].get!string; + } + } + } + if (_opt_action.cgi_search_title.length > 0) { + _struct_composite.conf.w_srv_cgi_search_form_title + = _opt_action.cgi_search_title; + } else { + _struct_composite.conf.w_srv_cgi_search_form_title + = (_cfg.cgi_search_form_title.empty) + ? "≅ SiSU spine search form" + : _cfg.cgi_search_form_title; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("cgi_search_form_title" in _yaml["webserv"] + && _yaml["webserv"]["cgi_search_form_title"].type.string + && _yaml["webserv"]["cgi_search_form_title"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_search_form_title + = _yaml["webserv"]["cgi_search_form_title"].get!string; + } + } + } + if (_opt_action.cgi_sqlite_search_filename.length > 0) { + _struct_composite.conf.w_srv_cgi_search_script + = _opt_action.cgi_sqlite_search_filename; + } else { + _struct_composite.conf.w_srv_cgi_search_script + = (_cfg.cgi_filename.empty) + ? "spine_search" + : _cfg.cgi_filename; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("cgi_search_script" in _yaml["webserv"] + && _yaml["webserv"]["cgi_search_script"].type.string + && _yaml["webserv"]["cgi_search_script"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_search_script + = _yaml["webserv"]["cgi_search_script"].get!string; + } + } + } + if (_opt_action.sqliteDB_filename.length > 0) { + _struct_composite.conf.w_srv_db_sqlite_filename + = _opt_action.sqliteDB_filename; + } else { + _struct_composite.conf.w_srv_db_sqlite_filename + = (_cfg.db_sqlite_filename.empty) + ? "spine.search.db" + : _cfg.db_sqlite_filename; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("db_sqlite_filename" in _yaml["webserv"] + && _yaml["webserv"]["db_sqlite_filename"].type.string + && _yaml["webserv"]["db_sqlite_filename"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_db_sqlite_filename + = _yaml["webserv"]["db_sqlite_filename"].get!string; + } + } + } + if (_opt_action.sqliteDB_path.length > 0) { + _struct_composite.conf.w_srv_db_sqlite_path + = _opt_action.sqliteDB_path; + } else { + _struct_composite.conf.w_srv_db_sqlite_path + = (_cfg.db_sqlite_path.empty) + ? "/var/www/sqlite" + : _cfg.db_sqlite_path; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("db_sqlite_path" in _yaml["webserv"] + && _yaml["webserv"]["db_sqlite_path"].type.string + && _yaml["webserv"]["db_sqlite_path"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_db_sqlite_path + = _yaml["webserv"]["db_sqlite_path"].get!string; + } + } + } + if (_opt_action.cgi_url_action.length > 0) { + _struct_composite.conf.w_srv_cgi_action + = _opt_action.cgi_url_action; + } else { + _struct_composite.conf.w_srv_cgi_action + = (_cfg.www_url_doc_root.empty) + ? "http://locahost" // "https://sisudoc.org" + : _cfg.www_url_doc_root; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("cgi_action" in _yaml["webserv"] + && _yaml["webserv"]["cgi_action"].type.string + && _yaml["webserv"]["cgi_action"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_action + = _yaml["webserv"]["cgi_action"].get!string; + } else if (_opt_action.cgi_sqlite_search_filename.length > 0) { + _struct_composite.conf.w_srv_cgi_action + = _struct_composite.conf.w_srv_cgi_bin_url ~ "/" ~ _opt_action.cgi_sqlite_search_filename; + } + } + } + if (!(_struct_composite.conf.output_path)) { + _struct_composite.conf.output_path = ((_manifested.output.path).asNormalizedPath).array; + } { + if (_opt_action.output_dir_set.length > 0) { + _struct_composite.conf.output_path + = (_opt_action.output_dir_set.asNormalizedPath).array; + } else { + _struct_composite.conf.output_path + = (_cfg.processing_path_doc_root.empty) + ? "/srv/www/spine" + : _cfg.processing_path_doc_root; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if (_yaml["output"].type.mapping + && _yaml["output"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("path" in _yaml["output"] + && _yaml["output"]["path"].type.string + && _yaml["output"]["path"].tag.match(rgx_y.yaml_tag_is_str) + ) { + if (_manifested.output.path == _manifested.env.pwd + && _yaml["output"]["path"].get!string.length > 0 + ) { + _struct_composite.conf.output_path = (((_yaml["output"]["path"].get!string).expandTilde).asNormalizedPath).array; + } + } + } + } + } + if (_opt_action.webserver_host_doc_root.length > 0) { // same as output_path immediately above, resolve FIX REMOVE + _struct_composite.conf.w_srv_data_root_path + = _opt_action.webserver_host_doc_root; + } else { + _struct_composite.conf.w_srv_data_root_path + = (_cfg.processing_path_doc_root.empty) + ? "/var/www/spine" + : _cfg.processing_path_doc_root; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("data_root_path" in _yaml["webserv"] + && _yaml["webserv"]["data_root_path"].type.string + && _yaml["webserv"]["data_root_path"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_root_path + = _yaml["webserv"]["data_root_path"].get!string; + } + } + } + } + if (_opt_action.cgi_bin_root.length > 0) { + _struct_composite.conf.w_srv_cgi_bin_path + = _opt_action.cgi_bin_root; + } else { + _struct_composite.conf.w_srv_cgi_bin_path + = (_cfg.cgi_bin_root.empty) + ? "/var/www/cgi/cgi-bin" + : _cfg.cgi_bin_root; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("cgi_bin_path" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_path"].type.string + && _yaml["webserv"]["cgi_bin_path"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_bin_path + = _yaml["webserv"]["cgi_bin_path"].get!string; + } + } + } + { _struct_composite.conf.w_srv_data_root_part + = ""; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("data_root_part" in _yaml["webserv"] + && _yaml["webserv"]["data_root_part"].type.string + && _yaml["webserv"]["data_root_part"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_root_part = _yaml["webserv"]["data_root_part"].get!string; + } + } + } + { _struct_composite.conf.w_srv_images_root_part + = "image"; + if (("webserv" in _yaml && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { + if ("images_root_part" in _yaml["webserv"] + && _yaml["webserv"]["images_root_part"].type.string + && _yaml["webserv"]["images_root_part"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_images_root_part = _yaml["webserv"]["images_root_part"].get!string; + } + } + } + } + if (("webserv" in _yaml + && _yaml["webserv"].type.sequence) + && (_yaml["webserv"].type.mapping + && _yaml["webserv"].tag.match(rgx_y.yaml_tag_is_map)) + ) { // cannot be used as is with opt_action FIX look at remaining, decide what to do later + if ("data_http" in _yaml["webserv"] + && _yaml["webserv"]["data_http"].type.string + && _yaml["webserv"]["data_http"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_http = _yaml["webserv"]["data_http"].get!string; + } + // if (_opt_action.*.length > 0) { + if ("cgi_http" in _yaml["webserv"] + && _yaml["webserv"]["cgi_http"].type.string + && _yaml["webserv"]["cgi_http"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_http = _yaml["webserv"]["cgi_http"].get!string; + } + // if (_opt_action.*.length > 0) { + if ("host" in _yaml["webserv"] + && _yaml["webserv"]["host"].type.string + && _yaml["webserv"]["host"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_host = _yaml["webserv"]["host"].get!string; + } + if ("data_root_url" in _yaml["webserv"] + && _yaml["webserv"]["data_root_url"].type.string + && _yaml["webserv"]["data_root_url"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; + _struct_composite.conf.w_srv_data_root_url_html = + _yaml["webserv"]["data_root_url"].get!string + ~ _struct_composite.conf.w_srv_data_root_part ~ "/" + ~ _manifested.src.language ~ "/" + ~ "html"; + } else { + _struct_composite.conf.w_srv_data_root_url = _struct_composite.conf.w_srv_data_root_part; + _struct_composite.conf.w_srv_data_root_url_html = + _struct_composite.conf.w_srv_data_root_part ~ "/" + ~ _manifested.src.language ~ "/" + ~ "html"; + } + if ("cgi_host" in _yaml["webserv"] + && _yaml["webserv"]["cgi_host"].type.string + && _yaml["webserv"]["cgi_host"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_host = _yaml["webserv"]["cgi_host"].get!string; + } else { // composite construct + _struct_composite.conf.w_srv_cgi_host = _struct_composite.conf.w_srv_host; + } + if ("cgi_bin_subpath" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_subpath"].type.string + && _yaml["webserv"]["cgi_bin_subpath"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_bin_subpath = _yaml["webserv"]["cgi_bin_subpath"].get!string; + } + if ("cgi_port" in _yaml["webserv"] + && _yaml["webserv"]["cgi_port"].type.string + && _yaml["webserv"]["cgi_port"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_port = _yaml["webserv"]["cgi_port"].get!string; + } + if ("cgi_user" in _yaml["webserv"] + && _yaml["webserv"]["cgi_user"].type.string + && _yaml["webserv"]["cgi_user"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_user = _yaml["webserv"]["cgi_user"].get!string; + } + if ("cgi_bin_url" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_url"].type.string + && _yaml["webserv"]["cgi_bin_url"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_bin_url = _yaml["webserv"]["cgi_bin_url"].get!string; + } else { + _struct_composite.conf.w_srv_cgi_bin_url = + (_struct_composite.conf.w_srv_cgi_http.empty) + ? _struct_composite.conf.w_srv_http + :_struct_composite.conf.w_srv_cgi_http + ~ "://" + ~ (_struct_composite.conf.w_srv_cgi_host.empty) + ? _struct_composite.conf.w_srv_cgi_host + : _struct_composite.conf.w_srv_host + ~ _struct_composite.conf.w_srv_cgi_bin_subpath; + } + // if ("cgi_file_links" in _yaml["webserv"] + // && _yaml["webserv"]["cgi_file_links"].type.string + // && _yaml["webserv"]["cgi_file_links"].tag.match(rgx_y.yaml_tag_is_str) + // ) { + // _struct_composite.conf.w_srv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string; + // } + } + // make (in: conf, make, meta)? + if ("processing" in _yaml + && _yaml["processing"].type.sequence + ) { + if (_yaml["processing"].type.mapping + && _yaml["processing"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("concord_max" in _yaml["processing"] + && _yaml["processing"]["concord_max"].type.string + && _yaml["processing"]["concord_max"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.processing_concord_max = _yaml["processing"]["concord_max"].get!string; + } + } + } + if ("flag" in _yaml + && _yaml["flag"].type.sequence + ) { + if (_yaml["flag"].type.mapping + && _yaml["flag"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("act0" in _yaml["flag"] + && _yaml["flag"]["act0"].type.string + && _yaml["flag"]["act0"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act0 = _yaml["flag"]["act0"].get!string; + } + if ("act1" in _yaml["flag"] + && _yaml["flag"]["act1"].type.string + && _yaml["flag"]["act1"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act1 = _yaml["flag"]["act1"].get!string; + } + if ("act2" in _yaml["flag"] + && _yaml["flag"]["act2"].type.string + && _yaml["flag"]["act2"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act2 = _yaml["flag"]["act2"].get!string; + } + if ("act3" in _yaml["flag"] + && _yaml["flag"]["act3"].type.string + && _yaml["flag"]["act3"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act3 = _yaml["flag"]["act3"].get!string; + } + if ("act4" in _yaml["flag"] + && _yaml["flag"]["act4"].type.string + && _yaml["flag"]["act4"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act4 = _yaml["flag"]["act4"].get!string; + } + if ("act5" in _yaml["flag"] + && _yaml["flag"]["act5"].type.string + && _yaml["flag"]["act5"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act5 = _yaml["flag"]["act5"].get!string; + } + if ("act6" in _yaml["flag"] + && _yaml["flag"]["act6"].type.string + && _yaml["flag"]["act6"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act6 = _yaml["flag"]["act6"].get!string; + } + if ("act7" in _yaml["flag"] + && _yaml["flag"]["act7"].type.string + && _yaml["flag"]["act7"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act7 = _yaml["flag"]["act7"].get!string; + } + if ("act8" in _yaml["flag"] + && _yaml["flag"]["act8"].type.string + && _yaml["flag"]["act8"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act8 = _yaml["flag"]["act8"].get!string; + } + if ("act9" in _yaml["flag"] + && _yaml["flag"]["act9"].type.string + && _yaml["flag"]["act9"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.flag_act9 = _yaml["flag"]["act9"].get!string; + } + } + } + string[] selected_papersize(string _sizes_str) { + string[] _sizes = _sizes_str.split(regex(r"\s*,\s*")); + string[] _selected_sizes; + foreach (_size; _sizes) { + switch (_size) { + case "a4": + _selected_sizes ~= "a4.portrait"; + _selected_sizes ~= "a4.landscape"; + break; + case "a4.portrait": + _selected_sizes ~= _size; + break; + case "a4.landscape": + _selected_sizes ~= _size; + break; + case "b4": + _selected_sizes ~= "b4.portrait"; + _selected_sizes ~= "b4.landscape"; + break; + case "b4.portrait": + _selected_sizes ~= _size; + break; + case "b4.landscape": + _selected_sizes ~= _size; + break; + case "a5": + _selected_sizes ~= "a5.portrait"; + _selected_sizes ~= "a5.landscape"; + break; + case "a5.portrait": + _selected_sizes ~= _size; + break; + case "a5.landscape": + _selected_sizes ~= _size; + break; + case "letter": + _selected_sizes ~= "letter.portrait"; + _selected_sizes ~= "letter.landscape"; + break; + case "letter.portrait": + _selected_sizes ~= _size; + break; + case "letter.landscape": + _selected_sizes ~= _size; + break; + case "legal": + _selected_sizes ~= "legal.portrait"; + _selected_sizes ~= "legal.landscape"; + break; + case "legal.portrait": + _selected_sizes ~= _size; + break; + case "legal.landscape": + _selected_sizes ~= _size; + break; + default: break; + } + } + return _selected_sizes; + } + string _set_papersize; + if (_opt_action.latex_papersize.length > 0) { + _set_papersize + = _opt_action.latex_papersize; + } else { + _set_papersize + = (_cfg.default_papersize.empty) + ? "a4,letter.portrait" + : _cfg.default_papersize; + if ("papersize" in _yaml["default"] + && _yaml["default"]["papersize"].type.string + && _yaml["default"]["papersize"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _set_papersize + = _yaml["default"]["papersize"].get!string; + } + } + _struct_composite.conf.set_papersize = selected_papersize(_set_papersize); + if ( + "default" in _yaml + && _yaml["default"].type.sequence + && _yaml["default"].type.mapping + && _yaml["default"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("text_wrap" in _yaml["default"] + && _yaml["default"]["text_wrap"].type.string + && _yaml["default"]["text_wrap"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.set_text_wrap = _yaml["default"]["text_wrap"].get!string; + } + if ("emphasis" in _yaml["default"] + && _yaml["default"]["emphasis"].type.string + && _yaml["default"]["emphasis"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.set_emphasis = _yaml["default"]["emphasis"].get!string; + } + if ("language" in _yaml["default"] + && _yaml["default"]["language"].type.string + && _yaml["default"]["language"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.set_language = _yaml["default"]["language"].get!string; + } + if ("digest" in _yaml["default"] + && _yaml["default"]["digest"].type.string + && _yaml["default"]["digest"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.set_digest = _yaml["default"]["digest"].get!string; + } + } + if ("search" in _yaml + && _yaml["search"].type.sequence + ) { + if (_yaml["search"].type.mapping + && _yaml["search"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("flag" in _yaml["search"] + && _yaml["search"]["flag"].type.string + && _yaml["search"]["flag"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.search_flag = _yaml["search"]["flag"].get!string; + } + if ("action" in _yaml["search"] + && _yaml["search"]["action"].type.string + && _yaml["search"]["action"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.search_action = _yaml["search"]["action"].get!string; + } + if ("db" in _yaml["search"] + && _yaml["search"]["db"].type.string + && _yaml["search"]["db"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.search_db = _yaml["search"]["db"].get!string; + } + if ("title" in _yaml["search"] + && _yaml["search"]["title"].type.string + && _yaml["search"]["title"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.conf.search_title = _yaml["search"]["title"].get!string; + } + } + } + } else { + /+ make ------------------------------------------------------------------- +/ + if ("make" in _yaml + && _yaml["make"].type.sequence + ) { + if (_yaml["make"].type.mapping + && _yaml["make"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("doc_type" in _yaml["make"] + && _yaml["make"]["doc_type"].type.string + && _yaml["make"]["doc_type"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.doc_type = _yaml["make"]["doc_type"].get!string; + } + if ("breaks" in _yaml["make"] + && _yaml["make"]["breaks"].type.string + && _yaml["make"]["breaks"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.breaks = _yaml["make"]["breaks"].get!string; + } + if ("bold" in _yaml["make"] + && _yaml["make"]["bold"].type.string + && _yaml["make"]["bold"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.bold = _yaml["make"]["bold"].get!string; + } + if ("cover_image" in _yaml["make"] + && _yaml["make"]["cover_image"].type.string + && _yaml["make"]["cover_image"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.cover_image = _yaml["make"]["cover_image"].get!string; + } + if ("css" in _yaml["make"] + && _yaml["make"]["css"].type.string + && _yaml["make"]["css"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.css = _yaml["make"]["css"].get!string; + } + if ("emphasis" in _yaml["make"] + && _yaml["make"]["emphasis"].type.string + && _yaml["make"]["emphasis"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.emphasis = _yaml["make"]["emphasis"].get!string; + } + if ("footer" in _yaml["make"] + && _yaml["make"]["footer"].type.string + && _yaml["make"]["footer"].tag.match(rgx_y.yaml_tag_is_str) + ) { + char[][] __match_footer_array + = (cast(char[]) _yaml["make"]["footer"].get!string) + .split(rgx.make_heading_delimiter); + _struct_composite.make_str.footer = __match_footer_array.to!(string[]); + } + if ("headings" in _yaml["make"] + && _yaml["make"]["headings"].type.string + && _yaml["make"]["headings"].tag.match(rgx_y.yaml_tag_is_str) + ) { + char[][] __match_headings_array + = (cast(char[]) _yaml["make"]["headings"].get!string) + .split(rgx.make_heading_delimiter); + _struct_composite.make_str.headings = __match_headings_array.to!(string[]); + } else if ("headings" in _yaml["make"] + && _yaml["make"]["headings"].type.string + && _yaml["make"]["headings"].tag.match(rgx_y.yaml_tag_is_seq) + ) { + foreach(string identify_heading_level; _yaml["make"]["headings"]) { + _struct_composite.make_str.headings ~= identify_heading_level; + } + } + if ("home_button_image" in _yaml["make"] + && _yaml["make"]["home_button_image"].type.string + && _yaml["make"]["home_button_image"].tag.match(rgx_y.yaml_tag_is_str) + ) { + char[][] __match_home_button_image_array + = (cast(char[]) _yaml["make"]["home_button_image"].get!string) + .split(rgx.make_heading_delimiter); + _struct_composite.make_str.home_button_image = __match_home_button_image_array.to!(string[]); + } + if ("home_button_text" in _yaml["make"] + && _yaml["make"]["home_button_text"].type.string + && _yaml["make"]["home_button_text"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.home_button_text = _yaml["make"]["home_button_text"].get!string; + } else if ("home_button_text" in _yaml["make"] + && _yaml["make"]["home_button_text"].type.string + && _yaml["make"]["home_button_text"].tag.match(rgx_y.yaml_tag_is_seq) + ) { + _struct_composite.make_str.home_button_text = ""; + foreach(string hbt; _yaml["make"]["home_button_text"]) { + _struct_composite.make_str.home_button_text ~= hbt ~ "; "; + } + } + if ("italics" in _yaml["make"] + && _yaml["make"]["italics"].type.string + && _yaml["make"]["italics"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.italics = _yaml["make"]["italics"].get!string; + } + if ("auto_num_top_at_level" in _yaml["make"] + && _yaml["make"]["auto_num_top_at_level"].type.string + && _yaml["make"]["auto_num_top_at_level"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.make_str.auto_num_top_at_level = _yaml["make"]["auto_num_top_at_level"].get!string; + switch (_yaml["make"]["auto_num_top_at_level"].get!string) { + case "A": + break; + case "B": _struct_composite.make_str.auto_num_top_lv = 1; + break; + case "C": _struct_composite.make_str.auto_num_top_lv = 2; + break; + case "D": _struct_composite.make_str.auto_num_top_lv = 3; + break; + case "1": _struct_composite.make_str.auto_num_top_lv = 4; + break; + case "2": _struct_composite.make_str.auto_num_top_lv = 5; + break; + case "3": _struct_composite.make_str.auto_num_top_lv = 6; + break; + case "4": _struct_composite.make_str.auto_num_top_lv = 7; + break; + default: + break; + } + } + if ("auto_num_depth" in _yaml["make"] + && _yaml["make"]["auto_num_depth"].type.string + && _yaml["make"]["auto_num_depth"].tag.match(rgx_y.yaml_tag_is_int) + ) { // not sure implemented for documents + _struct_composite.make_str.auto_num_depth = _yaml["make"]["auto_num_depth"].get!int; + } else if ("auto_num_depth" in _yaml["make"] + && _yaml["make"]["auto_num_depth"].type.string + && _yaml["make"]["auto_num_depth"].tag.match(rgx_y.yaml_tag_is_str) + ) { // not sure implemented for documents + _struct_composite.make_str.auto_num_depth = _yaml["make"]["auto_num_depth"].get!int; + } + if ("texpdf_font" in _yaml["make"] + && _yaml["make"]["texpdf_font"].type.string + ) { + _struct_composite.make_str.texpdf_font = _yaml["make"]["texpdf_font"].get!string; + } + } + _struct_composite.make.doc_type = _mk.doc_type(_struct_composite.make_str.doc_type); + _struct_composite.make.breaks = _mk.breaks(_struct_composite.make_str.breaks); + _struct_composite.make.bold = _mk.bold(_struct_composite.make_str.bold); + _struct_composite.make.cover_image = _mk.cover_image(_struct_composite.make_str.cover_image); + _struct_composite.make.css = _mk.css(_struct_composite.make_str.css); + _struct_composite.make.emphasis = _mk.emphasis(_struct_composite.make_str.emphasis); + _struct_composite.make.footer = _mk.footer(_struct_composite.make_str.footer); + _struct_composite.make.headings = _mk.headings(_struct_composite.make_str.headings); + _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); + _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); + _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); + _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); + _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); + _struct_composite.make.auto_num_depth = _mk.auto_num_depth(_struct_composite.make_str.auto_num_depth); + _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); + _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); + } + /+ meta ------------------------------------------------------------------- +/ + if (_struct_composite.meta.creator_author.empty) { + if ("creator" in _yaml + && _yaml["creator"].type.sequence + ) { + if (_yaml["creator"].type.mapping + && _yaml["creator"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("author" in _yaml["creator"] + && _yaml["creator"]["author"].type.string + && _yaml["creator"]["author"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.creator_author = _yaml["creator"]["author"].get!string; + } + if ("email" in _yaml["creator"] + && _yaml["creator"]["email"].type.string + && _yaml["creator"]["email"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.creator_author_email = _yaml["creator"]["email"].get!string; + } + if ("illustrator" in _yaml["creator"] + && _yaml["creator"]["illustrator"].type.string + && _yaml["creator"]["illustrator"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.creator_illustrator = _yaml["creator"]["illustrator"].get!string; + } + if ("translator" in _yaml["creator"] + && _yaml["creator"]["translator"].type.string + && _yaml["creator"]["translator"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.creator_translator = _yaml["creator"]["translator"].get!string; + } + } else if (_yaml["creator"].type.string + && _yaml["creator"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.creator_author = _yaml["creator"].get!string; + } + } + string[] author_arr; + string[][string] authors_hash_arr = [ "first" : [], "last" : [], "full" : [], "last_first" : [], "as_input" : [] ]; + string[] authors_raw_arr + = _struct_composite.meta.creator_author.split(rgx.arr_delimiter); + auto _lastname = appender!(char[])(); + foreach (author_raw; authors_raw_arr) { + if (auto m = author_raw.match(rgx.raw_author_munge)) { + author_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); + authors_hash_arr["first"] ~= author_raw.replace(rgx.raw_author_munge, "$2"); + authors_hash_arr["last"] ~= author_raw.replace(rgx.raw_author_munge, "$1"); + authors_hash_arr["full"] ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); + (m.captures[1]).map!toUpper.copy(_lastname); + authors_hash_arr["last_first"] ~= _lastname.data.to!string ~ ", " ~ m.captures[2]; + _lastname = appender!(char[])(); + } else { + author_arr ~= author_raw; + authors_hash_arr["last"] ~= author_raw; + authors_hash_arr["full"] ~= author_raw; + authors_hash_arr["last_first"] ~= author_raw; + } + authors_hash_arr["as_input"] ~= author_raw; + } + _struct_composite.meta.creator_author_arr = author_arr; + _struct_composite.meta.creator_author = author_arr.join(", ").chomp.chomp; + _struct_composite.meta.creator_author_surname = (authors_hash_arr["last"].length > 0) ? authors_hash_arr["last"][0] : ""; + string _author_name_last_first = authors_hash_arr["last_first"].join("; ").chomp.chomp; + _struct_composite.meta.creator_author_surname_fn = (_author_name_last_first.length > 0) + ? _author_name_last_first + : authors_hash_arr["as_input"].join("; ").chomp.chomp; + } + if (_struct_composite.meta.title_main.empty) { + if ("title" in _yaml + && _yaml["title"].type.sequence + ) { + if (_yaml["title"].type.mapping + && _yaml["title"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("main" in _yaml["title"] + && _yaml["title"]["main"].type.string + && _yaml["title"]["main"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_main = _yaml["title"]["main"].get!string; + } else if ("title" in _yaml["title"] + && _yaml["title"]["title"].type.string + && _yaml["title"]["title"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_main = _yaml["title"]["title"].get!string; + } + if ("edition" in _yaml["title"] + && _yaml["title"]["edition"].type.string + && _yaml["title"]["edition"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_edition = _yaml["title"]["edition"].get!string; + } + if ("full" in _yaml["title"] + && _yaml["title"]["full"].type.string + && _yaml["title"]["full"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_full = _yaml["title"]["full"].get!string; + } + if ("language" in _yaml["title"] + && _yaml["title"]["language"].type.string + && _yaml["title"]["language"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_language = _yaml["title"]["language"].get!string; + } + if ("note" in _yaml["title"] + && _yaml["title"]["note"].type.string + && _yaml["title"]["note"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_note = _yaml["title"]["note"].get!string; + } + if ("subtitle" in _yaml["title"] + && _yaml["title"]["subtitle"].type.string + && _yaml["title"]["subtitle"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_subtitle = _yaml["title"]["subtitle"].get!string; + } else if ("sub" in _yaml["title"] + && _yaml["title"]["sub"].type.string + && _yaml["title"]["sub"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_subtitle = _yaml["title"]["sub"].get!string; + } + } else if ( + _yaml["title"].type.string + && _yaml["title"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.title_main = _yaml["title"].get!string; + } + } + _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; + if ((!(_struct_composite.meta.title_subtitle.empty)) + && (_struct_composite.meta.title_sub.empty)) { + _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; + } + _struct_composite.meta.title_full = (_struct_composite.meta.title_subtitle.empty) + ? _struct_composite.meta.title_main + : format( + "%s - %s", + _struct_composite.meta.title_main, + _struct_composite.meta.title_subtitle, + ); + } + if ("classify" in _yaml + && _yaml["classify"].type.sequence + ) { + if (_yaml["classify"].type.mapping + && _yaml["classify"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("dewey" in _yaml["classify"] + && _yaml["classify"]["dewey"].type.string + && _yaml["classify"]["dewey"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.classify_dewey = _yaml["classify"]["dewey"].get!string; + } + if ("loc" in _yaml["classify"] + && _yaml["classify"]["loc"].type.string + && _yaml["classify"]["loc"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.classify_loc = _yaml["classify"]["loc"].get!string; + } + if ("keywords" in _yaml["classify"] + && _yaml["classify"]["keywords"].type.string + && _yaml["classify"]["keywords"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.classify_keywords = _yaml["classify"]["keywords"].get!string; + } + if ("topic_register" in _yaml["classify"] + && _yaml["classify"]["topic_register"].type.string + && _yaml["classify"]["topic_register"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.classify_topic_register = _yaml["classify"]["topic_register"].get!string; + if (_struct_composite.meta.classify_topic_register.length > 0) { + auto wrds = ctRegex!(`([\wa-zA-Z(). -]+)`); // ctRegex!(`([(]?\w+[a-zA-Z(). -]*)+`); + auto mkp_delim = ctRegex!(`:([^:]+?)(;|$)`); + string _topic_register = _struct_composite.meta.classify_topic_register; + _topic_register = _topic_register + .replaceAll(wrds, "\"$1\"") + .replaceAll(mkp_delim, ":$1$2"); + } + string[] main_topics_ = _struct_composite.meta.classify_topic_register.strip.split(rgx.topic_register_main_terms_split); + string[] topics; + string topics_tmp; + string[] multiple_sub_terms; + foreach (mt; main_topics_) { + topics_tmp = mt.replaceAll(rgx.topic_register_main_term_plus_rest_split, mkup.sep); + if (auto m = topics_tmp.match(rgx.topic_register_multiple_sub_terms_split)) { + multiple_sub_terms = m.captures[1].split(rgx.topic_register_sub_terms_split); + foreach (subterm; multiple_sub_terms) { + topics ~= m.captures.pre ~ mkup.sep ~ subterm; + } + } else { + topics ~= topics_tmp; + } + } + _struct_composite.meta.classify_topic_register_arr = topics; + string[] topics_expanded; + if (_struct_composite.meta.classify_topic_register_arr.length > 0) { + foreach (i, topic; _struct_composite.meta.classify_topic_register_arr) { + string[] subject_tree = topic.split(mkup.sep); + if (topic.length > 0) { + topics_expanded ~= subject_tree.join(", "); + } + } + } + _struct_composite.meta.classify_topic_register_expanded_arr = topics_expanded; + // writeln("\n------\n", _struct_composite.meta.title_full); + // writeln(_struct_composite.meta.classify_topic_register); + // writeln(_struct_composite.meta.classify_topic_register_expanded_arr.sort.join("\n")); + // writeln(_struct_composite.meta.classify_topic_register_arr); + } + } + } + if ("date" in _yaml + && _yaml["date"].type.sequence + ) { + if (_yaml["date"].type.mapping + && _yaml["date"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("added_to_site" in _yaml["date"] + && _yaml["date"]["added_to_site"].type.string + && _yaml["date"]["added_to_site"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_added_to_site = _yaml["date"]["added_to_site"].get!string; + } + if ("available" in _yaml["date"] + && _yaml["date"]["available"].type.string + && _yaml["date"]["available"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_available = _yaml["date"]["available"].get!string; + } + if ("created" in _yaml["date"] + && _yaml["date"]["created"].type.string + && _yaml["date"]["created"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_created = _yaml["date"]["created"].get!string; + } + if ("issued" in _yaml["date"] + && _yaml["date"]["issued"].type.string + && _yaml["date"]["issued"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_issued = _yaml["date"]["issued"].get!string; + } + if ("modified" in _yaml["date"] + && _yaml["date"]["modified"].type.string + && _yaml["date"]["modified"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_modified = _yaml["date"]["modified"].get!string; + } + if ("published" in _yaml["date"] + && _yaml["date"]["published"].type.string + && _yaml["date"]["published"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_published = _yaml["date"]["published"].get!string; + } + if ("valid" in _yaml["date"] + && _yaml["date"]["valid"].type.string + && _yaml["date"]["valid"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.date_valid = _yaml["date"]["valid"].get!string; + } + } + } + _struct_composite.meta.language_document_char = _manifested.src.language; // move + if ("links" in _yaml) { + // if ("" in _yaml["links"]) { + // _struct_composite.meta.links_ = _yaml["links"][""].str; + // } + } + if ("notes" in _yaml + && _yaml["notes"].type.sequence + ) { + if (_yaml["notes"].type.mapping + && _yaml["notes"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("abstract" in _yaml["notes"] + && _yaml["notes"]["abstract"].type.string + && _yaml["notes"]["abstract"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.notes_abstract = _yaml["notes"]["abstract"].get!string; + } + if ("description" in _yaml["notes"] + && _yaml["notes"]["description"].type.string + && _yaml["notes"]["description"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.notes_description = _yaml["notes"]["description"].get!string; + } + if ("summary" in _yaml["notes"] + && _yaml["notes"]["summary"].type.string + && _yaml["notes"]["summary"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.notes_summary = _yaml["notes"]["summary"].get!string; + } + } + } + if ("original" in _yaml + && _yaml["original"].type.sequence + ) { + if (_yaml["original"].type.mapping + && _yaml["original"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("language" in _yaml["original"] + && _yaml["original"]["language"].type.string + && _yaml["original"]["language"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.original_language = _yaml["original"]["language"].get!string; + } + if ("language_char" in _yaml["original"] + && _yaml["original"]["language_char"].type.string + && _yaml["original"]["language_char"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.original_language_char = _yaml["original"]["language_char"].get!string; + } + if ("source" in _yaml["original"] + && _yaml["original"]["source"].type.string + && _yaml["original"]["source"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.original_source = _yaml["original"]["source"].get!string; + } + if ("title" in _yaml["original"] + && _yaml["original"]["title"].type.string + && _yaml["original"]["title"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.original_title = _yaml["original"]["title"].get!string; + } + } + } + if ("publisher" in _yaml) { + // if ("" in _yaml["publisher"]) { + // _struct_composite.meta.publisher = _yaml["publisher"][""].str; + // } + } + if ("rights" in _yaml + && _yaml["rights"].type.sequence + ) { + if (_yaml["rights"].type.mapping + && _yaml["rights"].tag.match(rgx_y.yaml_tag_is_map) + ) { + if ("copyright" in _yaml["rights"] + && _yaml["rights"]["copyright"].type.string + && _yaml["rights"]["copyright"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright = check_input_markup(_yaml["rights"]["copyright"].get!string); + } + if ("copyright_text" in _yaml["rights"] + && _yaml["rights"]["copyright_text"].type.string + && _yaml["rights"]["copyright_text"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_text = _yaml["rights"]["copyright_text"].get!string; + } + if ("copyright_audio" in _yaml["rights"] + && _yaml["rights"]["copyright_audio"].type.string + && _yaml["rights"]["copyright_audio"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_audio = _yaml["rights"]["copyright_audio"].get!string; + } + if ("copyright_cover" in _yaml["rights"] + && _yaml["rights"]["copyright_cover"].type.string + && _yaml["rights"]["copyright_cover"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_cover = _yaml["rights"]["copyright_cover"].get!string; + } + if ("copyright_illustrations" in _yaml["rights"] + && _yaml["rights"]["copyright_illustrations"].type.string + && _yaml["rights"]["copyright_illustrations"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_illustrations = _yaml["rights"]["copyright_illustrations"].get!string; + } + if ("copyright_photographs" in _yaml["rights"] + && _yaml["rights"]["copyright_photographs"].type.string + && _yaml["rights"]["copyright_photographs"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_photographs = _yaml["rights"]["copyright_photographs"].get!string; + } + if ("copyright_translation" in _yaml["rights"] + && _yaml["rights"]["copyright_translation"].type.string + && _yaml["rights"]["copyright_translation"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_translation = _yaml["rights"]["copyright_translation"].get!string; + } + if ("copyright_video" in _yaml["rights"] + && _yaml["rights"]["copyright_video"].type.string + && _yaml["rights"]["copyright_video"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_copyright_video = _yaml["rights"]["copyright_video"].get!string; + } + if ("license" in _yaml["rights"] + && _yaml["rights"]["license"].type.string + && _yaml["rights"]["license"].tag.match(rgx_y.yaml_tag_is_str) + ) { + _struct_composite.meta.rights_license = check_input_markup(_yaml["rights"]["license"].get!string); + } + } + } + } + return _struct_composite; + } +} +template configParseYAMLreturnSpineStruct() { + import dyaml; + import + sisudoc.meta.conf_make_meta_structs, + sisudoc.meta.conf_make_meta_json; + mixin contentYAMLtoSpineStruct; + @system auto configParseYAMLreturnSpineStruct(T,CCm,M,O,Cfg)( + T _document_struct, + CCm _make_and_meta_struct, + M _manifested, + O _opt_action, + Cfg _cfg + ){ + Node _yaml; + if (_document_struct.content.length > 0) { + try { + _yaml = Loader.fromString(_document_struct.content).load(); + } catch (Throwable) { + import std.stdio; + writeln("ERROR failed to parse content as yaml: ", _document_struct.filename); + // writeln(_document_struct.content); + } + try { + _make_and_meta_struct + = contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, _cfg, _document_struct.filename); + } catch (Throwable) { + import std.stdio; + writeln("ERROR failed to convert yaml to struct: ", _document_struct.filename); + } + } + return _make_and_meta_struct; + } +} +template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { + import + std.exception, + std.regex, + std.stdio, + std.traits, + std.typecons, + std.utf, + std.conv : to; + import + dyaml; + import + sisudoc.meta.conf_make_meta_structs, + sisudoc.meta.conf_make_meta_json, + sisudoc.meta.rgx_yaml, + sisudoc.meta.rgx; + mixin spineRgxIn; + mixin contentJSONtoSpineStruct; + static auto rgx = RgxI(); + mixin spineRgxYamlTags; + static auto rgx_y = RgxYaml(); + @system auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M,O,Cfg)( + Src header_src, + CCm _make_and_meta_struct, + M _manifested, + O _opt_action, + Cfg _cfg, + ) { + Node _yaml; + try { + _yaml = Loader.fromString(header_src).load(); + if (("title" in _yaml) && ("creator" in _yaml)) {} else { // need test for _yaml content (does not work) + writeln("ERROR failed to read document header, yaml header does not contain essential information related to title and author"); + } + return contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, _cfg, "header"); + } catch (Throwable) { + writeln("ERROR failed to read document header, header not parsed as yaml: ", _manifested.src.filename); + return _make_and_meta_struct; + } + } +} diff --git a/src/sisudoc/meta/defaults.d b/src/sisudoc/meta/defaults.d new file mode 100644 index 0000000..fe0cd1a --- /dev/null +++ b/src/sisudoc/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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + default settings ++/ +module 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 new file mode 100644 index 0000000..ae50256 --- /dev/null +++ b/src/sisudoc/meta/doc_debugs.d @@ -0,0 +1,252 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + output debugs ++/ +module sisudoc.meta.doc_debugs; +template spineDebugs() { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx_files; + import + std.algorithm, + std.array, + std.container, + std.exception, + std.json, + std.stdio, + std.file, + std.path, + std.range, + std.regex, + std.string, + std.typecons, + std.utf, + std.conv : to; + 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 new file mode 100644 index 0000000..a1899da --- /dev/null +++ b/src/sisudoc/meta/metadoc.d @@ -0,0 +1,296 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc; +@safe: +template spineAbstraction() { + import + std.datetime; + import + sisudoc.meta, + sisudoc.meta.metadoc_from_src, + sisudoc.meta.conf_make_meta_structs, + sisudoc.meta.conf_make_meta_json, + sisudoc.meta.defaults, + sisudoc.io_in.paths_source, + sisudoc.io_in.read_config_files, + sisudoc.io_in.read_source_files, + sisudoc.io_out.hub; + mixin spineBiblio; + mixin outputHub; + enum headBody { header, body_content, insert_file_list, image_list } + enum makeMeta { make, meta } + enum docAbst { doc_abstract_obj, doc_has } + @system auto spineAbstraction(E,P,O,Cfg,M,S)( + E _env, + P program_info, + O _opt_action, + Cfg _cfg, + M _manifest, + S _make_and_meta_struct + ){ + { /+ document config/make file +/ + auto _config_document_struct = readConfigDoc!()(_manifest, _env); + import 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); + static assert(_header_body_insertfilelist_imagelist.length==4); + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("- step1 complete for [", _manifest.src.filename, "]"); + } + debug(header_and_body) { + writeln(header); + writeln(_header_body_insertfilelist_imagelist.length); + writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]); + } + /+ ↓ split header into make and meta +/ + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("step2 commence → (read document header (yaml) return struct) [", _manifest.src.filename, "]"); + } + import sisudoc.meta.conf_make_meta_yaml; + _make_and_meta_struct = + docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()( + _header_body_insertfilelist_imagelist[headBody.header], + _make_and_meta_struct, + _manifest, + _opt_action, + _cfg, + ); + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("- step2 complete for [", _manifest.src.filename, "]"); + } + /+ ↓ document abstraction: process document, return abstraction as tuple +/ + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters) [", _manifest.src.filename, "]"); + } + auto da = docAbstraction!()( + _header_body_insertfilelist_imagelist[headBody.body_content], + _make_and_meta_struct, + _opt_action, + _manifest, + true, + ); + auto doc_abstraction = da.document_the; + auto _doc_has_struct = da.doc_has; + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("- step3 complete for [", _manifest.src.filename, "]"); + } + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("step4 commence → (doc_matters) [", _manifest.src.filename, "]"); + } + struct DocumentMatters { + auto generator_program() { + struct Prog_ { + string project_name() { + return "spine"; + } + string name() { + return program_info.name; + } + string ver() { + return program_info.ver; + } + @trusted string name_and_version() { + return program_info.name_and_version; + } + @trusted string name_version_and_compiler() { + return program_info.name_version_and_compiler; + } + string url_home() { + return "https://sisudoc.org"; + } + string url_git() { + return "https://git.sisudoc.org/projects/"; + } + auto compiler() { + return program_info.compiler; + } + auto time_output_generated() { + return program_info.time_output_generated; + } + } + return Prog_(); + } + auto generated_time() { + auto _st = Clock.currTime(UTC()); + auto _time = _st.year.to!string + ~ "-" ~ _st.month.to!int.to!string // prefer as month number + ~ "-" ~ _st.day.to!string + ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" + ~ " " ~ _st.hour.to!string + ~ ":" ~ _st.minute.to!string + ~ ":" ~ _st.second.to!string; + return _time; + } + auto conf_make_meta() { + return _make_and_meta_struct; + } + auto has() { + return _doc_has_struct; + } + auto env() { + struct Env_ { + auto pwd() { + return _manifest.env.pwd; + } + auto home() { + return _manifest.env.home; + } + } + return Env_(); + } + auto opt() { + struct Opt_ { + auto action() { + /+ getopt options, commandline instructions, raw + - processing instructions --epub --html etc. + - command line config instructions --output + +/ + return _opt_action; + } + } + return Opt_(); + } + auto src() { + return _manifest.src; + } + auto src_path_info() { + return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path + } + auto pod() { + return _manifest.pod; + } + auto sqlite() { + struct SQLite_ { + string filename() { + string _fn = ""; + string _pth = ""; + if (_opt_action.sqliteDB_filename.length > 0) { + _fn = _opt_action.sqliteDB_filename; + } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_db_sqlite_filename; + } + return _fn; + } + string path() { + string _pth = ""; + if (_opt_action.sqliteDB_path.length > 0) { + _pth = _opt_action.sqliteDB_path; + } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_path.length > 0) { + _pth = _make_and_meta_struct.conf.w_srv_db_sqlite_path; + } + return _pth; + } + string cgi_filename() { + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script; + } + return _fn; + } + string cgi_filename_d() { + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename_d.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename_d; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d; + } + return _fn; + } + } + return SQLite_(); + } + auto output_path() { + return _make_and_meta_struct.conf.output_path; + } + auto srcs() { + struct SRC_ { + auto file_insert_list() { + return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; + } + auto image_list() { + return _doc_has_struct.imagelist; + } + } + return SRC_(); + } + } + auto doc_matters = DocumentMatters(); + if ((_opt_action.debug_do) + || (_opt_action.debug_do_stages) + ) { + writeln("- step4 complete for [", _manifest.src.filename, "]"); + } + auto t = tuple(doc_abstraction, doc_matters); + return t; + } +} diff --git a/src/sisudoc/meta/metadoc_curate.d b/src/sisudoc/meta/metadoc_curate.d new file mode 100644 index 0000000..3b5654b --- /dev/null +++ b/src/sisudoc/meta/metadoc_curate.d @@ -0,0 +1,92 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_curate; +@safe: +template spineMetaDocCurate() { + auto spineMetaDocCurate(T,H)( + T doc_matters, + H hvst, + ) { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + 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/meta/metadoc_curate_authors.d b/src/sisudoc/meta/metadoc_curate_authors.d new file mode 100644 index 0000000..cb2b1db --- /dev/null +++ b/src/sisudoc/meta/metadoc_curate_authors.d @@ -0,0 +1,530 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_curate_authors; +@safe: + import + std.algorithm, + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.conv : to; + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + mixin spineCurateMetadata; + mixin InternalMarkup; +template spineMetaDocCuratesAuthors() { + static auto mkup = InlineMarkup(); + void spineMetaDocCuratesAuthors(H,M,O)( + H curates, + M _make_and_meta_struct, + O _opt_action, + ) { + string inline_search_form(M)( + M _make_and_meta_truct, + ) { + string o; + string _form; + if (_opt_action.html_link_search) { + o = format(q"┃ + ┃", + _make_and_meta_struct.conf.w_srv_cgi_action, + (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) + ? "" + : "\n ", + ); + } else { + o = ""; + } + return o; + } +string theme_dark_0 = format(q"┃ + body { + color : #CCCCCC; + background : #000000; + background-color : #000000; + } + a:link { + color : #FFFFFF; + text-decoration : none; + } + a:visited { + color : #999999; + text-decoration : none; + } + a:hover { + color : #000000; + background-color : #555555; + } + a:hover img { + background-color : #000000; + } + a:active { + color : #888888; + text-decoration : underline; + } + a.lev0:hover { + color : #FFFFFF; + background-color : #000000; + } + a.lev1:hover { + color : #FFFFFF; + background : #333333; + } + a.lev2:hover { + color : #FFFFFF; + background : #555555; + } + a.lev3:hover { + color : #FFFFFF; + background : #777777; + } + a.lnkicon:link { + text-decoration : none; + } + a.lnkicon:visited { + text-decoration : none; + } + a.lnkicon:hover { + font-size : 160%%; + } + a:hover img { + background-color : #FFFFFF; + } + input, select, textarea { + font-size : 150%%; + } + input { + color : #FFFFFF; + background-color : #777777; + } +┃"); +string theme_light_0 = format(q"┃ + body { + color : #000000; + background : #FFFFFF; + background-color : #FFFFFF; + } + a:link { + color : #003399; + text-decoration : none; + } + a:visited { + color : #003399; + text-decoration : none; + } + a:hover { + color : #000000; + background-color : #f9f9aa; + } + a:hover img { + background-color : #FFFFFF; + } + a:active { + color : #003399; + text-decoration : underline; + } + a.lev0:hover { + color : #000000; + background-color : #FFFFFF; + } + a.lev1:hover { + color : #FFFFFF; + background : #444444; + } + a.lev2:hover { + background : #888888; + } + a.lev3:hover { + background : #BBBBBB; + } + a.lnkicon:link { + text-decoration : none; + } + a.lnkicon:visited { + text-decoration : none; + } + a.lnkicon:hover { + font-size : 160%%; + } + a:hover img { + background-color : #FFFFFF; + } + input, select, textarea { + font-size : 150%%; + } + input { + color : #000000; + background-color : #FFFFFF; + } +┃"); +string theme_dark_1 = format(q"┃ + h1 { + color : #FFFFFF; + background : #000000; + } + p.letter { + color : #FFFFFF; + background : #333333; + } + p.lev0 { + color : #FFFFFF; + background : #000000; + } + p.lev1 { + color : #FFFFFF; + background : #333333; + } + p.lev2 { + background : #555555; + } + p.lev3 { + background : #777777; + } + p.lev4 { + background : #AAAAAA; + } + p.lev5 { + } +┃"); +string theme_light_1 = format(q"┃ + h1 { + color : #FFFFFF; + background : #1A3A7A; + } + p.letter { + color : #FFFFFF; + background : #1A3A7A; + } + p.lev0 { + color : #FFFFFF; + background : #000000; + } + p.lev1 { + color : #FFFFFF; + background : #444444; + } + p.lev2 { + background : #888888; + } + p.lev3 { + background : #BBBBBB; + } + p.lev4 { + background : #EEEEEE; + } + p.lev5 { + } +┃"); + string[] authors = []; + authors ~= format(q"┃ + + + + +⌘ Curated metadata - 🖋 Authors + + + + + + + + + + + + + +⌘ Curated metadata - 🖋 Authors (output organised by language & filetype)
+ + +
+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"┃
┃", + doc_curate.author_surname.translate([' ' : "_"]), + doc_curate.author_surname_fn, + (doc_curate.date_published.length > 0) + ? doc_curate.date_published : "", + doc_curate.path_html_segtoc, + doc_curate.title, + doc_curate.path_html_metadata, + doc_curate.language, + ); + _prev_auth = doc_curate.author_surname_fn; + } else { + _au[doc_curate.author_surname_fn] + ~= format(q"┃┃", + (doc_curate.date_published.length > 0) + ? doc_curate.date_published : "", + doc_curate.path_html_segtoc, + doc_curate.title, + doc_curate.path_html_metadata, + doc_curate.language, + ); + } + _author_date_title ~= format(q"┃%s %s "%s" [ %s ]%s┃", + doc_curate.author_surname_fn, + (doc_curate.date_published.length > 0) + ? "(" ~ doc_curate.date_published ~ ")" : "", + doc_curate.title, + doc_curate.path_html_metadata, + doc_curate.language, + (_opt_action.show_curate_authors) ? "\n " ~ doc_curate.path_abs_html_scroll : "", + ); + } + foreach (k; _au.keys.sort) { + if (k.toUpper.to!(char[])[0] != _prev_k) { + authors ~= format(q"┃┃", + k.toUpper.to!(char[])[0], + k.toUpper.to!(char[])[0], + ); + _prev_k = k.toUpper.to!(char[])[0]; + } + authors ~= _au[k]; + } + authors + ~= format(q"┃ +
+ + + + + + + + +┃") ~ "\n"; + import 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/meta/metadoc_curate_topics.d b/src/sisudoc/meta/metadoc_curate_topics.d new file mode 100644 index 0000000..a30be73 --- /dev/null +++ b/src/sisudoc/meta/metadoc_curate_topics.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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_curate_topics; +@safe: + import + std.algorithm, + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.conv : to; + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + mixin spineCurateMetadata; + mixin InternalMarkup; +template spineMetaDocCuratesTopics() { + static auto mkup = InlineMarkup(); + void spineMetaDocCuratesTopics(H,M,O)( + H hvst, + M _make_and_meta_struct, + O _opt_action, + ) { + string inline_search_form(M)( + M _make_and_meta_truct, + ) { + string o; + string _form; + if (_opt_action.html_link_search) { + o = format(q"┃ + ┃", + _make_and_meta_struct.conf.w_srv_cgi_action, + (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) + ? "" + : "\n ", + ); + } else { + o = ""; + } + return o; + } + auto min_repeat_number = 42; + string[] _document_topic_register; + string[] _topic_register; + string[] _sub_topic_register; + string[] topics = []; + string _auth = ""; + foreach(k, doc_curate; hvst.curates) { + _topic_register = []; + foreach(topic; doc_curate.topic_register_arr.sort) { + _sub_topic_register = []; + string _spaces; + string[] subject_tree = topic.split(mkup.sep); + switch (subject_tree.length) { + case 1: + hvst.subject_trees[subject_tree[0]]["_a"]["_a"]["_a"] ~= doc_curate; + break; + case 2: + hvst.subject_trees[subject_tree[0]][subject_tree[1]]["_a"]["_a"] ~= doc_curate; + break; + case 3: + hvst.subject_trees[subject_tree[0]][subject_tree[1]][subject_tree[2]]["_a"] ~= doc_curate; + break; + case 4: + hvst.subject_trees[subject_tree[0]][subject_tree[1]][subject_tree[2]][subject_tree[3]] ~= doc_curate; + break; + default: + break; + } + _topic_register ~= _sub_topic_register.join("\n"); + } + auto char_repeat_number = (doc_curate.title.length + + doc_curate.author.length + 16); + char_repeat_number = (char_repeat_number > min_repeat_number) + ? char_repeat_number + : min_repeat_number; + _document_topic_register ~= format( + "\"%s\", %s%s\n%s", + doc_curate.title, + doc_curate.author, + (doc_curate.date_published.length > 0) ? " (" ~ doc_curate.date_published ~ ")" : "", + _topic_register.sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable).release.join("\n"), + ); + } +string theme_dark_0 = format(q"┃ + body { + color : #CCCCCC; + background : #000000; + background-color : #000000; + } + a:link { + color : #FFFFFF; + text-decoration : none; + } + a:visited { + color : #999999; + text-decoration : none; + } + a:hover { + color : #000000; + background-color : #555555; + } + a:hover img { + background-color : #000000; + } + a:active { + color : #888888; + text-decoration : underline; + } + a.lev0:hover { + color : #FFFFFF; + background-color : #000000; + } + a.lev1:hover { + color : #FFFFFF; + background : #333333; + } + a.lev2:hover { + color : #FFFFFF; + background : #555555; + } + a.lev3:hover { + color : #FFFFFF; + background : #777777; + } + a.lnkicon:link { + text-decoration : none; + } + a.lnkicon:visited { + text-decoration : none; + } + a.lnkicon:hover { + font-size : 160%%; + } + a:hover img { + background-color : #FFFFFF; + } + input, select, textarea { + font-size : 150%%; + } + input { + color : #FFFFFF; + background-color : #777777; + } +┃"); +string theme_light_0 = format(q"┃ + body { + color : #000000; + background : #FFFFFF; + background-color : #FFFFFF; + } + a:link { + color : #003399; + text-decoration : none; + } + a:visited { + color : #003399; + text-decoration : none; + } + a:hover { + color : #000000; + background-color : #f9f9aa; + } + a:hover img { + background-color : #FFFFFF; + } + a:active { + color : #003399; + text-decoration : underline; + } + a.lev0:hover { + color : #000000; + background-color : #FFFFFF; + } + a.lev1:hover { + color : #FFFFFF; + background : #444444; + } + a.lev2:hover { + background : #888888; + } + a.lev3:hover { + background : #BBBBBB; + } + a.lnkicon:link { + text-decoration : none; + } + a.lnkicon:visited { + text-decoration : none; + } + a.lnkicon:hover { + font-size : 160%%; + } + a:hover img { + background-color : #FFFFFF; + } + input, select, textarea { + font-size : 150%%; + } + input { + color : #000000; + background-color : #FFFFFF; + } +┃"); +string theme_dark_1 = format(q"┃ + h1 { + color : #FFFFFF; + background : #000000; + } + p.letter { + color : #FFFFFF; + background : #333333; + } + p.lev0 { + color : #FFFFFF; + background : #000000; + } + p.lev1 { + color : #FFFFFF; + background : #333333; + } + p.lev2 { + background : #555555; + } + p.lev3 { + background : #777777; + } + p.lev4 { + background : #AAAAAA; + } + p.lev5 { + } +┃"); +string theme_light_1 = format(q"┃ + h1 { + color : #FFFFFF; + background : #1A3A7A; + } + p.letter { + color : #FFFFFF; + background : #1A3A7A; + } + p.lev0 { + color : #FFFFFF; + background : #000000; + } + p.lev1 { + color : #FFFFFF; + background : #444444; + } + p.lev2 { + background : #888888; + } + p.lev3 { + background : #BBBBBB; + } + p.lev4 { + background : #EEEEEE; + } + p.lev5 { + } +┃"); + topics ~= format(q"┃ + + + +⌘ Curated metadata - ⌘ Topics + + + + + + + + + + + + + +⌘ Curated metadata - ⌘ Topics (output organised by language & filetype)
+ +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"; + 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"┃"%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"┃
┃", + k0.translate([' ' : "_"]), + k1.translate([' ' : "_"]), k1,) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" ", k1); + } + if ("_a" in hvst.subject_trees[k0][k1]) { + foreach (t_a_; + hvst.subject_trees[k0][k1]["_a"]["_a"] + .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) + ) { + _auth = []; + if (t_a_.author_arr.length < 2) { + _auth = format(q"┃ %s┃", + t_a_.author_surname.translate([' ' : "_"]), + t_a_.author, + ); + } else { + foreach (a; t_a_.author_arr) { + _auth ~= format(q"┃ %s,┃", + t_a_.author_surname.translate([' ' : "_"]), + a, + ); + } + } + topics ~= format(q"┃%s - %s [ %s ]┃", + t_a_.path_html_segtoc, + t_a_.title, + _auth, + t_a_.path_html_metadata, + t_a_.language, + ) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" - ", t_a_.title, " - ", t_a_.author); + } + } + } + } + foreach(k2; + hvst.subject_trees[k0][k1].keys + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) + ) { + if (k2 != "_a") { + topics ~= format(q"┃
┃", + k0.translate([' ' : "_"]), k1.translate([' ' : "_"]), + k2.translate([' ' : "_"]), k2,) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" ", k2); + } + if ("_a" in hvst.subject_trees[k0][k1][k2]) { + foreach (t_a_; + hvst.subject_trees[k0][k1][k2]["_a"] + .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) + ) { + _auth = []; + if (t_a_.author_arr.length < 2) { + _auth = format(q"┃ %s┃", + t_a_.author_surname.translate([' ' : "_"]), + t_a_.author, + ); + } else { + foreach (a; t_a_.author_arr) { + _auth ~= format(q"┃ %s,┃", + t_a_.author_surname.translate([' ' : "_"]), + a, + ); + } + } + topics ~= format(q"┃%s - %s [ %s ]┃", + t_a_.path_html_segtoc, + t_a_.title, + _auth, + t_a_.path_html_metadata, + t_a_.language, + ) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" - ", t_a_.title, " - ", t_a_.author); + } + } + } + } + foreach(k3; + hvst.subject_trees[k0][k1][k2].keys + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.unstable) + ) { + if (k3 != "_a") { + topics ~= format(q"┃
┃", + k0.translate([' ' : "_"]), k1.translate([' ' : "_"]), k2.translate([' ' : "_"]), + k3.translate([' ' : "_"]), k3,) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" ", k3); + } + { + foreach (t_a_; + hvst.subject_trees[k0][k1][k2][k3] + .multiSort!("toUpper(a.title) < toUpper(b.title)", "a.author < b.author", SwapStrategy.unstable) + ) { + _auth = []; + if (t_a_.author_arr.length < 2) { + _auth = format(q"┃%s┃", + t_a_.author_surname.translate([' ' : "_"]), + t_a_.author, + ); + } else { + foreach (a; t_a_.author_arr) { + _auth ~= format(q"┃ %s,┃", + t_a_.author_surname.translate([' ' : "_"]), + a, + ); + } + } + topics ~= format(q"┃%s - %s [ %s ]┃", + t_a_.path_html_segtoc, + t_a_.title, + _auth, + t_a_.path_html_metadata, + t_a_.language, + ) ~ "\n"; + if (_opt_action.show_curate_topics) { + writeln(" - ", t_a_.title, " - ", t_a_.author); + } + } + } + } + } + } + } + } + } + topics + ~= format(q"┃ +
+ + + + + + + + +┃") ~ "\n"; + import 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/meta/metadoc_from_src.d b/src/sisudoc/meta/metadoc_from_src.d new file mode 100644 index 0000000..32954f1 --- /dev/null +++ b/src/sisudoc/meta/metadoc_from_src.d @@ -0,0 +1,1509 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +// 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, + std.container, + std.file, + std.json, + std.path; + import + sisudoc.meta, + sisudoc.meta.defaults, + sisudoc.meta.rgx, + sisudoc.meta.metadoc_object_setter, + 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; + auto node_para_int_ = node_metadata_para_int; + auto node_para_str_ = node_metadata_para_str; + ObjGenericComposite comp_obj_; + line_occur = [ + "heading" : 0, + "para" : 0, + "glossary" : 0, + "blurb" : 0, + ]; + uint[string] dochas = [ + "inline_links" : 0, + "inline_notes" : 0, + "inline_notes_star" : 0, + "codeblock" : 0, + "table" : 0, + "block" : 0, + "group" : 0, + "poem" : 0, + "quote" : 0, + "images" : 0, + ]; + uint[string] pith = [ + "ocn" : 1, + "section" : 0, + "txt_is" : 0, + "block_is" : 0, + "block_state" : 0, + "block_delim" : 0, + "make_headings" : 0, + "dummy_heading_status" : 0, + "dummy_heading_multiple_objects" : 0, + "no_ocn_multiple_objects" : 0, + "verse_new" : 0, + ]; + string[string] object_number_poem = [ + "start" : "", + "end" : "" + ]; + string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ]; + int[string] lv = [ + "lv" : eN.bi.off, + "h0" : eN.bi.off, + "h1" : eN.bi.off, + "h2" : eN.bi.off, + "h3" : eN.bi.off, + "h4" : eN.bi.off, + "h5" : eN.bi.off, + "h6" : eN.bi.off, + "h7" : eN.bi.off, + "lev_int_collapsed" : 0, + ]; + int[string] collapsed_lev = [ + "h0" : eN.bi.off, + "h1" : eN.bi.off, + "h2" : eN.bi.off, + "h3" : eN.bi.off, + "h4" : eN.bi.off, + "h5" : eN.bi.off, + "h6" : eN.bi.off, + "h7" : eN.bi.off + ]; + string[string] heading_match_str = [ + "h_A": "^(none)", + "h_B": "^(none)", + "h_C": "^(none)", + "h_D": "^(none)", + "h_1": "^(none)", + "h_2": "^(none)", + "h_3": "^(none)", + "h_4": "^(none)" + ]; + Regex!char[string] heading_match_rgx = [ + "h_A": regex(r"^(none)"), + "h_B": regex(r"^(none)"), + "h_C": regex(r"^(none)"), + "h_D": regex(r"^(none)"), + "h_1": regex(r"^(none)"), + "h_2": regex(r"^(none)"), + "h_3": regex(r"^(none)"), + "h_4": regex(r"^(none)") + ]; + string _anchor_tag; + string toc_txt_; + an_object["glossary_nugget"] = ""; + an_object["blurb_nugget"] = ""; + comp_obj_ = set_object_heading("lev4", "frontmatter", "toc", "Table of Contents"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "toc"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.ptr.html_segnames = html_segnames_ptr; + comp_obj_.tags.anchor_tags = ["toc"]; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + auto toc_head = comp_obj_; + html_segnames_ptr_cntr++; + the_document_toc_section = [toc_head]; + static auto mkup = InlineMarkup(); + static auto munge = ObjInlineMarkupMunge(); + auto note_section = NotesSection(); + auto bookindex_extract_hash = BookIndexNuggetHash(); + string[][string] lev4_subtoc; + string[][string] segnames = ["html": ["toc"], "epub": ["toc"]]; + int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; + // abstraction init ↑ + debug (substitutions) { + writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); + if (!(conf_make_meta.make.headings.empty)) { + writeln(conf_make_meta.make.headings); + } + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + writeln("regex to match: ", substitution_pair[Substitute.match]); + writeln("substitution to make: ", substitution_pair[Substitute.markup]); + } + } + if (conf_make_meta.make.bold) { + writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]); + } + if (conf_make_meta.make.emphasis) { + writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]); + } + if (conf_make_meta.make.italics) { + writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]); + } + } + auto loopMarkupSrcByLine( + char[][] markup_sourcefile_content, + string[string] an_object, + uint[string] pith, + ) { + _loopMarkupSrcByLineStruct ret; + srcDocLoopLineByLine_: + foreach (line; markup_sourcefile_content) { + // ↓ markup document/text line by line + // "line" variable can be empty but should never be null + // scope + scope(exit) { } + scope(failure) { + stderr.writefln( + "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n", + __MODULE__, __FUNCTION__, + __FILE__, __LINE__, + manifested.src.filename, line, + ); + } + debug(source) { writeln(line); } + debug(srclines) { if (!line.empty) { writefln("* %s", line); } } + if (!line.empty) { pith = line._check_ocn_status_(pith); } + if ( pith["block_is"] == eN.blk_is.code + && pith["block_state"] == eN.blk_state.on + ) { + // block object: code + { + ST_txt_by_line_block_generic _get = line.txt_by_line_block_code(an_object, pith); + { + an_object = _get.this_object; + pith = _get.pith; + } + } + continue; + } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { + // object other than "code block" object + // (includes regular text paragraph, headings & blocks other than code) + // heading, glossary, blurb, poem, group, block, quote, table + line = line.inline_markup_faces; // by text line (rather than by text object), linebreaks in para problematic + if (line.matchFirst(rgx.heading_biblio) + || (pith["section"] == eN.sect.bibliography + && ((!(line.matchFirst(rgx.heading_glossary))) + && (!(line.matchFirst(rgx.heading_blurb))) + && (!(line.matchFirst(rgx.heading))) + && (!(line.matchFirst(rgx.comment))))) + ) { + pith["section"] = eN.sect.bibliography; + if (opt_action.backmatter && opt_action.section_biblio) { + { + ST_txt_by_line_block_biblio _get = line.txt_by_line_block_biblio(pith, bib_entry, biblio_entry_str_json, biblio_arr_json); + { + pith = _get.pith; + bib_entry = _get.bib_entry; + biblio_entry_str_json = _get.biblio_entry_str_json; + biblio_arr_json = _get.biblio_arr_json; + } + } + debug(bibliobuild) { + writeln("- ", biblio_entry_str_json); + writeln("-> ", biblio_arr_json.length); + } + } + continue; + } else if (line.matchFirst(rgx.heading_glossary) + || (pith["section"] == eN.sect.glossary + && ((!(line.matchFirst(rgx.heading_biblio))) + && (!(line.matchFirst(rgx.heading_blurb))) + && (!(line.matchFirst(rgx.heading))) + && (!(line.matchFirst(rgx.comment))))) + ) { + // within section (block object): glossary + debug(glossary) { writeln(__LINE__); writeln(line); } + pith["section"] = eN.sect.glossary; + if (opt_action.backmatter && opt_action.section_glossary) { + ST_the_section add_to_glossary_sect = line.build_the_glossary_section(pith, tag_assoc); // double check, should not be necessary to pass pith + the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[0]; + if (add_to_glossary_sect.comp_section_obj.length > 1) { // heading + the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[1]; + } + pith = add_to_glossary_sect.pith; + tag_assoc = add_to_glossary_sect.tag_assoc; + } + continue; + } else if (line.matchFirst(rgx.heading_blurb) + || (pith["section"] == eN.sect.blurb + && ((!(line.matchFirst(rgx.heading_glossary))) + && (!(line.matchFirst(rgx.heading_biblio))) + && (!(line.matchFirst(rgx.heading))) + && (!(line.matchFirst(rgx.comment))))) + ) { + pith["section"] = eN.sect.blurb; + debug(blurb) { writeln(__LINE__); writeln(line); } + if ((opt_action.backmatter && opt_action.section_blurb) && !(line.empty)) { + ST_the_section add_to_blurb_sect = line.build_the_blurb_section(pith, tag_assoc, opt_action); // double check, should not be necessary to pass pith + the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[0]; + if (add_to_blurb_sect.comp_section_obj.length > 1) { // heading + the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[1]; + } + pith = add_to_blurb_sect.pith; + tag_assoc = add_to_blurb_sect.tag_assoc; + } + continue; + } else if (pith["block_state"] == eN.blk_state.on) { + if (pith["block_is"] == eN.blk_is.quote) { + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); + { + auto _get = line.txt_by_line_block_quote(an_object, pith); + { + an_object = _get.this_object; + pith = _get.pith; + } + } + continue; + } else if (pith["block_is"] == eN.blk_is.group) { + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta) + .replaceAll(rgx.para_delimiter, mkup.br_line_spaced ~ "$1"); + { + auto _get = line.txt_by_line_block_group(an_object, pith); + { + an_object = _get.this_object; + pith = _get.pith; + } + } + continue; + } else if (pith["block_is"] == eN.blk_is.block) { + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); + if (auto m = line.match(rgx.spaces_keep)) { + line = line + .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); + } + { + auto _get = line.txt_by_line_block_block(an_object, pith); + { + an_object = _get.this_object; + pith = _get.pith; + } + } + continue; + } else if (pith["block_is"] == eN.blk_is.poem) { + { + auto _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); + { + an_object = _get.this_object; + pith = _get.pith; + cntr = _get.cntr; + } + } + continue; + } else if (pith["block_is"] == eN.blk_is.table) { + { + auto _get = line.txt_by_line_block_table(an_object, pith, conf_make_meta); + { + an_object = _get.this_object; + pith = _get.pith; + conf_make_meta = _get.conf_make_meta; + } + } + continue; + } + } else { + // not within a block group + assert( + (pith["block_state"] == eN.blk_state.off) + || (pith["block_state"] == eN.blk_state.closing), + "block status: none or closed" + ); + if (line.matchFirst(rgx.block_open)) { + if (line.matchFirst(rgx.block_poem_open)) { + // poem to verse exceptions! + object_reset(an_object); + processing.remove("verse"); + object_number_poem["start"] = obj_cite_digits.object_number.to!string; + } + { + auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem); + { + pith = _get.pith; + dochas = _get.dochas; + object_number_poem = _get.object_number_poem; + } + } + continue; + } else if (!line.empty) { + // line not empty - non blocks (headings, paragraphs) & closed blocks + assert(!line.empty, "line tested, line not empty surely:\n \"" ~ line ~ "\""); + assert( + (pith["block_state"] == eN.blk_state.off) + || (pith["block_state"] == eN.blk_state.closing), + "code block status: none or closed" + ); + if (pith["block_state"] == eN.blk_state.closing) { + debug(check) { writeln(__LINE__); writeln(line); } + assert( + line.matchFirst(rgx.book_index_item) + || line.matchFirst(rgx.book_index_item_open) + || pith["section"] == eN.sect.book_index, + "\nblocks closed, unless followed by book index, non-matching line:\n \"" + ~ line ~ "\"" + ); + } + if (line.matchFirst(rgx.book_index_item) + || line.matchFirst(rgx.book_index_item_open) + || pith["section"] == eN.sect.book_index) { + { // book_index + auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action); + { + an_object = _get.this_object; + pith = _get.pith; + book_idx_tmp = _get.book_idx_tmp; + } + } + } else { + // not book_index + an_object_key = "body_nugget"; + if (auto m = line.matchFirst(rgx.comment)) { + // matched comment + debug(comment) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + comp_obj_comment = comp_obj_comment.init; + comp_obj_comment.metainfo.is_of_part = "comment"; // breaks flow + comp_obj_comment.metainfo.is_of_section = "comment"; // breaks flow + comp_obj_comment.metainfo.is_of_type = "comment"; + comp_obj_comment.metainfo.is_a = "comment"; + comp_obj_comment.text = an_object[an_object_key].strip; + the_document_body_section ~= comp_obj_comment; + { + auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + { + line_occur = _get.line_occur; + an_object = _get.this_object; + pith = _get.pith; + } + } + processing.remove("verse"); + ++cntr; + } else if ((line_occur["para"] == eN.bi.off + && line_occur["heading"] == eN.bi.off) + && pith["txt_is"] == eN.txt_is.off + ) { // heading or para but neither flag nor line exists + if ((conf_make_meta.make.headings.length > 2) + && (pith["make_headings"] == eN.bi.off)) { + // heading found + { + auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); + { + heading_match_str = _get.heading_match_str; + heading_match_rgx = _get.heading_match_rgx; + pith = _get.pith; + } + } + } + if (pith["make_headings"] == eN.bi.on + && (line_occur["para"] == eN.bi.off + && line_occur["heading"] == eN.bi.off) + && pith["txt_is"] == eN.txt_is.off + ) { + // heading make set + { + auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); + { + line = _get.line; + an_object = _get.this_object; + pith = _get.pith; + } + } + } + // TODO node info: all headings identified at this point, + // - extract node info here?? + // - how long can it wait? + // - should be incorporated in composite objects + // - should happen before endnote links set (they need to be moved down?) + if (line.matchFirst(rgx.headings)) { + // heading match + line = line._doc_header_and_make_substitutions_(conf_make_meta); + { + auto _get = line.flow_heading_matched_( + an_object, + line_occur, + an_object_key, + lv, + collapsed_lev, + pith, + conf_make_meta, + ); + { + an_object = _get.this_object; + pith = _get.pith; + } + } + } else if (line_occur["para"] == eN.bi.off) { + // para match + an_object_key = "body_nugget"; + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); + { + auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + { + an_object = _get.this_object; + an_object_key = _get.this_object_key; + pith = _get.pith; + indent = _get.indent; + bullet = _get.bullet; + line_occur = _get.line_occur; + } + } + } + } else if (line_occur["heading"] > eN.bi.off) { + // heading + debug(heading) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + ++line_occur["heading"]; + } else if (line_occur["para"] > eN.bi.off) { + // paragraph + debug(para) { writeln(an_object_key, "-> ", line); } + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); + an_object[an_object_key] ~= " " ~ line; + ++line_occur["para"]; + } + } + } else if (pith["block_state"] == eN.blk_state.closing) { + // line empty, with blocks flag + { + auto _get = line.flow_block_flag_line_empty_( + an_object, + bookindex_extract_hash, + the_document_body_section, + bookindex_unordered_hashes, + obj_cite_digits, + comp_obj_, + cntr, + pith, + object_number_poem, + conf_make_meta, + tag_in_seg, + ); + { + an_object = _get.this_object; + the_document_body_section = _get.the_document_body_section; + bookindex_unordered_hashes = _get.bookindex_unordered_hashes; + obj_cite_digits = _get.obj_cite_digits; + comp_obj_ = _get.comp_obj_; + cntr = _get.cntr; + pith = _get.pith; + } + } + } else { + // line.empty, post contents, empty variables: + assert( + line.empty, + "\nline should be empty:\n \"" + ~ line ~ "\"" + ); + assert( + (pith["block_state"] == eN.blk_state.off), + "code block status: none" + ); + if (_new_doc) { + tag_assoc = tag_assoc.init; + lv0to3_tags = lv0to3_tags.init; + tag_in_seg = tag_in_seg.init; + } + if (pith["txt_is"] == eN.txt_is.heading + && line_occur["heading"] > eN.bi.off + ) { + // heading object (current line empty) + obj_cite_digits = (an_object["lev_markup_number"].to!int == 0) + ? ocn_emit(eN.ocn.reset) + : ocn_emit(pith["ocn"]); + an_object["is"] = "heading"; + an_object_key = "body_nugget"; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_object_and_anchor_tags_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc)); + an_object["substantive"] = substantive_object_and_anchor_tags_struct.obj_txt; + anchor_tag = substantive_object_and_anchor_tags_struct.anchor_tag; + if (_new_doc) { + cnt1 = 1; + cnt2 = 1; + cnt3 = 1; + _new_doc = false; + } + if ( + an_object["lev_markup_number"].to!int == 4 + && (!(anchor_tag.empty) + || (lv0to3_tags.length > 0)) + ) { + tag_in_seg["seg_lv4"] = anchor_tag; + tag_in_seg["seg_lv1to4"] = anchor_tag; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; + if (lv0to3_tags.length > 0) { + // names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) + foreach (lv0_to_lv3_html_tag; lv0to3_tags) { + tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag; + } + } + anchor_tag_ = anchor_tag; + lv0to3_tags = lv0to3_tags.init; + } else if (an_object["lev_markup_number"].to!int > 4) { + tag_in_seg["seg_lv4"] = anchor_tag_; + tag_in_seg["seg_lv1to4"] = anchor_tag_; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; + } else if (an_object["lev_markup_number"].to!int < 4) { + string segn; + switch (an_object["lev_markup_number"].to!int) { + // names used for epub markup segments A to D + case 0: + segn = "_the_title"; + goto default; + case 1: + segn = "_part_" ~ cnt1.to!string; + ++cnt1; + goto default; + case 2: + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; + ++cnt2; + goto default; + case 3: + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; + ++cnt3; + goto default; + default: + lv0to3_tags ~= obj_cite_digits.object_number.to!string; + lv0to3_tags ~= segn; + tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known + tag_in_seg["seg_lv1to4"] = segn; + break; + } + } + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); + _anchor_tag = obj_cite_digits.identifier; + // (incrementally build toc) table of contents here! + { + auto _get = obj_im.flow_table_of_contents_gather_headings( + an_object, + conf_make_meta, + tag_in_seg, + _anchor_tag, + lev4_subtoc, + the_document_toc_section, + ); + { + the_document_toc_section = _get.the_document_toc_section; + lev4_subtoc = _get.lev4_subtoc; + } + } + if (an_object["lev_markup_number"] == "4") { + segnames["html"] ~= tag_in_seg["seg_lv4"]; + html_segnames_ptr = html_segnames_ptr_cntr; + html_segnames_ptr_cntr++; + } + if (an_object["lev_markup_number"].to!int <= 4) { + segnames["epub"] ~= tag_in_seg["seg_lv1to4"]; + } + auto comp_obj_ = node_construct.node_emitter_heading( + an_object, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, // OCNset + cntr, // int + heading_ptr, // int + lv_ancestors_txt, // string[] + html_segnames_ptr, // int + substantive_object_and_anchor_tags_struct, + ); + ++heading_ptr; + debug(segments) { + writeln(an_object["lev_markup_number"]); + writeln(tag_in_seg["seg_lv4"]); + writeln(tag_in_seg["seg_lv1to4"]); + } + the_document_body_section ~= comp_obj_; + debug(objectrelated1) { writeln(line); } // check + { + auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + { + line_occur = _get.line_occur; + an_object = _get.this_object; + pith = _get.pith; + } + } + an_object.remove("lev"); + an_object.remove("lev_markup_number"); + processing.remove("verse"); + ++cntr; + } else if (pith["txt_is"] == eN.txt_is.para + && line_occur["para"] > eN.bi.off + ) { // paragraph object (current line empty) - repeated character paragraph separator + if ((an_object[an_object_key].to!string).matchFirst(rgx.repeated_character_line_separator)) { + pith["ocn"] = eN.ocn.off; + } + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); + an_object["is"] = "para"; + auto comp_obj_ = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"], + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "para", "para", an_object["substantive"].to!string.strip, obj_cite_digits.object_number); + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = (obj_cite_digits.off == 0) ? true : false; // TODO + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.attrib.indent_hang = indent["hang_position"]; + comp_obj_.attrib.indent_base = indent["base_position"]; + comp_obj_.attrib.bullet = bullet; + comp_obj_.tags.anchor_tags = [anchor_tag]; anchor_tag=""; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + comp_obj_.has.image_without_dimensions = substantive_obj_misc_struct.has_images_without_dimensions; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + { + auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); + { + line_occur = _get.line_occur; + an_object = _get.this_object; + pith = _get.pith; + } + } + indent = [ + "hang_position" : 0, + "base_position" : 0, + ]; + bullet = false; + processing.remove("verse"); + ++cntr; + // } else { // could be useful to test line variable should be empty and never null + } + } // close else for line empty + } // close else for not the above + } // close after non code, other blocks or regular text + // unless (the_document_body_section.length == 0) ? + if (the_document_body_section.length > 0) { + if (((the_document_body_section[$-1].metainfo.is_a == "para") + || (the_document_body_section[$-1].metainfo.is_a == "heading") + || (the_document_body_section[$-1].metainfo.is_a == "quote") + || (the_document_body_section[$-1].metainfo.is_a == "group") + || (the_document_body_section[$-1].metainfo.is_a == "block") + || (the_document_body_section[$-1].metainfo.is_a == "verse")) + && (the_document_body_section.length > previous_length)) { + if ((the_document_body_section[$-1].metainfo.is_a == "heading") + && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) { + pith["section"] = eN.sect.unset; + } + if (the_document_body_section[$-1].metainfo.is_a == "verse") { + // scan for endnotes for whole poem (each verse in poem) + foreach (i; previous_length .. the_document_body_section.length) { + if (the_document_body_section[i].metainfo.is_a == "verse") { + if ((the_document_body_section[i].text).match( + rgx.inline_notes_al_all_note + )) { + object_notes = note_section.gather_notes_for_endnote_section( + the_document_body_section, + tag_in_seg, + (i).to!int, + ); + } + } + } + } else { + // scan object for endnotes + previous_length = the_document_body_section.length.to!int; + if ((the_document_body_section[$-1].text).match( + rgx.inline_notes_al_all_note + )) { + previous_count = (the_document_body_section.length -1).to!int; + object_notes = note_section.gather_notes_for_endnote_section( + the_document_body_section, + tag_in_seg, + (the_document_body_section.length-1).to!int, + ); + } + } + previous_length = the_document_body_section.length.to!int; + } + } + } + ret.toc = the_document_toc_section; + ret.body = the_document_body_section; + ret.glossary = the_document_glossary_section; + ret.blurb = the_document_blurb_section; + ret.object_notes = object_notes; + ret.segnames = segnames; + return ret; + } + { // loopMarkupSrcByLine + auto _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith); + the_document_toc_section = _doc_by_line.toc; + the_document_body_section = _doc_by_line.body; + the_document_glossary_section = _doc_by_line.glossary; + the_document_blurb_section = _doc_by_line.blurb; + segnames = _doc_by_line.segnames; + object_notes = _doc_by_line.object_notes; // endnotes, compare, not sure is used + destroy(_doc_by_line); + } + { // EOF backMatter + comp_obj_ = set_object_heading("lev1", "backmatter", "tail", ""); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_eof"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "tail"; + comp_obj_.tags.anchor_tags = ["section_eof"]; + comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0]; + comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0]; + the_document_xml_dom_tail_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } + // endNotes + ST_endnotes en_st = note_section.backmatter_endnote_objects(obj_cite_digits, opt_action); + { // endnotes + the_document_endnotes_section = en_st.endnotes; + obj_cite_digits = en_st.ocn; + debug(endnotes) { + writefln("%s %s", __LINE__, the_document_endnotes_section.length); + foreach (o; the_document_endnotes_section) { writeln(o); } + } + } + { // glossary + if (an_object["glossary_nugget"].length == 0) { + comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Glossary section"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + the_document_glossary_section ~= comp_obj_; + } + debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } } + } + { // bibliography + string[] biblio_unsorted_incomplete = biblio_arr_json.dup; + ST_biblio_section biblio_section = backmatter_make_the_bibliography_section(biblio_unsorted_incomplete, bib_arr_json); + the_document_bibliography_section = biblio_section.bibliography_section; + tag_assoc = biblio_section.tag_assoc; + } + { // bookindex + BookIndexReportSection bi = BookIndexReportSection(); + ST_bookindex bi_st + = bi.backmatter_bookindex_build_abstraction_section(bookindex_unordered_hashes, obj_cite_digits, opt_action); + destroy(bookindex_unordered_hashes); + the_document_bookindex_section = bi_st.bookindex; + obj_cite_digits = bi_st.ocn; + debug(bookindex) { foreach (bi_entry; the_document_bookindex_section) { writeln(bi_entry); } } + } + { // blurb + if (an_object["blurb_nugget"].length == 0) { + comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Blurb section"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = ""; + comp_obj_.tags.anchor_tag_html = ""; + comp_obj_.tags.in_segment_html = ""; + the_document_blurb_section ~= comp_obj_; + } + debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } } + } + { // toc gather backmatter + the_document_toc_section ~= backmatter_gather_table_of_contents(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section); // + } + { // document head and body + the_document_head_section ~= the_document_body_section[0]; + the_document_body_section = the_document_body_section[1..$]; + } + { // document ancestors + ST_ancestors get_ancestors; + get_ancestors = the_document_body_section.after_doc_determine_ancestors(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section); + the_document_body_section = get_ancestors.the_document_body_section; + the_document_endnotes_section = get_ancestors.the_document_endnotes_section; + the_document_glossary_section = get_ancestors.the_document_glossary_section; + the_document_bibliography_section = get_ancestors.the_document_bibliography_section; + the_document_bookindex_section = get_ancestors.the_document_bookindex_section; + the_document_blurb_section = get_ancestors.the_document_blurb_section; + } + { // document segnames + ST_segnames get_segnames; + get_segnames = the_document_body_section.after_doc_determine_segnames(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section, segnames, html_segnames_ptr_cntr, html_segnames_ptr); // + segnames = get_segnames.segnames; + html_segnames_ptr_cntr = get_segnames.html_segnames_ptr_cntr; + html_segnames_ptr = get_segnames.html_segnames_ptr; + } + // document head + string[] segnames_0_to_4; + foreach (ref obj; the_document_head_section) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + } + if (obj.metainfo.heading_lev_markup == 0) { + // TODO second hit (of two) with same assertion failure, check, fix and reinstate + // assert( obj.metainfo.ocn == 1, + // "Title OCN should be 1 not: " ~ obj.metainfo.ocn.to!string); // bug introduced 0.18.1 + obj.metainfo.ocn = 1; + obj.metainfo.identifier = "1"; + obj.metainfo.object_number_type = OCNtype.ocn; + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } + obj = _links(obj); + } + if (the_document_toc_section.length > 1) { + // scroll + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + foreach (ref obj; the_document_toc_section) { + if (obj.metainfo.is_a == "heading") { + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } + obj = _links(obj); + } + } + // images + string[] _images; + // multiple 1~ levels, loop through document body + if (the_document_body_section.length > 1) { + foreach (ref obj; the_document_body_section) { + if (!(obj.metainfo.identifier.empty)) { + if (!(((obj.metainfo.identifier) in tag_assoc) + && ("seg_lv4" in tag_assoc[(obj.metainfo.identifier)])) + ) { + tag_assoc[(obj.metainfo.identifier)]["seg_lv4"] + = obj.tags.html_segment_anchor_tag_is; + } + tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"] + = obj.tags.epub_segment_anchor_tag_is; + } + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } else if (obj.metainfo.is_a == "para") { + _images ~= extract_images(obj.text); + obj = _image_dimensions(obj, manifested); + } + obj = _links(obj); + } + } + auto image_list = (_images.sort()).uniq; + // endnotes optional only one 1~ level + if (the_document_endnotes_section.length > 1) { + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; + foreach (ref obj; the_document_endnotes_section) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup == 1) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } + obj = _links(obj); + } + } + // glossary optional only one 1~ level + if (the_document_glossary_section.length > 1) { + foreach (ref obj; the_document_glossary_section) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup == 1) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } else if (obj.metainfo.is_a == "glossary" && !(obj.text.empty)) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + obj = _links(obj); + } + } + // bibliography optional only one 1~ level + if (the_document_bibliography_section.length > 1) { + foreach (ref obj; the_document_bibliography_section) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup == 1) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } else if (obj.metainfo.is_a == "bibliography") { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + obj = _links(obj); + } + } + // book index, optional only one 1~ level + int ocn_ = obj_cite_digits.object_number; + int ocn_bkidx_ = 0; + int ocn_bidx_; + if (the_document_bookindex_section.length > 1) { // scroll + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + foreach (ref obj; the_document_bookindex_section) { + if (obj.metainfo.is_a == "heading") { + // debug(dom) { } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + } + if (obj.metainfo.heading_lev_markup == 1) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + if (obj.metainfo.heading_lev_markup <= 4) { + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } else if (obj.metainfo.is_a == "bookindex") { + obj_cite_digits = ocn_emit(eN.ocn.bkidx); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; + obj.metainfo.object_number_type = OCNtype.bkidx; + } + obj = _links(obj); + } + // TODO assert failure, reinstate + // assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); + } + // blurb optional only one 1~ level + if (the_document_blurb_section.length > 1) { + foreach (ref obj; the_document_blurb_section) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup == 1) { + obj_cite_digits = ocn_emit(eN.ocn.on); + obj.metainfo.ocn = obj_cite_digits.object_number; + obj.metainfo.identifier = obj_cite_digits.identifier; + } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; + if (obj.metainfo.heading_lev_markup == 4) { + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + } + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); + } + } + // dom structure (marked up & collapsed) + if (opt_action.meta_processing_xml_dom) { + obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); + } + obj = obj.obj_heading_ancestors(lv_ancestors_txt); + } else if (obj.metainfo.is_a == "blurb") { + obj_cite_digits = ocn_emit(eN.ocn.off); + obj.metainfo.object_number_off = obj_cite_digits.off; + obj.metainfo.object_number_type = OCNtype.non; + } + obj = _links(obj); + } + } + // get descendants + if (the_document_body_section.length > 1) { + auto pairs = after_doc_get_descendants( + the_document_head_section ~ + the_document_body_section ~ + the_document_endnotes_section ~ + the_document_glossary_section ~ + the_document_bibliography_section ~ + the_document_bookindex_section ~ + the_document_blurb_section ~ + the_document_xml_dom_tail_section + ); + debug(descendants_tuple) { + pairs = pairs.sort(); + foreach (pair; pairs) { // (pair; pairs.sort()) + writeln(pair[0], "..", pair[1]); + } + } + foreach (ref obj; the_document_head_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + if (the_document_body_section.length > 1) { + foreach (ref obj; the_document_body_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_endnotes_section.length > 1) { + foreach (ref obj; the_document_endnotes_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_glossary_section.length > 1) { + foreach (ref obj; the_document_glossary_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_bibliography_section.length > 1) { + foreach (ref obj; the_document_bibliography_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_bookindex_section.length > 1) { + foreach (ref obj; the_document_bookindex_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_blurb_section.length > 1) { + foreach (ref obj; the_document_blurb_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + if (the_document_xml_dom_tail_section.length > 1) { + foreach (ref obj; the_document_xml_dom_tail_section) { + if (obj.metainfo.is_a == "heading") { + foreach (pair; pairs) { + if (obj.metainfo.ocn == pair[0]) { + obj.metainfo.last_descendant_ocn = pair[1]; + } + } + } + } + } + } + // TODO + // - note create/insert heading object sole purpose eof close all open tags + // sort out: + // - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; + // - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; + comp_obj_ = set_object_heading("lev1", "empty", "empty", ""); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = ""; + comp_obj_.tags.anchor_tag_html = ""; + comp_obj_.tags.in_segment_html = ""; + comp_obj_.tags.html_segment_anchor_tag_is = ""; + comp_obj_.tags.epub_segment_anchor_tag_is = ""; + comp_obj_.metainfo.heading_lev_markup = 9; + comp_obj_.metainfo.heading_lev_collapsed = 9; + comp_obj_.metainfo.parent_ocn = 0; + comp_obj_.metainfo.parent_lev_markup = 0; + comp_obj_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; + comp_obj_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; + comp_obj_ = comp_obj_.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, 0); + comp_obj_ = comp_obj_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0); + comp_obj_ = comp_obj_.obj_heading_ancestors(lv_ancestors_txt); + // the_dom_tail_section ~= comp_obj_; // remove tail for now, decide on later + // the doc + ObjGenericComposite[][string] document_the = [ + "head": the_document_head_section, + "toc": the_document_toc_section, + // substantive/body: + "body": the_document_body_section, + // backmatter: + "endnotes": the_document_endnotes_section, + "glossary": the_document_glossary_section, + "bibliography": the_document_bibliography_section, + "bookindex": the_document_bookindex_section, + "blurb": the_document_blurb_section, + // dom tail only + "tail": the_document_xml_dom_tail_section, + ]; + // document parts keys as needed + string[][string] document_section_keys_sequenced = [ + "scroll": ["head", "toc", "body",], + "seg": ["head", "toc", "body",], + "sql": ["head", "body",], + "latex": ["head", "toc", "body",] + ]; + if (document_the["endnotes"].length > 1) { + document_section_keys_sequenced["scroll"] ~= "endnotes"; + document_section_keys_sequenced["seg"] ~= "endnotes"; + document_section_keys_sequenced["latex"] ~= "endnotes"; + } + if (document_the["glossary"].length > 1) { + document_section_keys_sequenced["scroll"] ~= "glossary"; + document_section_keys_sequenced["seg"] ~= "glossary"; + document_section_keys_sequenced["sql"] ~= "glossary"; + document_section_keys_sequenced["latex"] ~= "glossary"; + } + if (document_the["bibliography"].length > 1) { + document_section_keys_sequenced["scroll"] ~= "bibliography"; + document_section_keys_sequenced["seg"] ~= "bibliography"; + document_section_keys_sequenced["sql"] ~= "bibliography"; + document_section_keys_sequenced["latex"] ~= "bibliography"; + } + if (document_the["bookindex"].length > 1) { + document_section_keys_sequenced["scroll"] ~= "bookindex"; + document_section_keys_sequenced["seg"] ~= "bookindex"; + document_section_keys_sequenced["sql"] ~= "bookindex"; + document_section_keys_sequenced["latex"] ~= "bookindex"; + } + if (document_the["blurb"].length > 1) { + document_section_keys_sequenced["scroll"] ~= "blurb"; + document_section_keys_sequenced["seg"] ~= "blurb"; + document_section_keys_sequenced["sql"] ~= "blurb"; + document_section_keys_sequenced["latex"] ~= "blurb"; + } + if ((opt_action.html) + || (opt_action.html_scroll) + || (opt_action.html_seg) + || (opt_action.epub)) { + document_section_keys_sequenced["scroll"] ~= "tail"; + document_section_keys_sequenced["seg"] ~= "tail"; + } + // segnames + string[] segnames_4 = segnames["html"].dup; + string[] segnames_lv1to4 = segnames["epub"].dup; + debug(segnames) { + writeln("segnames_lv4: ", segnames_4); + writeln("segnames_lv1to4: ", segnames_lv1to4); + } + // restart + destroy(the_document_head_section); + destroy(the_document_toc_section); + destroy(the_document_body_section); + destroy(the_document_endnotes_section); + destroy(the_document_glossary_section); + destroy(the_document_bibliography_section); + destroy(the_document_bookindex_section); + destroy(the_document_blurb_section); + destroy(the_document_xml_dom_tail_section); + destroy(segnames); + destroy(bookindex_unordered_hashes); + destroy(an_object); + obj_cite_digits = ocn_emit(eN.ocn.reset); + biblio_arr_json = []; + obj_cite_digit_ = 0; + html_segnames_ptr = 0; + html_segnames_ptr_cntr = 0; + content_non_header = "8"; + dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + lev_anchor_tag = ""; + anchor_tag = ""; + // identify parts + struct DocHas_ { + uint inline_links() { + return dochas["inline_links"]; + } + uint inline_notes_reg() { + return dochas["inline_notes"]; + } + uint inline_notes_star() { + return dochas["inline_notes_star"]; + } + uint codeblocks() { + return dochas["codeblock"]; + } + uint tables() { + return dochas["table"]; + } + uint blocks() { + return dochas["block"]; + } + uint groups() { + return dochas["group"]; + } + uint poems() { + return dochas["poem"]; + } + uint quotes() { + return dochas["quote"]; + } + ulong images() { // TODO not ideal rethink + return (image_list.to!string.strip("[","]").split(",").length); + } + auto imagelist() { + return image_list; + } + auto keys_seq() { + return docSectKeysSeq!()(document_section_keys_sequenced); + } + string[] segnames_lv4() { + return segnames_4; + } + string[] segnames_lv_0_to_4() { + return segnames_0_to_4; + } + string[string][string] tag_associations() { + return tag_assoc; + } + } + auto doc_has() { + return DocHas_(); + } + // the doc to be returned + struct ST_docAbstraction { + ObjGenericComposite[][string] document_the; + DocHas_ doc_has; + } + ST_docAbstraction ret; + { + ret.document_the = document_the; + ret.doc_has = doc_has; + } + return ret; + } // ← closed: abstract doc source +} diff --git a/src/sisudoc/meta/metadoc_from_src_functions.d b/src/sisudoc/meta/metadoc_from_src_functions.d new file mode 100644 index 0000000..29e675c --- /dev/null +++ b/src/sisudoc/meta/metadoc_from_src_functions.d @@ -0,0 +1,5216 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +// 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 + import + std.algorithm, + std.container, + std.file, + std.json, + std.path; + import + sisudoc.meta, + sisudoc.meta.defaults, + sisudoc.meta.rgx, + sisudoc.meta.metadoc_object_setter, + sisudoc.meta.rgx; + // ↓ abstraction mixins + mixin ObjectSetter; + mixin InternalMarkup; + mixin spineRgxIn; + static auto rgx = RgxI(); + // initialize + string[string] an_object, processing, object_notes; + string an_object_key; + string[] anchor_tags; + string anchor_tag; + string anchor_tag_; + string[string] tag_in_seg; + string lev_anchor_tag; + string[string][string] tag_assoc; + string[] lv0to3_tags; + // enum + // biblio variables + string biblio_tag_name, biblio_tag_entry, st; + string[] biblio_arr_json; + string biblio_entry_str_json; + JSONValue[] bib_arr_json; + int bib_entry; + // counters + int cntr, previous_count, previous_length; + bool reset_note_numbers = true; + int[string] line_occur; + int html_segnames_ptr = 0; + int html_segnames_ptr_cntr = 0; + int verse_line, heading_ptr; + // paragraph attributes + int[string] indent; + bool bullet = true; + string content_non_header = "8"; + // ocn + OCNset obj_cite_digits; + int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + static auto obj_im = ObjInlineMarkup(); + static auto obj_att = ObjAttributes(); + auto object_citation_number = OCNemitter(); + auto node_construct = NodeStructureMetadata(); + // ↓ abstraction function emitters + // ↓ - emitters + pure struct OCNemitter { + int ocn_digit, ocn_object_number, ocn_on_, ocn_off_, ocn_bkidx, ocn_bkidx_; + string object_identifier; + bool ocn_is_off; + auto ocn_emitter(int ocn_status_flag) { + OCNset ocn; + assert(ocn_status_flag <= eN.ocn.reset); + ocn_object_number = ocn_bkidx = 0; + object_identifier = ""; + ocn_is_off = false; + switch(ocn_status_flag) with (eN.ocn) { + case reset: + ocn_digit = ocn_on_ = 1; + object_identifier = "1"; + ocn_is_off = false; + ocn_off_ = ocn_bkidx_ = 0; + break; + case on: + ocn_digit = ocn_object_number = ++ocn_on_; + object_identifier = ocn_digit.to!string; + ocn_is_off = false; + break; + case off: + ocn_digit = 0; + ocn_off_ = ++ocn_off_; + object_identifier = "a" ~ ocn_off_.to!string; + ocn_is_off = true; + break; + case bkidx: + ocn_bkidx = ++ocn_bkidx_; + break; + case closing: // unused? + break; + default: + ocn_digit = 0; + } + assert(ocn_digit >= 0); + ocn.digit = ocn_digit; + ocn.object_number = ocn_object_number; // difference between .object_number and .digit? + ocn.identifier = object_identifier; + ocn.off = ocn_is_off; + ocn.bkidx = ocn_bkidx; + ocn.type = ocn_status_flag; + return ocn; + } + invariant() { + } + } + pure ObjGenericComposite obj_heading_ancestors()( + ObjGenericComposite obj, + string[] lv_ancestors_txt, + ) { + switch (obj.metainfo.heading_lev_markup) { + case 0: + lv_ancestors_txt[0] = obj.text.to!string; + foreach(k; 1..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 1: + lv_ancestors_txt[1] = obj.text.to!string; + foreach(k; 2..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 2: + lv_ancestors_txt[2] = obj.text.to!string; + foreach(k; 3..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 3: + lv_ancestors_txt[3] = obj.text.to!string; + foreach(k; 4..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 4: + lv_ancestors_txt[4] = obj.text.to!string; + foreach(k; 5..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 5: + lv_ancestors_txt[5] = obj.text.to!string; + foreach(k; 6..8) { lv_ancestors_txt[k] = ""; } + goto default; + case 6: + lv_ancestors_txt[6] = obj.text.to!string; + lv_ancestors_txt[7] = ""; + goto default; + case 7: + lv_ancestors_txt[7] = obj.text.to!string; + goto default; + default: + obj.tags.heading_ancestors_text = lv_ancestors_txt.dup; + } + return obj; + } + static OCNset ocn_emit(int ocn_status_flag) { + return object_citation_number.ocn_emitter(ocn_status_flag); + } + static uint[string] _check_ocn_status_()( + char[] line, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if (!(line.empty)) { + if (pith["no_ocn_multiple_objects"] == eN.bi.off) { + // not multi-line object, check whether object_number is on or turned off + if (line.matchFirst(rgx.object_number_block_marks)) { // switch off object_number + if (line.matchFirst(rgx.object_number_off_block)) { + pith["no_ocn_multiple_objects"] = eN.bi.on; + pith["ocn"] = eN.ocn.off; + debug(ocnoff) { writeln(line); } + } + if (line.matchFirst(rgx.object_number_off_block_dummy_heading)) { + pith["no_ocn_multiple_objects"] = eN.bi.on; + pith["dummy_heading_multiple_objects"] = eN.bi.on; + pith["ocn"] = eN.ocn.off; + debug(ocnoff) { writeln(line); } + } + } else if (pith["no_ocn_multiple_objects"] == eN.bi.off) { + pith["dummy_heading_status"] = eN.bi.off; + if (pith["dummy_heading_multiple_objects"]) { + pith["dummy_heading_status"] = eN.bi.on; + } + if (line.matchFirst(rgx.object_number_off)) { + pith["ocn"] = eN.ocn.off; + } else if (line.matchFirst(rgx.object_number_off_dummy_heading)) { + pith["ocn"] = eN.ocn.off; + pith["dummy_heading_status"] = eN.bi.on; + } else { + pith["ocn"] = eN.ocn.on; + pith["dummy_heading_status"] = eN.bi.off; + } + } else { + pith["ocn"] = pith["no_ocn_multiple_objects"]; + } + } else if (pith["no_ocn_multiple_objects"] == eN.bi.on) { + if (line.matchFirst(rgx.object_number_off_block_close)) { + pith["no_ocn_multiple_objects"] = eN.bi.off; + pith["ocn"] = eN.ocn.on; + pith["dummy_heading_status"] = eN.bi.off; + debug(ocnoff) { writeln(line); } + } + } + } + return pith; + } + // ↑ - emitters ↑ + // ↓ abstraction functions + // ↓ - reset text by line + @system ST_txt_by_line_common_reset txt_by_line_common_reset_()( + int[string] line_occur, + string[string] an_object, + uint[string] pith, + ) { + line_occur["heading"] = eN.bi.off; + line_occur["para"] = eN.bi.off; + pith["txt_is"] = eN.txt_is.off; + an_object = an_object.object_reset; + ST_txt_by_line_common_reset ret; + { + ret.line_occur = line_occur; + ret.this_object = an_object; + ret.pith = pith; + } + return ret; + } + // ↓ - reset object + static string[string] object_reset()(string[string] an_object) { + an_object.remove("body_nugget"); + an_object.remove("substantive"); + an_object.remove("is"); + an_object.remove("attrib"); + an_object.remove("bookindex_nugget"); + return an_object; + } + // ↑ - resets + // ↓ - markup text by line + char[] font_faces_line()(char[] textline) { + static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); + if (textline.match(rgx.inline_faces_line)) { + textline = textline + .replaceFirst(rgx.inline_emphasis_line, + format(q"┃%s%s%s%s%s%s%s┃", + mkup.ff_i, mkup.emph, mkup.ff_o, "$1", mkup.ff_c, mkup.emph, "$2")) + .replaceFirst(rgx.inline_bold_line, + format(q"┃%s%s%s%s%s%s%s┃", + mkup.ff_i, mkup.bold, mkup.ff_o, "$1", mkup.ff_c, mkup.bold, "$2")) + .replaceFirst(rgx.inline_underscore_line, + format(q"┃%s%s%s%s%s%s%s┃", + mkup.ff_i, mkup.underscore, mkup.ff_o, "$1", mkup.ff_c, mkup.underscore, "$2")) + .replaceFirst(rgx.inline_italics_line, + format(q"┃%s%s%s%s%s%s%s┃", + mkup.ff_i, mkup.italic, mkup.ff_o, "$1", mkup.ff_c, mkup.italic, "$2")); + } + return textline; + } + auto inline_markup_faces(L)(L line) { + static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); + line = replaceAll!(m => mkup.quote_o ~ m[1] ~ mkup.quote_c)(line, rgx.within_quotes); + line = replaceAll!(m => mkup.ff_i ~ mkup.mono ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.mono)(line, rgx.inline_mark_mono); + line = replaceAll!(m => mkup.ff_i ~ mkup.cite ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.cite)(line, rgx.inline_mark_cite); + foreach (regx; [rgx.inline_mark_emphasis, rgx.inline_mark_bold, rgx.inline_mark_underscore, rgx.inline_mark_italics, rgx.inline_mark_superscript, rgx.inline_mark_subscript, rgx.inline_mark_strike, rgx.inline_mark_insert]) { + line = replaceAll!(m => mkup.ff_i ~ m["mark"] ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ m["mark"])(line, regx); + } + return line; + } + static string links_and_images()(string obj_txt) { + static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); + if (obj_txt.match(rgx.smid_inline_url_generic)) { + if ( + obj_txt.match(rgx.smid_inline_link_endnote_url_helper) + || obj_txt.match(rgx.smid_inline_link_endnote_url_helper_punctuated) + ) { + obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s%s", + mkup.lnk_o, m["content"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c, + mkup.en_a_o, + mkup.lnk_o, m["link"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c, + mkup.en_a_c, + m[3] + ))(obj_txt, rgx.smid_inline_link_endnote_url_helper_punctuated); + obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s", + mkup.lnk_o, m["content"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c, + mkup.en_a_o, + mkup.lnk_o, m["link"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c, + mkup.en_a_c + ))(obj_txt, rgx.smid_inline_link_endnote_url_helper); + } else { + obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s", + m["pre"], + mkup.lnk_o, m["content"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c + ))(obj_txt, rgx.smid_inline_link_markup_regular); + } + obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s", + m["pre"], + mkup.lnk_o, m["link"].strip, mkup.lnk_c, + mkup.url_o, m["link"], mkup.url_c + ))(obj_txt, rgx.smid_inline_link_naked_url); // + } + return obj_txt; + } + char[] _doc_header_and_make_substitutions_(CMM)( + char[] line, + CMM conf_make_meta, + ) { + enum Substitute { match, markup, } + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + line = line.replaceAll( + regex("\b" ~ substitution_pair[Substitute.match]), + substitution_pair[Substitute.markup] + ); + } + } + return line; + } + char[] _doc_header_and_make_substitutions_fontface_(CMM)( + char[] line, + CMM conf_make_meta, + ) { + enum Substitute { match, markup, } + if ( conf_make_meta.make.bold) { + line = line.replaceAll( + regex("\b" ~ conf_make_meta.make.bold[Substitute.match]), + conf_make_meta.make.bold[Substitute.markup] + ); + } + if (conf_make_meta.make.emphasis) { + line = line.replaceAll( + regex("\b" ~ conf_make_meta.make.emphasis[Substitute.match]), + conf_make_meta.make.emphasis[Substitute.markup] + ); + } + if (conf_make_meta.make.italics) { + line = line.replaceAll( + regex("\b" ~ conf_make_meta.make.italics[Substitute.match]), + conf_make_meta.make.italics[Substitute.markup] + ); + } + return line; + } + // ↑ - markup by line + // ↓ - text by line (blocks etc.) + ST_txt_by_line_block_start txt_by_line_block_start()( + char[] line, + uint[string] pith, + uint[string] dochas, + string[string] object_number_poem + ) { + static auto rgx = RgxI(); + if (auto m = line.matchFirst(rgx.block_curly_code_open)) { + dochas["codeblock"]++; + an_object["lang"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; + debug(codecurly) { writefln( "* [code curly] %s", line); } // code (curly) open + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + } else if (auto m = line.matchFirst(rgx.block_curly_poem_open)) { + dochas["poem"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(poem) { writefln( "* [poem curly] %s", line); } // poem (curly) open + object_number_poem["start"] = obj_cite_digits.object_number.to!string; + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + pith["verse_new"] = eN.bi.on; + } else if (auto m = line.matchFirst(rgx.block_curly_group_open)) { + dochas["group"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(group) { writefln( "* [group curly] %s", line); } // group (curly) open + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + } else if (auto m = line.matchFirst(rgx.block_curly_block_open)) { + dochas["block"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(block) { writefln( "* [block curly] %s", line); } + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + } else if (auto m = line.matchFirst(rgx.block_curly_quote_open)) { + dochas["quote"]++; + an_object["syntax"] = ""; + an_object["attrib"] = m["attrib"].to!string; + an_object["lang"] = m["lang"].to!string; + debug(quote) { writefln( "* [quote curly] %s", line); } + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + } else if (auto m = line.matchFirst(rgx.block_curly_table_open)) { // curly table open + debug(table) { writefln( "* [table curly] %s", line); } + dochas["table"] ++; + an_object["table_head"] = m["attrib"].to!string; + an_object["block_type"] = "curly"; + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly; + } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { // table: special table block markup syntax! + dochas["table"]++; + an_object["table_head"] = m["attrib"].to!string; + an_object["block_type"] = "special"; + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.curly_special; + } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { + dochas["codeblock"]++; + an_object["lang"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; + debug(codetic) { writefln( "* [code tic] %s", line); } + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + } else if (auto m = line.matchFirst(rgx.block_tic_poem_open)) { + dochas["poem"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(poem) { writefln( "* [poem tic] %s", line); } + object_number_poem["start"] = obj_cite_digits.object_number.to!string; + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + pith["verse_new"] = eN.bi.on; + } else if (auto m = line.matchFirst(rgx.block_tic_group_open)) { + dochas["group"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(group) { writefln( "* [group tic] %s", line); } + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + } else if (auto m = line.matchFirst(rgx.block_tic_block_open)) { + dochas["block"]++; + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; + debug(block) { writefln( "* [block tic] %s", line); } + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + } else if (auto m = line.matchFirst(rgx.block_tic_quote_open)) { + dochas["quote"]++; + an_object["syntax"] = ""; + an_object["attrib"] = m["attrib"].to!string; + an_object["lang"] = m["lang"].to!string; + debug(quote) { writefln( "* [quote tic] %s", line); // quote (tic) open + } + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + } else if (auto m = line.matchFirst(rgx.block_tic_table_open)) { // tic table open + debug(table) { writefln( "* [table tic] %s", line); } + dochas["table"] ++; + an_object["table_head"] = m["attrib"].to!string; + an_object["block_type"] = "tic"; + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.on; + pith["block_delim"] = eN.blk_delim.tic; + } + ST_txt_by_line_block_start ret; + { + ret.pith = pith; + ret.dochas = dochas; + ret.object_number_poem = object_number_poem; + } + return ret; + } + ST_txt_by_line_block_generic txt_by_line_block_group()( + char[] line, + string[string] an_object, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if (pith["block_is"] == eN.blk_is.group) { + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_group_close)) { + debug(group) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(group) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(group) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.group; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(group) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } + } + ST_txt_by_line_block_generic ret; + { + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + ST_txt_by_line_block_generic txt_by_line_block_block()( + char[] line, + string[string] an_object, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if (pith["block_is"] == eN.blk_is.block) { + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_block_close)) { + debug(block) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(block) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(block) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(block) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } + } + ST_txt_by_line_block_generic ret; + { + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + ST_txt_by_line_block_poem txt_by_line_block_poem(CMM)( + char[] line, + string[string] an_object, + uint[string] pith, + int cntr, + string[string] object_number_poem, + CMM conf_make_meta, + string[string] tag_in_seg, + ) { + static auto rgx = RgxI(); + if (pith["block_is"] == eN.blk_is.poem) { + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_poem_close)) { + if (an_object_key in an_object + || processing.length > 0) { + an_object[an_object_key] = ""; + debug(poem) { writefln( "* [poem curly] %s", line); } + if (processing.length > 0) { + an_object[an_object_key] = processing["verse"]; + } + debug(poem) { + writeln(__LINE__); + writefln( "* %s %s", obj_cite_digits.object_number, line); + } + if (an_object.length > 0) { + debug(poem) { writeln( obj_cite_digits.object_number, an_object[an_object_key]); } + an_object["is"] = "verse"; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + } + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + object_number_poem["end"] = obj_cite_digits.object_number.to!string; + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + processing["verse"] ~= line ~= "\n"; + if (pith["verse_new"] == eN.bi.on) { + obj_cite_digits = ocn_emit(pith["ocn"]); + pith["verse_new"] = eN.bi.off; + } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { + processing["verse"] = processing["verse"].stripRight; + verse_line = eN.bi.off; + pith["verse_new"] = eN.bi.on; + } + if (pith["verse_new"] == eN.bi.on) { + verse_line = 1; + an_object[an_object_key] = processing["verse"]; + debug(poem) { writefln( + "* %s curly\n%s", + obj_cite_digits.object_number, + an_object[an_object_key] + ); + } + processing.remove("verse"); + an_object["is"] = "verse"; + auto comp_obj_location = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (auto m = line.matchFirst(rgx.block_tic_close)) { + an_object[an_object_key] = "verse"; + debug(poem) { writefln( "* [poem tic] %s", line); } + if (processing.length > 0) { + an_object[an_object_key] = processing["verse"]; + } + if (an_object.length > 0) { + debug(poem) { writeln(__LINE__); writeln(obj_cite_digits.object_number, line); } + processing.remove("verse"); + an_object["is"] = "verse"; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + object_number_poem["end"] = obj_cite_digits.object_number.to!string; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + processing["verse"] ~= line ~= "\n"; + if (pith["verse_new"] == eN.bi.on) { + obj_cite_digits = ocn_emit(pith["ocn"]); + pith["verse_new"] = eN.bi.off; + } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { + processing["verse"] = processing["verse"].stripRight; + pith["verse_new"] = eN.bi.on; + verse_line = eN.bi.off; + } + if (pith["verse_new"] == eN.bi.on) { + verse_line = 1; + an_object[an_object_key] = processing["verse"]; + debug(poem) { writefln( + "* %s tic\n%s", + obj_cite_digits.object_number, + an_object[an_object_key] + ); + } + processing.remove("verse"); + an_object["is"] = "verse"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + } + } + } + ST_txt_by_line_block_poem ret; + { + ret.cntr = cntr; + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + ST_txt_by_line_block_generic txt_by_line_block_code()( + char[] line, + string[string] an_object, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if ( pith["block_is"] == eN.blk_is.code) { + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_code_close)) { + debug(codecurly) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.newline_eol_delimiter_only, "") + .stripRight; + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(codecurly) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(codetic) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.newline_eol_delimiter_only, "") + .stripRight; + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(codetic) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } + } + ST_txt_by_line_block_generic ret; + { + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + @system auto txt_by_line_block_table(CMM)( + char[] line, + string[string] an_object, + uint[string] pith, + CMM conf_make_meta, + ) { + static auto rgx = RgxI(); + if (pith["block_is"] == eN.blk_is.table) { + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_table_close)) { + debug(table) { writeln(line); } + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(table) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.curly_special) { + if (line.empty) { + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + { + auto _get = line.flow_table_closed_make_special_notation_table_( + an_object, + the_document_body_section, + obj_cite_digits, + comp_obj_, + cntr, + pith, + conf_make_meta, + ); + { + an_object = _get.this_object; + the_document_body_section = _get.the_document_body_section; + obj_cite_digits = _get.obj_cite_digits; + comp_obj_ = _get.comp_obj_; + cntr = _get.cntr; + pith = _get.pith; + } + } + } else { + debug(table) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(table) { writeln(line); } + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(table) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } + } + struct ST_txt_by_line_block_table { + CMM conf_make_meta; + uint[string] pith; + string[string] this_object; + } + ST_txt_by_line_block_table ret; + { + ret.conf_make_meta = conf_make_meta, + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + ST_txt_by_line_block_generic txt_by_line_block_quote()( + char[] line, + string[string] an_object, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if (pith["block_is"] == eN.blk_is.quote){ + if (pith["block_delim"] == eN.blk_delim.curly) { + if (line.matchFirst(rgx.block_curly_quote_close)) { + debug(quote) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(quote) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } else if (pith["block_delim"] == eN.blk_delim.tic) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(quote) { writeln(line); } + an_object[an_object_key] = an_object[an_object_key].stripRight; + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.closing; + pith["block_delim"] = eN.blk_delim.off; + } else { + debug(quote) { writeln(line); } + an_object[an_object_key] ~= line ~= "\n"; + } + } + } + ST_txt_by_line_block_generic ret; + { + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + @system ST_txt_by_line_block_biblio txt_by_line_block_biblio( + char[] line, + uint[string] pith, + int bib_entry, + string biblio_entry_str_json, + string[] biblio_arr_json, + ) { + mixin spineBiblio; + auto jsn = BibJsnStr(); + static auto rgx = RgxI(); + string biblio_tag_map()(string abr) { + auto btm = [ + "au" : "author_raw", + "ed" : "editor_raw", + "ti" : "fulltitle", + "lng" : "language", + "jo" : "journal", + "vol" : "volume", + "edn" : "edition", + "yr" : "year", + "pl" : "place", + "pb" : "publisher", + "pub" : "publisher", + "pg" : "pages", + "pgs" : "pages", + "sn" : "short_name" + ]; + return btm[abr]; + } + if (line.matchFirst(rgx.heading_biblio)) { + pith["section"] = eN.sect.bibliography; + } + if (line.empty) { + debug { + debug(biblioblock) { writeln("---"); } + debug(biblioblockinclude) { writeln(biblio_entry_str_json.length); } + } + if ((bib_entry == eN.bi.off) + && (biblio_entry_str_json.empty)) { + bib_entry = eN.bi.on; + biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; + } else if (!(biblio_entry_str_json.empty)) { + bib_entry = eN.bi.off; + if (!(biblio_entry_str_json == jsn.biblio_entry_tags_jsonstr)) { + auto biblio_entry = parseJSON(biblio_entry_str_json); + if (biblio_entry["fulltitle"].str.empty) { + writeln("check problem entry (Title missing): ", biblio_entry_str_json); + } else if ((biblio_entry["author_raw"].str.empty) && (biblio_entry["editor_raw"].str.empty)) { + writeln("check problem entry (No author and no editor): ", biblio_entry_str_json); + } else { + biblio_arr_json ~= biblio_entry_str_json; + } + biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; + } + } else { + writeln("?? 2. ERROR ", biblio_entry_str_json, "??"); + biblio_entry_str_json = ""; + } + } else if (line.matchFirst(rgx.biblio_tags)) { + debug(biblioblock) { writeln(line); } + auto bt = line.match(rgx.biblio_tags); + bib_entry = eN.bi.off; + st = bt.captures[1].to!string; + auto header_tag_value = (bt.captures[2]).to!string; + JSONValue j = parseJSON(biblio_entry_str_json); + biblio_tag_name = (st.match(rgx.biblio_abbreviations)) + ? (biblio_tag_map(st)) + : st; + j.object[biblio_tag_name] = header_tag_value; + debug(bibliounsortedcheckduplicates) { writeln(biblio_tag_name, ": ", header_tag_value); writeln("--"); } + switch (biblio_tag_name) { + case "author_raw": // author_arr author (fn sn) + j["author_arr"] + = header_tag_value.split(rgx.arr_delimiter); + string tmp; + biblioAuthorLoop: + foreach (au; j["author_arr"].array) { + if (auto x = au.str.match(rgx.name_delimiter)) { + tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; + } else { + tmp ~= au.str; + } + } + tmp = tmp.replace(rgx.trailing_comma, ""); + j["author"].str = tmp; + goto default; + case "editor_raw": // editor_arr editor (fn sn) + j["editor_arr"] + = header_tag_value.split(rgx.arr_delimiter); + string tmp; + biblioEditorLoop: + foreach (ed; j["editor_arr"].array) { + if (auto x = ed.str.match(rgx.name_delimiter)) { + tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; + } else { + tmp ~= ed.str; + } + } + tmp = tmp.replace(rgx.trailing_comma, ""); + j["editor"].str = tmp; + goto default; + case "fulltitle": // title & subtitle + goto default; + default: + break; + } + auto s = j.toString(); + debug(biblio1) { writefln( + "* %s: %s\n%s", + biblio_tag_name, + biblio_tag_entry, + j[biblio_tag_name] + ); + } + if (line.match(rgx.comment)) { + writeln("ERROR", line, "COMMENT"); + writeln("ERROR", s, "%%"); + } + if (!(match(line, rgx.comment))) { + debug(biblioblockinclude) { writeln(line); } + biblio_entry_str_json = s; + } else { + biblio_entry_str_json = ""; + } + header_tag_value = ""; + } + ST_txt_by_line_block_biblio ret; + { + ret.pith = pith; + ret.bib_entry = bib_entry; + ret.biblio_entry_str_json = biblio_entry_str_json; + ret.biblio_arr_json = biblio_arr_json; + } + return ret; + } + // ↑ - text by line + // ↓ - para + string[string][string] inline_para_link_anchor()( + string[string] an_object, + string[string] tag_in_seg, + string[string][string] tag_assoc + ) { + static auto rgx = RgxI(); + if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) { + if (m.captures[1] !in tag_assoc) { + tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[(m.captures[1])]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; + } else { + writeln("a tag named already exists, check text line\n ", an_object["substantive"]); + } + } + return tag_assoc; + } + ST_flow_para_match flow_para_match_()( + char[] line, + string[string] an_object, + string an_object_key, + int[string] indent, + bool bullet, + uint[string] pith, + int[string] line_occur, + ) { + static auto rgx = RgxI(); + if (line_occur["para"] == eN.bi.off) { + line = font_faces_line(line); + // para matches + pith["txt_is"] = eN.txt_is.para; + an_object[an_object_key] ~= line; + indent = [ + "hang_position" : 0, + "base_position" : 0, + ]; + bullet = false; + if (auto m = line.matchFirst(rgx.para_indent)) { + debug(paraindent) { writeln(line); } + indent["hang_position"] = (m["indent"]).to!int; + indent["base_position"] = (m["indent"]).to!int; + } else if (line.matchFirst(rgx.para_bullet)) { + debug(parabullet) { writeln(line); } + bullet = true; + } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { + debug(paraindenthang) { writeln(line); } + indent = [ + "hang_position" : (m["hang"]).to!int, + "base_position" : (m["indent"]).to!int, + ]; + } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { + debug(parabulletindent) { writeln(line); } + indent = [ + "hang_position" : (m["indent"]).to!int, + "base_position" : (m["indent"]).to!int, + ]; + bullet = true; + } + ++line_occur["para"]; + } + ST_flow_para_match ret; + { + ret.pith = pith; + ret.this_object = an_object; + ret.this_object_key = an_object_key; + ret.indent = indent; + ret.bullet = bullet; + ret.line_occur = line_occur; + } + return ret; + } + // ↑ - para + // ↓ - heading + ST_flow_heading_found flow_heading_found_()( + char[] line, + string[string] heading_match_str, + string[] _make_unmarked_headings, + Regex!(char)[string] heading_match_rgx, + uint[string] pith, + ) { + static auto rgx = RgxI(); + if ((_make_unmarked_headings.length > 2) + && (pith["make_headings"] == eN.bi.off)) { // headings found + debug(headingsfound) { writeln(_make_unmarked_headings); } + debug(headingsfound) { + writeln(_make_unmarked_headings.length); + writeln(_make_unmarked_headings); + } + switch (_make_unmarked_headings.length) { + case 7 : + if (!empty(_make_unmarked_headings[6])) { + heading_match_str["h_4"] + = "^(" ~ _make_unmarked_headings[6].to!string ~ ")"; + heading_match_rgx["h_4"] + = regex(heading_match_str["h_4"]); + } + goto case; + case 6 : + if (!empty(_make_unmarked_headings[5])) { + heading_match_str["h_3"] + = "^(" ~ _make_unmarked_headings[5].to!string ~ ")"; + heading_match_rgx["h_3"] + = regex(heading_match_str["h_3"]); + } + goto case; + case 5 : + if (!empty(_make_unmarked_headings[4])) { + heading_match_str["h_2"] + = "^(" ~ _make_unmarked_headings[4].to!string ~ ")"; + heading_match_rgx["h_2"] + = regex(heading_match_str["h_2"]); + } + goto case; + case 4 : + if (!empty(_make_unmarked_headings[3])) { + heading_match_str["h_1"] + = "^(" ~ _make_unmarked_headings[3].to!string ~ ")"; + heading_match_rgx["h_1"] + = regex(heading_match_str["h_1"]); + } + goto case; + case 3 : + if (!empty(_make_unmarked_headings[2])) { + heading_match_str["h_D"] + = "^(" ~ _make_unmarked_headings[2].to!string ~ ")"; + heading_match_rgx["h_D"] + = regex(heading_match_str["h_D"]); + } + goto case; + case 2 : + if (!empty(_make_unmarked_headings[1])) { + heading_match_str["h_C"] + = "^(" ~ _make_unmarked_headings[1].to!string ~ ")"; + heading_match_rgx["h_C"] + = regex(heading_match_str["h_C"]); + } + goto case; + case 1 : + if (!empty(_make_unmarked_headings[0])) { + heading_match_str["h_B"] + = "^(" ~ _make_unmarked_headings[0].to!string ~ ")"; + heading_match_rgx["h_B"] + = regex(heading_match_str["h_B"]); + } + break; + default: + break; + } + pith["make_headings"] = eN.bi.on; + } + ST_flow_heading_found ret; + { + ret.heading_match_str = heading_match_str; + ret.heading_match_rgx = heading_match_rgx; + ret.pith = pith; + } + return ret; + } + ST_flow_heading_make_set flow_heading_make_set_()( + char[] line, + int[string] line_occur, + return ref Regex!(char)[string] heading_match_rgx, + return ref uint[string] pith, + ) { + if (pith["make_headings"] == eN.bi.on + && (line_occur["para"] == eN.bi.off + && line_occur["heading"] == eN.bi.off) + && pith["txt_is"] == eN.txt_is.off + ) { // heading make set + if (line.matchFirst(heading_match_rgx["h_B"])) { + line = "B~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_C"])) { + line = "C~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_D"])) { + line = "D~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_1"])) { + line = "1~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_2"])) { + line = "2~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_3"])) { + line = "3~ " ~ line; + debug(headingsfound) { writeln(line); } + } + if (line.matchFirst(heading_match_rgx["h_4"])) { + line = "4~ " ~ line; + debug(headingsfound) { writeln(line); } + } + } + ST_flow_heading_make_set ret; + { + ret.line = line; + ret.pith = pith; + ret.this_object = an_object; + } + return ret; + } + auto flow_heading_matched_(CMM)( + char[] line, + string[string] an_object, + int[string] line_occur, + string an_object_key, + int[string] lv, + int[string] collapsed_lev, + uint[string] pith, + CMM conf_make_meta, + ) { + static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); + if (auto m = line.match(rgx.headings)) { // heading match + ++line_occur["heading"]; + pith["txt_is"] = eN.txt_is.heading; + if (line.match(rgx.heading_seg_and_above)) { + pith["section"] = eN.sect.unset; + } + an_object[an_object_key] ~= line ~= "\n"; + an_object["lev"] ~= m.captures[1]; + assertions_doc_structure(an_object, an_object_key, lv); // includes most of the logic for collapsed levels + switch (an_object["lev"]) { + case "A": // Title set + if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author) + && an_object[an_object_key].match(rgx.variable_doc_date))) { + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_line_inline + ~ conf_make_meta.meta.creator_author + ~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")")) + .replaceFirst(rgx.variable_doc_title, + (conf_make_meta.meta.title_full ~ mkup.br_line_inline)) + .replaceFirst(rgx.variable_doc_author, + conf_make_meta.meta.creator_author) + .replaceFirst(rgx.variable_doc_date, + " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"); + } else if ((an_object[an_object_key].match(rgx.variable_doc_title_author)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author))) { + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_line_inline + ~ conf_make_meta.meta.creator_author)) + .replaceFirst(rgx.variable_doc_title, + (conf_make_meta.meta.title_full ~ mkup.br_line_inline)) + .replaceFirst(rgx.variable_doc_author, + conf_make_meta.meta.creator_author); + } else if (an_object[an_object_key].match(rgx.variable_doc_title)) { + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title, + conf_make_meta.meta.title_full); + } + collapsed_lev["h0"] = 0; + an_object["lev_collapsed_number"] + = collapsed_lev["h0"].to!string; + lv["lv"] = DocStructMarkupHeading.h_sect_A; + ++lv["h0"]; + lv["h1"] = eN.bi.off; + lv["h2"] = eN.bi.off; + lv["h3"] = eN.bi.off; + lv["h4"] = eN.bi.off; + lv["h5"] = eN.bi.off; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "B": + collapsed_lev["h1"] = collapsed_lev["h0"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h1"].to!string; + lv["lv"] = DocStructMarkupHeading.h_sect_B; + ++lv["h1"]; + lv["h2"] = eN.bi.off; + lv["h3"] = eN.bi.off; + lv["h4"] = eN.bi.off; + lv["h5"] = eN.bi.off; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "C": + collapsed_lev["h2"] = collapsed_lev["h1"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h2"].to!string; + lv["lv"] = DocStructMarkupHeading.h_sect_C; + ++lv["h2"]; + lv["h3"] = eN.bi.off; + lv["h4"] = eN.bi.off; + lv["h5"] = eN.bi.off; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "D": + collapsed_lev["h3"] = collapsed_lev["h2"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h3"].to!string; + lv["lv"] = DocStructMarkupHeading.h_sect_D; + ++lv["h3"]; + lv["h4"] = eN.bi.off; + lv["h5"] = eN.bi.off; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "1": + if (lv["h3"] > eN.bi.off) { + collapsed_lev["h4"] = collapsed_lev["h3"] + 1; + } else if (lv["h2"] > eN.bi.off) { + collapsed_lev["h4"] = collapsed_lev["h2"] + 1; + } else if (lv["h1"] > eN.bi.off) { + collapsed_lev["h4"] = collapsed_lev["h1"] + 1; + } else if (lv["h0"] > eN.bi.off) { + collapsed_lev["h4"] = collapsed_lev["h0"] + 1; + } + an_object["lev_collapsed_number"] + = collapsed_lev["h4"].to!string; + lv["lv"] = DocStructMarkupHeading.h_text_1; + ++lv["h4"]; + lv["h5"] = eN.bi.off; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "2": + if (lv["h5"] > eN.bi.off) { + an_object["lev_collapsed_number"] + = collapsed_lev["h5"].to!string; + } else if (lv["h4"] > eN.bi.off) { + collapsed_lev["h5"] = collapsed_lev["h4"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h5"].to!string; + } + lv["lv"] = DocStructMarkupHeading.h_text_2; + ++lv["h5"]; + lv["h6"] = eN.bi.off; + lv["h7"] = eN.bi.off; + goto default; + case "3": + if (lv["h6"] > eN.bi.off) { + an_object["lev_collapsed_number"] + = collapsed_lev["h6"].to!string; + } else if (lv["h5"] > eN.bi.off) { + collapsed_lev["h6"] = collapsed_lev["h5"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h6"].to!string; + } + lv["lv"] = DocStructMarkupHeading.h_text_3; + ++lv["h6"]; + lv["h7"] = eN.bi.off; + goto default; + case "4": + if (lv["h7"] > eN.bi.off) { + an_object["lev_collapsed_number"] + = collapsed_lev["h7"].to!string; + } else if (lv["h6"] > eN.bi.off) { + collapsed_lev["h7"] = collapsed_lev["h6"] + 1; + an_object["lev_collapsed_number"] + = collapsed_lev["h7"].to!string; + } + lv["lv"] = DocStructMarkupHeading.h_text_4; + ++lv["h7"]; + goto default; + default: + an_object["lev_markup_number"] = lv["lv"].to!string; + } + an_object["dummy_heading_status"] = (pith["dummy_heading_status"] == eN.bi.off) ? "f" : "t"; + debug(heading) { writeln(line.strip); } + } + struct ST_flow_heading_matched { + string[string] this_object; + int[string] line_occur; + string an_object_key; + int[string] lv; + int[string] collapsed_lev; + uint[string] pith; + CMM conf_make_meta; + } + ST_flow_heading_matched ret; + { + ret.this_object = an_object; + ret.line_occur = line_occur; + ret.an_object_key = an_object_key; + ret.lv = lv; + ret.collapsed_lev = collapsed_lev; + ret.pith = pith; + ret.conf_make_meta = conf_make_meta; + } + return ret; + } + // ↑ - heading + // ↓ - table + ObjGenericComposite flow_table_instructions(H)( + ObjGenericComposite table_object, + H table_head, + ) { + static auto rgx = RgxI(); + table_object.metainfo.is_of_part = "body"; + table_object.metainfo.is_of_section = "body"; + table_object.metainfo.is_of_type = "block"; + table_object.metainfo.is_a = "table"; + table_object.has.inline_notes_reg = false; + table_object.has.inline_notes_star = false; + table_object.has.inline_links = false; + if (auto m = table_head.matchFirst(rgx.table_head_instructions)) { + table_object.table.heading + = ((m["c_heading"].length > 0) && (m["c_heading"] == "h")) ? true : false; + table_object.table.number_of_columns + = ((m["c_num"].length > 0) && (m["c_num"].to!int > 0)) ? m["c_num"].to!int : 0; + foreach (cw; m["c_widths"].matchAll(rgx.table_col_widths)) { + auto x = cw.hit.matchFirst(rgx.table_col_widths_and_alignment); + table_object.table.column_widths ~= x["width"].to!int; + table_object.table.column_aligns ~= (x["align"].empty) ? "" : x["align"]; + } + } + return table_object; + } + ST_flow_table_array_munge flow_table_array_munge()( + ObjGenericComposite table_object, + string[][] table_array, + ) { + static auto rgx = RgxI(); + static auto mng = InlineMarkup(); + string _table_substantive; + ulong col_num; + ulong col_num_; + ulong col_num_chk = 0; + foreach(idx_r, row; table_array) { + debug(table_dev) { writeln("row ", idx_r); } + col_num_ = 0; + if (col_num == 0 + || col_num < row.length) { + col_num = row.length; + } + if (col_num_chk == 0) { + col_num_chk = col_num; + } else if (col_num == 1) { + debug(table_dev) { writeln("table note: "); } + } else if (col_num_chk != col_num) { + debug(table_dev) { writeln("warning irregular number of columns: ", col_num_chk, " != ", col_num); } + } else { + } + foreach(idx_c, col; row) { + debug(table_dev) { write(idx_c, ", "); } + col_num_ = idx_c; + _table_substantive ~= col ~ mng.tc_s; + if (idx_r == 0 && table_object.table.heading) { + } else if (col.match(rgx.numeric_col) && idx_r == 1) { // conditions reversed to avoid: gdc compiled program run segfault + if ((table_object.table.column_aligns.length > idx_c) + && (table_object.table.column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { + table_object.table.column_aligns[idx_c] = table_object.table.column_aligns[idx_c]; + } else if (table_object.table.column_aligns.length > idx_c) { + table_object.table.column_aligns[idx_c] = "r"; + } else { + table_object.table.column_aligns ~= "r"; + } + } else if (idx_r == 1) { + if ((table_object.table.column_aligns.length > idx_c) + && (table_object.table.column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { + table_object.table.column_aligns[idx_c] = table_object.table.column_aligns[idx_c]; + } else if (table_object.table.column_aligns.length > idx_c) { + table_object.table.column_aligns[idx_c] = "l"; + } else { + table_object.table.column_aligns ~= "l"; + } + } + } + debug(table_dev) { writeln(""); } + if (col_num_chk > 0 && (col_num != col_num_chk)) { + } else if (col_num == col_num_chk){ + } else { + col_num_chk = col_num; + } + _table_substantive = _table_substantive.replaceFirst(rgx.table_col_separator_nl, "\n"); + } + if (table_object.table.number_of_columns != col_num) { + if (table_object.table.number_of_columns == 0) { + table_object.table.number_of_columns = (col_num).to!int; + } else { + debug(table_dev) { writeln(table_object.table.number_of_columns, " != ", col_num); } + } + } + if (table_object.table.number_of_columns == 0 + && table_object.table.column_widths.length > 0) { + writeln(__LINE__, " ERROR"); + } + if (table_object.table.number_of_columns > 0 + && table_object.table.column_widths.length == 0) { + double col_w = (100.00 / table_object.table.number_of_columns); + foreach (i; 0..table_object.table.number_of_columns) { + table_object.table.column_widths ~= col_w; + } + } else if (table_object.table.number_of_columns + != table_object.table.column_widths.length) { + debug(table_dev) { writeln(m.hit); } // further logic required + if (table_object.table.number_of_columns > table_object.table.column_widths.length) { + double col_w = (100.00 - (table_object.table.column_widths).sum) + / (table_object.table.number_of_columns - table_object.table.column_widths.length); + foreach (i; 0..table_object.table.column_widths.length) { + table_object.table.column_widths ~= col_w; + } + foreach (i; 0..(table_object.table.number_of_columns - table_object.table.column_widths.length)) { + table_object.table.column_widths ~= col_w; + } + } else if (table_object.table.number_of_columns < table_object.table.column_widths.length) { + writeln(__LINE__, " warning, ERROR"); + } + } + if (table_object.table.column_widths.sum > 101 + || table_object.table.column_widths.sum < 95 ) { + writeln("sum: ", table_object.table.column_widths.sum, + ", array: ", table_object.table.column_widths, + ", cols: ", table_object.table.number_of_columns); + writeln(_table_substantive); + } + debug(table_res) { + writeln("aligns: ", table_object.table.column_aligns, "\n", + "no. of columns: ", table_object.table.number_of_columns, "\n", + "col widths: ", table_object.table.column_widths, + " sum: ", table_object.table.column_widths.sum, "\n", + _table_substantive); + } + table_object.text = _table_substantive; + ST_flow_table_array_munge ret; + { + ret.table_object = table_object; + ret.table_array = table_array; + } + return ret; + } + @system ST_flow_table_substantive_munge flow_table_substantive_munge()( + ObjGenericComposite table_object, + string table_substantive, + ) { + static auto rgx = RgxI(); + static auto munge = ObjInlineMarkupMunge(); + string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter); + string[] _table_cols; + string[][] _table_array; + foreach(col; _table_rows) { + _table_cols = col.split(rgx.table_col_delimiter); + _table_array ~= _table_cols; + } + { + auto _get = table_object.flow_table_array_munge(_table_array); + { + table_object = _get.table_object; + _table_array = _get.table_array; // what do you do with this? how is this passed down? + } + } + ST_flow_table_substantive_munge ret; + { + ret.table_object = table_object; + ret.table_substantive = table_substantive; // has anything been changed here? + } + return ret; + } + @system ST_flow_table_substantive_munge flow_table_substantive_munge_special()( + ObjGenericComposite table_object, + string table_substantive, + ) { + static auto rgx = RgxI(); + static auto munge = ObjInlineMarkupMunge(); + string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter_special); + string[] _table_cols; + string[][] _table_array; + foreach(col; _table_rows) { + _table_cols = col.split(rgx.table_col_delimiter_special); + _table_array ~= _table_cols; + } + { + auto _get = table_object.flow_table_array_munge(_table_array); + { + table_object = _get.table_object; + _table_array = _get.table_array; + } + } + ST_flow_table_substantive_munge ret; + { + ret.table_object = table_object; + ret.table_substantive = table_substantive; + } + return ret; + } + @system ST_flow_table_closed_make_special_notation_table flow_table_closed_make_special_notation_table_(CMM)( + char[] line, + string[string] an_object, + ObjGenericComposite[] the_document_body_section, + OCNset obj_cite_digits, + ObjGenericComposite comp_obj_, + int cntr, + uint[string] pith, + CMM conf_make_meta + ) { + comp_obj_ = comp_obj_.init; + obj_cite_digits = ocn_emit(pith["ocn"]); + auto comp_obj_location = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + "table" + ); + an_object["is"] = "table"; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + comp_obj_.metainfo.ocn = obj_cite_digits.object_number; + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]); + { + auto _get = comp_obj_.flow_table_substantive_munge_special(an_object["substantive"]); + { + comp_obj_ = _get.table_object; + an_object["substantive"] = _get.table_substantive; + } + } + the_document_body_section ~= comp_obj_; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + ST_flow_table_closed_make_special_notation_table ret; + { + ret.this_object = an_object; + ret.the_document_body_section = the_document_body_section; + ret.obj_cite_digits = obj_cite_digits; + ret.comp_obj_ = comp_obj_; + ret.cntr = cntr; + ret.pith = pith; + } + return ret; + } + // ↑ - table + + @system ST_flow_block_flag_line_empty flow_block_flag_line_empty_(B,CMM,Ts)( + char[] line, + string[string] an_object, + B bookindex_extract_hash, + ObjGenericComposite[] the_document_body_section, + string[][string][string] bookindex_unordered_hashes, + OCNset obj_cite_digits, + ObjGenericComposite comp_obj_, + int cntr, + uint[string] pith, + string[string] object_number_poem, + CMM conf_make_meta, + Ts tag_in_seg, + ) { + assert( + line.empty, + "\nline should be empty:\n \"" + ~ line ~ "\"" + ); + assert( + (pith["block_state"] == eN.blk_state.closing), + "code block status: closed" + ); + static auto rgx = RgxI(); + if (pith["block_state"] == eN.blk_state.closing) { + if (pith["block_is"] == eN.blk_is.quote) { + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "quote"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "quote", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_.metainfo.lang = an_object["lang"]; + comp_obj_.metainfo.attrib = an_object["attrib"]; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + pith["block_is"] = eN.blk_is.quote; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } else if (pith["block_is"] == eN.blk_is.group) { + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "group"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "group", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.metainfo.lang = an_object["lang"]; + comp_obj_.metainfo.attrib = an_object["attrib"]; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } else if (pith["block_is"] == eN.blk_is.block) { + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "block"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + // anchor_tag = substantive_obj_misc_struct.anchor_tag; // check + comp_obj_ = set_object_generic("body", "body", "block", "block", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_.metainfo.lang = an_object["lang"]; + comp_obj_.metainfo.attrib = an_object["attrib"]; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + pith["block_is"] = eN.blk_is.block; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } else if (pith["block_is"] == eN.blk_is.poem) { + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "verse"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + comp_obj_poem_ocn = set_object_generic("body", "body", "block", "poem", "", obj_cite_digits.object_number); + comp_obj_poem_ocn.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_poem_ocn.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_poem_ocn.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_poem_ocn.metainfo.object_number_type = obj_cite_digits.type; + the_document_body_section ~= comp_obj_poem_ocn; + pith["block_is"] = eN.blk_is.poem; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + } else if (pith["block_is"] == eN.blk_is.code) { + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "code"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + anchor_tag = substantive_obj_misc_struct.anchor_tag; + comp_obj_ = set_object_generic("body", "body", "block", "code", an_object["substantive"], obj_cite_digits.object_number); + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.metainfo.syntax = an_object["syntax"]; + comp_obj_.metainfo.attrib = an_object["attrib"]; + comp_obj_.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links; + the_document_body_section ~= comp_obj_; + pith["block_is"] = eN.blk_is.code; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } else if (pith["block_is"] == eN.blk_is.table) { + comp_obj_ = comp_obj_.init; + obj_cite_digits = ocn_emit(pith["ocn"]); + an_object["bookindex_nugget"] + = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; + bookindex_unordered_hashes + = bookindex_extract_hash.bookindex_nugget_hash( + an_object["bookindex_nugget"], + obj_cite_digits, + tag_in_seg + ); + an_object["is"] = "table"; + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + an_object["is"] + ); + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct + = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); + an_object["substantive"] = substantive_obj_misc_struct.obj_txt; + comp_obj_ = comp_obj_.init; + comp_obj_.metainfo.ocn = obj_cite_digits.object_number; + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]); + { + auto _get = comp_obj_.flow_table_substantive_munge(an_object["substantive"]); + { + comp_obj_ = _get.table_object; + an_object["substantive"] = _get.table_substantive; + } + } + the_document_body_section ~= comp_obj_; + pith["block_is"] = eN.blk_is.table; + pith["block_state"] = eN.blk_state.off; + pith["block_delim"] = eN.blk_delim.off; + object_reset(an_object); + processing.remove("verse"); + ++cntr; + } + } + ST_flow_block_flag_line_empty ret; + { + ret.this_object = an_object; + ret.the_document_body_section = the_document_body_section; + ret.bookindex_unordered_hashes = bookindex_unordered_hashes; + ret.obj_cite_digits = obj_cite_digits; + ret.comp_obj_ = comp_obj_; // + ret.cntr = cntr; + ret.pith = pith; + } + return ret; + } + // ↓ - object set + ObjGenericComposite set_object_heading()( + string level, + string part, + string section, + string text, + ) { + ObjGenericComposite comp_obj; + { + comp_obj = comp_obj.init; + comp_obj.metainfo.is_of_part = part; + comp_obj.metainfo.is_of_section = section; + comp_obj.metainfo.is_of_type = "para"; + comp_obj.metainfo.is_a = "heading"; + comp_obj.text = text; + comp_obj.metainfo.ocn = 0; + if (level == "lev1") { + comp_obj.metainfo.heading_lev_markup = 1; + comp_obj.metainfo.heading_lev_collapsed = 1; + comp_obj.metainfo.parent_ocn = 1; + comp_obj.metainfo.parent_lev_markup = 0; + } else if (level == "lev4") { + comp_obj.metainfo.heading_lev_markup = 4; + comp_obj.metainfo.heading_lev_collapsed = 1; + comp_obj.metainfo.parent_ocn = 1; + comp_obj.metainfo.parent_lev_markup = 0; + comp_obj.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + } + } + return comp_obj; + } + ObjGenericComposite set_object_generic()( + string part, + string section, + string type, + string is_a, + string text, + int ocn, + ) { + ObjGenericComposite comp_obj; + { + comp_obj = comp_obj.init; + comp_obj.metainfo.is_of_part = part; + comp_obj.metainfo.is_of_section = section; + comp_obj.metainfo.is_of_type = type; + comp_obj.metainfo.is_a = is_a; + comp_obj.text = text; + comp_obj.metainfo.ocn = ocn; + } + return comp_obj; + } + // ↑ - object set + // ↓ - object inline munge + static struct ObjInlineMarkupMunge { + string[string] obj_txt; + int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; + string asterisks_, plus_; + string obj_txt_out, tail, note; + static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); + int stage_reset_note_numbers = true; + private auto initialize_note_numbers() { + n_foot = 0; + n_foot_reg = 0; + n_foot_sp_asterisk = 0; + n_foot_sp_plus = 0; + } + static auto images()(string obj_txt_in) { + static auto mng = InlineMarkup(); + // url matched + obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented + if (obj_txt_in.match(rgx.smid_image_generic)) { // images with and without links + debug(images) { writeln("Image: ", obj_txt_in); } + if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image_with_dimensions, ("$1" ~ mkup.img ~ "$2,w$3h$4 " ~ "$5")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); + debug(images) { writeln("IMAGE with size: ", obj_txt_in); } + } else if (obj_txt_in.match(rgx.smid_image)) { + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image, ("$1" ~ mkup.img ~ "$2,w0h0" ~ "$3")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); + debug(images) { writeln("IMAGE: ", obj_txt_in); } // decide on representation + } + } + return obj_txt_in; + } + ST_txtPlusHasFootnotes footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) { + // endnotes (regular) + bool flg_notes_reg = false; + bool flg_notes_star = false; + bool flg_notes_plus = false; + obj_txt_in = obj_txt_in.replaceAll( + rgx.inline_notes_curly, + (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) + ); + if (!(stage_reset_note_numbers) && reset_note_numbers) { + stage_reset_note_numbers = true; + } + obj_txt_out = ""; + if (obj_txt_in.match(rgx.inline_notes_al_gen)) { + string[] _tmp_txt; + foreach (x; obj_txt_in.split("\n")) { + if (auto m = x.matchAll(rgx.inline_text_and_note_al_)) { + if (stage_reset_note_numbers) { + n_foot = 0; + n_foot_reg = 0; + n_foot_sp_asterisk = 0; + n_foot_sp_plus = 0; + } + stage_reset_note_numbers = false; + foreach(n; m) { + if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_star)) { + flg_notes_star = true; + ++n_foot_sp_asterisk; + asterisks_ = "*"; + n_foot = n_foot_sp_asterisk; + _tmp_txt ~= n.hit.to!string.replaceFirst( + rgx.inline_al_delimiter_open_symbol_star, + (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ") + ); + } else if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_plus)) { + flg_notes_plus = true; + ++n_foot_sp_plus; + plus_ = "*"; + n_foot = n_foot_sp_plus; + _tmp_txt ~= n.hit.to!string.replaceFirst( + rgx.inline_al_delimiter_open_symbol_plus, + (mkup.en_a_o ~ replicate(plus_, n_foot_sp_plus) ~ " ") + ); + } else if (n.hit.to!string.matchFirst(rgx.inline_al_delimiter_open_regular)) { + string _tmp_str = n.hit.to!string; + flg_notes_reg = true; + foreach (q; n.hit.to!string.matchAll(rgx.inline_al_delimiter_open_regular)) { + ++n_foot_reg; + n_foot = n_foot_reg; + _tmp_str = replaceFirst!(m => mkup.en_a_o ~ n_foot.to!string ~ " ") + (_tmp_str, rgx.inline_al_delimiter_open_regular); + } + _tmp_txt ~= _tmp_str; + } else { + _tmp_txt ~= n.hit.to!string; + } + } + obj_txt_out = _tmp_txt.join("\n"); + } + } + } else { + obj_txt_out = obj_txt_in; + } + ST_txtPlusHasFootnotes ret; + { + ret.obj_txt = obj_txt_out; + ret.has_notes_reg = flg_notes_reg; + ret.has_notes_star = flg_notes_star; + ret.has_notes_plus = flg_notes_plus; + } + return ret; + } + private ST_txtPlusHasFootnotesUrlsImages object_notes_and_links_()( + string obj_txt_in, + bool reset_note_numbers = false + ) { + obj_txt_out = ""; + bool urls = false; + bool images_without_dimensions = false; + tail = ""; + // special endnotes + obj_txt_in = obj_txt_in.replaceAll( + rgx.inline_notes_curly_sp_asterisk, + (mkup.en_a_o ~ "*" ~ " $1" ~ mkup.en_a_c) + ); + obj_txt_in + = obj_txt_in.replaceAll( + rgx.inline_notes_curly_sp_plus, + (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) + ); + // image matched + if (obj_txt_in.match(rgx.smid_image_generic)) { + obj_txt_in = images(obj_txt_in); + if (obj_txt_in.match(rgx.smid_mod_image_without_dimensions)) { + images_without_dimensions = true; + } + } + // url matched + if (obj_txt_in.match(rgx.smid_inline_url)) { + urls = true; + obj_txt_in = obj_txt_in.links_and_images; + } + if (auto m = obj_txt_in.match(rgx.para_inline_link_anchor)) { + obj_txt_in = obj_txt_in + .replaceAll(rgx.para_inline_link_anchor, "┃$1┃"); + } + ST_txtPlusHasFootnotes ftn = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); + obj_txt_out = ftn.obj_txt; + debug(footnotes) { writeln(obj_txt_out, tail); } + obj_txt_out = obj_txt_out ~ tail; + debug(footnotesdone) { + foreach(m; matchAll(obj_txt_out, (mkup.en_a_o ~ `\s*(.+?)` ~ mkup.en_a_c))) { + writeln(m[1]); + writeln(m.hit); + } + } + ST_txtPlusHasFootnotesUrlsImages ret; + { + ret.obj_txt = obj_txt_out; + ret.has_notes_reg = ftn.has_notes_reg; + ret.has_notes_star = ftn.has_notes_star; + ret.has_notes_plus = ftn.has_notes_plus; + ret.has_urls = urls; + ret.has_images_without_dimensions = images_without_dimensions; + } + return ret; + } + private ST_txtPlusHasFootnotesUrlsImages object_only_()( + string obj_txt_in, + bool reset_note_numbers = false + ) { + ST_txtPlusHasFootnotesUrlsImages ret; + { + ret.obj_txt = obj_txt_in; + ret.has_notes_reg = false; + ret.has_notes_star = false; + ret.has_notes_plus = false; + ret.has_urls = false; + ret.has_images_without_dimensions = false; + } + return ret; + } + ST_txtPlusHasFootnotesUrlsImages init() { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(""); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_heading()( + string obj_txt_in, + bool reset_note_numbers = false + ) { + obj_txt["munge"] = obj_txt_in + .replaceFirst(rgx.headings, "") + .replaceFirst(rgx.object_number_off_all, "") + .replaceFirst(rgx.markup_inline_linebreak, mkup.br_line_inline) + .strip; + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); + debug(munge) { writeln(__LINE__); writeln(obj_txt_in); writeln(__LINE__); writeln(obj_txt["munge"].to!string); } + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_para()(string obj_txt_in) { + obj_txt["munge"] = (obj_txt_in) + .replaceFirst(rgx.para_attribs, "") + .replaceFirst(rgx.object_number_off_all, "") + .replaceFirst(rgx.markup_inline_linebreak, mkup.br_line_inline); + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt["munge"]); + debug(munge) { writeln(__LINE__); writeln(obj_txt_in); + writeln(__LINE__); + writeln(obj_txt["munge"].to!string); + } + return ret; + } + ST_txtPlusHasFootnotesUrlsImages munge_quote()(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in.split("\n\n").join(" \\\\\n \\\\\n")); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_group(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in.split("\n\n").join("\n" ~ mkup.br_line_spaced ~ "\n")); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_block()(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); + return ret; + } + invariant() { + } + auto munge_verse()(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_code()(string obj_txt_in) { + obj_txt_in = obj_txt_in.replaceAll(rgx.space, mkup.nbsp); + ST_txtPlusHasFootnotesUrlsImages ret = object_only_(obj_txt_in); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_table()(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_notes_and_links_(obj_txt_in); + return ret; + } + invariant() { + } + ST_txtPlusHasFootnotesUrlsImages munge_comment()(string obj_txt_in) { + ST_txtPlusHasFootnotesUrlsImages ret = object_only_(obj_txt_in); + return ret; + } + invariant() { + } + } + // ↑ - object inline munge + // ↓ - object inline markup + static struct ObjInlineMarkup { + static auto rgx = RgxI(); + static auto munge = ObjInlineMarkupMunge(); + string[string] obj_txt; + string anchor_tag = ""; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages obj_inline_markup_and_anchor_tags_and_misc(CMM)( + string[string] obj_, + string obj_key_, + CMM conf_make_meta, + Flag!"_new_doc" _new_doc + ) { + obj_txt["munge"] = obj_[obj_key_].dup; + obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) + ? obj_txt["munge"] + : obj_txt["munge"].strip; + if (_new_doc) { + anchor_tag = ""; + } + auto x = munge.init; + ST_txtAndAnchorTagPlusHasFootnotesUrlsImages ret; + ret.obj_txt = ""; + ret.anchor_tag = ""; + ret.has_notes_reg = false; + ret.has_notes_star = false; + ret.has_notes_plus = false; + ret.has_links = false; + ret.has_images_without_dimensions = false; + if ((obj_["is"] == "para") + || (obj_["is"] == "heading") + || (obj_["is"] == "quote") + || (obj_["is"] == "group") + || (obj_["is"] == "block") + || (obj_["is"] == "verse")) { + obj_txt["munge"] = (obj_txt["munge"]).inline_markup_faces; + obj_txt["munge"] = (obj_txt["munge"]).links_and_images; + } + switch (obj_["is"]) { + case "heading": + if (_new_doc) { + anchor_tag = ""; + } + obj_txt["munge"] = _configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc); + obj_txt["munge"] = _make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); + if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { + anchor_tag = m.captures[1]; + } else if (obj_["lev"] == "1") { + writeln("heading anchor tag missing: ", obj_txt["munge"]); + } + x = munge.munge_heading(obj_txt["munge"], reset_note_numbers); + reset_note_numbers = false; + goto default; + case "para": + x = munge.munge_para(obj_txt["munge"]); + goto default; + case "group": + x = munge.munge_group(obj_txt["munge"]); + goto default; + case "block": + x = munge.munge_block(obj_txt["munge"]); + goto default; + case "quote": + x = munge.munge_quote(obj_txt["munge"]); + goto default; + case "verse": + x = munge.munge_verse(obj_txt["munge"]); + goto default; + case "code": + x = munge.munge_code(obj_txt["munge"]); + goto default; + case "table": + x = munge.munge_table(obj_txt["munge"]); + goto default; + case "comment": + x = munge.munge_comment(obj_txt["munge"]); + goto default; + case "doc_end_reset": + munge.initialize_note_numbers(); + break; + default: + // para, heading, group, block, verse + ret.obj_txt = x.obj_txt; + ret.anchor_tag = anchor_tag; + ret.has_notes_reg = x.has_notes_reg; + ret.has_notes_star = x.has_notes_star; + ret.has_notes_plus = x.has_notes_plus; + ret.has_links = x.has_urls; + ret.has_images_without_dimensions = x.has_images_without_dimensions; + break; + } + anchor_tag = ""; + return ret; + } + invariant() { + } + auto _clean_heading_toc_()( + char[] heading_toc_, + ) { + auto m = (cast(char[]) heading_toc_).matchFirst(rgx.heading); + heading_toc_ = (m.post).replaceAll(rgx.inline_notes_curly_gen, ""); + return heading_toc_; + }; + ST_flow_table_of_contents_gather_headings flow_table_of_contents_gather_headings(CMM)( // + string[string] obj_, + CMM conf_make_meta, + string[string] tag_in_seg, + string _anchor_tag, + string[][string] lev4_subtoc, + ObjGenericComposite[] the_document_toc_section, + ) { + ObjGenericComposite comp_obj_; + mixin InternalMarkup; + static auto mkup = InlineMarkup(); + char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])) + .replaceAll(rgx.inline_notes_al, ""); + heading_toc_ = _clean_heading_toc_(heading_toc_); + auto attrib = ""; + string toc_txt_, subtoc_txt_; + int[string] indent; + if (obj_["lev_markup_number"].to!int > 0) { + indent = [ + "hang_position" : obj_["lev_markup_number"].to!int, + "base_position" : obj_["lev_markup_number"].to!int, + ]; + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + heading_toc_.strip, + mkup.lnk_c, + mkup.url_o, + _anchor_tag, + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", toc_txt_.to!string.strip, 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false; + comp_obj_.attrib.indent_hang = indent["hang_position"]; + comp_obj_.attrib.indent_base = indent["base_position"]; + comp_obj_.attrib.bullet = false; + comp_obj_.has.inline_links = true; + the_document_toc_section ~= comp_obj_; + } + comp_obj_ = comp_obj_.init; + comp_obj_.metainfo.is_of_part = "frontmatter"; + comp_obj_.metainfo.is_of_section = "toc"; + comp_obj_.metainfo.is_of_type = "para"; + comp_obj_.metainfo.is_a = "toc"; + comp_obj_.metainfo.ocn = 0; + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false; + comp_obj_.attrib.bullet = false; + comp_obj_.has.inline_links = true; + switch (obj_["lev_markup_number"].to!int) { + case 0: .. case 3: + break; + case 4: + lev4_subtoc[tag_in_seg["seg_lv4"]] = []; + break; + case 5: .. case 7: + subtoc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + heading_toc_.strip, + mkup.lnk_c, + mkup.url_o, + _anchor_tag, + mkup.url_c, + ); + lev4_subtoc[tag_in_seg["seg_lv4"]] + ~= links_and_images(obj_["lev_markup_number"] + ~ "~ " ~ subtoc_txt_.to!string.strip + ); + break; + default: + break; + } + ST_flow_table_of_contents_gather_headings ret; + { + ret.the_document_toc_section = the_document_toc_section; + ret.lev4_subtoc = lev4_subtoc; + } + return ret; + } + invariant() { + } + private: + static int[] heading_num = [ 0, 0, 0, 0 ]; + static string heading_number_auto_composite = ""; + static string heading_number_auto_composite_segname = ""; + static bool[] auto_heading_numbering = [ true, true, true, true]; + static string _configured_auto_heading_numbering_and_segment_anchor_tags(CMM)( + string munge_, + string[string] obj_, + CMM conf_make_meta, + bool _new_doc, + ) { + if (_new_doc) { + heading_num = [ 0, 0, 0, 0 ]; + heading_number_auto_composite = ""; + auto_heading_numbering = [ true, true, true, true]; + } + if (conf_make_meta.make.auto_num_top_lv) { + if (obj_["lev_markup_number"].to!int == 0) { + heading_num[0] = 0; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; + heading_number_auto_composite = ""; + } + // auto_num_depth minimum 0 + // (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement + if ( + conf_make_meta.make.auto_num_top_lv + > obj_["lev_markup_number"].to!uint + ) { + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; + } else if ( + conf_make_meta.make.auto_num_top_lv + == obj_["lev_markup_number"].to!uint + ) { + auto_heading_numbering[0] = + (munge_.match(rgx.auto_heading_numbering_off_lv1)) ? false : true; + if (auto_heading_numbering[0]) { + heading_num[0] ++; + } + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; + } else if ( + conf_make_meta.make.auto_num_top_lv + == (obj_["lev_markup_number"].to!uint - 1) + ) { + auto_heading_numbering[1] = + (munge_.match(rgx.auto_heading_numbering_off_lv2)) ? false : true; + if (auto_heading_numbering[0] + && auto_heading_numbering[1]) { + heading_num[1] ++; + } + heading_num[2] = 0; + heading_num[3] = 0; + } else if ( + conf_make_meta.make.auto_num_top_lv + == (obj_["lev_markup_number"].to!uint - 2) + ) { + auto_heading_numbering[2] = + (munge_.match(rgx.auto_heading_numbering_off_lv3)) ? false : true; + if (auto_heading_numbering[0] + && auto_heading_numbering[1] + && auto_heading_numbering[2]) { + heading_num[2] ++; + } + heading_num[3] = 0; + } else if ( + conf_make_meta.make.auto_num_top_lv + == (obj_["lev_markup_number"].to!uint - 3) + ) { + auto_heading_numbering[3] = + (munge_.match(rgx.auto_heading_numbering_off_lv4)) ? false : true; + if (auto_heading_numbering[0] + && auto_heading_numbering[1] + && auto_heading_numbering[2] + && auto_heading_numbering[3]) { + heading_num[3] ++; + } + } + if (auto_heading_numbering[0]) { + if (heading_num[3] > 0) { + heading_number_auto_composite + = (conf_make_meta.make.auto_num_depth.to!uint == 3 + && auto_heading_numbering[3]) + ? (format(q"┃%s.%s.%s.%s┃", + heading_num[0].to!string, + heading_num[1].to!string, + heading_num[2].to!string, + heading_num[3].to!string + )) + : ""; + } else if (heading_num[2] > 0) { + heading_number_auto_composite + = ((conf_make_meta.make.auto_num_depth.to!uint >= 2) + && (conf_make_meta.make.auto_num_depth.to!uint <= 3) + && auto_heading_numbering[2]) + ? (format(q"┃%s.%s.%s┃", + heading_num[0].to!string, + heading_num[1].to!string, + heading_num[2].to!string + )) + : ""; + } else if (heading_num[1] > 0) { + heading_number_auto_composite + = ((conf_make_meta.make.auto_num_depth.to!uint >= 1) + && (conf_make_meta.make.auto_num_depth.to!uint <= 3) + && auto_heading_numbering[1]) + ? (format(q"┃%s.%s┃", + heading_num[0].to!string, + heading_num[1].to!string + )) + : ""; + } else if (heading_num[0] > 0 + && munge_.match(rgx.auto_heading_numbering_lv1) + ) { + heading_number_auto_composite + = ((conf_make_meta.make.auto_num_depth.to!uint >= 0) + && (conf_make_meta.make.auto_num_depth.to!uint <= 3) + && auto_heading_numbering[0]) + ? (format(q"┃%s┃", + heading_num[0].to!string + )) + : ""; + } else { + heading_number_auto_composite = ""; + } + } + heading_number_auto_composite_segname = + (heading_number_auto_composite.empty) + ? "" + : "seg_" ~ heading_number_auto_composite; + debug(heading_number_auto) { writeln(heading_number_auto_composite); } + if ((!empty(heading_number_auto_composite)) + && (obj_["lev_markup_number"].to!uint >= conf_make_meta.make.auto_num_top_lv)) { + munge_ = munge_ + .replaceFirst(rgx.heading, + "$1~$2 " ~ heading_number_auto_composite ~ ". ") + .replaceFirst(rgx.heading_marker_missing_tag, + "$1~" ~ heading_number_auto_composite_segname ~ " "); + } + } + return munge_; + } + static int heading_num_lev1 = 0; + static string _make_segment_anchor_tags_if_none_provided()( + string munge_, + string lev_, + bool _new_doc + ) { + if (!(munge_.match(rgx.heading_anchor_tag))) { + if (lev_ == "A") { // (_new_doc) + heading_num_lev1 = 0; + } + if (munge_.match(rgx.heading_identify_anchor_tag)) { + if (auto m = munge_.match(rgx.heading_extract_named_anchor_tag)) { + munge_ = munge_.replaceFirst( + rgx.heading_marker_missing_tag, + "$1~" ~ m.captures[1].toLower ~ "_" ~ m.captures[2] ~ " "); + if (auto n = munge_.match(rgx.heading_anchor_tag_plus_colon)) { + auto tag_remunge_ = n.captures[2] + .replaceAll(rgx.heading_marker_tag_has_colon, ".."); + munge_ = munge_.replaceFirst(rgx.heading_anchor_tag_plus_colon, n.captures[1] ~ tag_remunge_ ~ " "); + } + } else if (auto m = munge_.match(rgx.heading_extract_unnamed_anchor_tag)) { + munge_ = munge_.replaceFirst( + rgx.heading_marker_missing_tag, + "$1~" ~ "s" ~ m.captures[1] ~ " "); + } + } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev == "1" + heading_num_lev1 ++; + munge_ = munge_.replaceFirst( + rgx.heading_marker_missing_tag, + "$1~" ~ "x" ~ heading_num_lev1.to!string ~ " "); + } + } + return munge_; + } + } + // ↑ - object inline markup + // ↓ - object attributes + struct ObjAttributes { + string[string] _obj_attrib; + string obj_attributes()( + string obj_is_, + string obj_raw, + ObjGenericComposite comp_obj_, + ) { + scope(exit) { + destroy(obj_is_); + destroy(obj_raw); + destroy(comp_obj_); + } + _obj_attrib["json"] ="{"; + switch (obj_is_) { + case "heading": + _obj_attrib["json"] ~= txt_heading(obj_raw); + break; + case "para": + _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) + ~ txt_para(obj_raw); + break; + case "code": + _obj_attrib["json"] ~= txt_code(obj_raw); + break; + case "group": + _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) + ~ txt_group(obj_raw); + break; + case "block": + _obj_attrib["json"] ~= txt_para_and_blocks(obj_raw) + ~ txt_block(obj_raw); + break; + case "verse": + _obj_attrib["json"] ~= txt_verse(obj_raw); + break; + case "quote": + _obj_attrib["json"] ~= txt_quote(obj_raw); + break; + case "table": + _obj_attrib["json"] ~= txt_table(obj_raw); + break; + case "comment": + _obj_attrib["json"] ~= txt_comment(obj_raw); + break; + default: + _obj_attrib["json"] ~= txt_para(obj_raw); + break; + } + _obj_attrib["json"] ~= " }"; + _obj_attrib["json"] = _set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, comp_obj_); + debug(structattrib) { + if (oa_j["is"].str() == "heading") { + writeln(_obj_attrib["json"]); + writeln( + "is: ", oa_j["is"].str(), + "; object_number: ", oa_j["object_number"].integer() + ); + } + } + return _obj_attrib["json"]; + } + invariant() { + } + private: + string _obj_attributes; + string txt_para_and_blocks()(string obj_txt_in) { + if (obj_txt_in.matchFirst(rgx.para_bullet)) { + _obj_attributes =" \"bullet\": \"true\"," + ~ " \"indent_hang\": 0," + ~ " \"indent_base\": 0,"; + } else if (auto m = obj_txt_in.matchFirst(rgx.para_bullet_indent)) { + _obj_attributes =" \"bullet\": \"true\"," + ~ " \"indent_hang\": " ~ m["indent"].to!string ~ "," + ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; + } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent_hang)) { + _obj_attributes =" \"bullet\": \"false\"," + ~ " \"indent_hang\": " ~ m["hang"].to!string ~ "," + ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; + } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent)) { + _obj_attributes =" \"bullet\": \"false\"," + ~ " \"indent_hang\": " ~ m["indent"].to!string ~ "," + ~ " \"indent_base\": " ~ m["indent"].to!string ~ ","; + } else { + _obj_attributes =" \"bullet\": \"false\"," + ~ " \"indent_hang\": 0," + ~ " \"indent_base\": 0,"; + } + return _obj_attributes; + } + string txt_heading()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"para\"," + ~ " \"is\": \"heading\""; + return _obj_attributes; + } + invariant() { + } + string txt_para()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"para\"," + ~ " \"is\": \"para\""; + return _obj_attributes; + } + invariant() { + } + string txt_quote()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"quote\""; + return _obj_attributes; + } + invariant() { + } + string txt_group()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"group\""; + return _obj_attributes; + } + invariant() { + } + string txt_block()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"block\""; + return _obj_attributes; + } + invariant() { + } + string txt_verse()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"verse\""; + return _obj_attributes; + } + invariant() { + } + string txt_code()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"code\""; + return _obj_attributes; + } + invariant() { + } + string txt_table()(string obj_txt_in) { + _obj_attributes = " \"use\": \"content\"," + ~ " \"of\": \"block\"," + ~ " \"is\": \"table\""; + return _obj_attributes; + } + invariant() { + } + string txt_comment()(string obj_txt_in) { + _obj_attributes = " \"use\": \"comment\"," + ~ " \"of\": \"comment\"," + ~ " \"is\": \"comment\""; + return _obj_attributes; + } + invariant() { + } + string _set_additional_values_parse_as_json()( + string _obj_attrib, + string obj_is_, + ObjGenericComposite comp_obj_, + ) { + JSONValue oa_j = parseJSON(_obj_attrib); + assert( + (oa_j.type == JSON_TYPE.OBJECT) + ); + if (obj_is_ == "heading") { + oa_j.object["object_number"] = comp_obj_.metainfo.ocn; + oa_j.object["lev_markup_number"] = comp_obj_.metainfo.heading_lev_markup; + oa_j.object["lev_collapsed_number"] = comp_obj_.metainfo.heading_lev_collapsed; + oa_j.object["heading_ptr"] = comp_obj_.ptr.heading; + oa_j.object["doc_object_ptr"] = comp_obj_.ptr.doc_object; + } + oa_j.object["parent_object_number"] = comp_obj_.metainfo.parent_ocn; + oa_j.object["parent_lev_markup_number"] = comp_obj_.metainfo.parent_lev_markup; + _obj_attrib = oa_j.toString(); + return _obj_attrib; + } + } + // ↑ - object attributes + // ↓ - object tags + pure ObjGenericComposite obj_dom_structure_set_markup_tags()( + ObjGenericComposite obj, + int[] dom, + int lev + ) { + foreach (i; 0 .. 8) { + if (i < lev) { + if (dom[i] == DomTags.open + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.open_still; + } else if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } + } else if (i == lev) { + if (lev == 0 + && dom[i] == DomTags.open_still + ) { + dom[i] = DomTags.close; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close_and_open; + } else { + dom[i] = DomTags.open; + } + } else if (i > lev) { + if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close; + } + } + } + debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); } + obj.metainfo.dom_structure_markedup_tags_status = dom.dup; + return obj; + } + pure ObjGenericComposite obj_dom_set_collapsed_tags()( + ObjGenericComposite obj, + int[] dom, + int lev + ) { + foreach (i; 0 .. 8) { + if (i < lev) { + if (dom[i] == DomTags.open + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.open_still; + } else if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } + } else if (i == lev) { + if (lev == 0 + && dom[i] == DomTags.open_still + ) { + dom[i] = DomTags.close; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close_and_open; + } else { + dom[i] = DomTags.open; + } + } else if (i > lev) { + if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close; + } + } + } + debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); } + obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; + return obj; + } + // ↑ - object tags + // ↓ - table of contents + @system ObjGenericComposite[] backmatter_gather_table_of_contents( + ObjGenericComposite[] the_document_endnotes_section, + ObjGenericComposite[] the_document_glossary_section, + ObjGenericComposite[] the_document_bibliography_section, + ObjGenericComposite[] the_document_bookindex_section, + ObjGenericComposite[] the_document_blurb_section, + ) { + ObjGenericComposite[] toc_section_backmatter; + string toc_txt_; + static auto mkup = InlineMarkup(); + ObjGenericComposite comp_obj_; + int[string] indent = [ + "hang_position" : 1, + "base_position" : 1, + ]; + comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", "", 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.attrib.indent_hang = indent["hang_position"]; + comp_obj_.attrib.indent_base = indent["base_position"]; + comp_obj_.attrib.bullet = false; + if (the_document_endnotes_section.length > 1) { + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + "Endnotes", + mkup.lnk_c, + mkup.url_o, + "endnotes", + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_.text = toc_txt_.to!string.strip; + comp_obj_.has.inline_links = true; + toc_section_backmatter ~= comp_obj_; + } + if (the_document_glossary_section.length > 1) { + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + "Glossary", + mkup.lnk_c, + mkup.url_o, + "glossary", + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_.text = toc_txt_.to!string.strip; + comp_obj_.has.inline_links = true; + toc_section_backmatter ~= comp_obj_; + } + if (the_document_bibliography_section.length > 1){ + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + "Bibliography", + mkup.lnk_c, + mkup.url_o, + "bibliography", + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_.text = toc_txt_.to!string.strip; + comp_obj_.has.inline_links = true; + toc_section_backmatter ~= comp_obj_; + } + if (the_document_bookindex_section.length > 1) { + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + "Book Index", + mkup.lnk_c, + mkup.url_o, + "bookindex", + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_.text = toc_txt_.to!string.strip; + comp_obj_.has.inline_links = true; + toc_section_backmatter ~= comp_obj_; + } + if (the_document_blurb_section.length > 1) { + toc_txt_ = format("%s%s%s%s#%s%s", + mkup.lnk_o, + "Blurb", + mkup.lnk_c, + mkup.url_o, + "blurb", + mkup.url_c, + ); + toc_txt_= toc_txt_.links_and_images; + comp_obj_.has.inline_links = true; + comp_obj_.text = toc_txt_.to!string.strip; + toc_section_backmatter ~= comp_obj_; + } + debug(toc) { + writefln( "%s %s", __LINE__,); + foreach (toc_linked_heading; toc_section_backmatter) { + writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); + } + } + return toc_section_backmatter; + } + // ↑ - table of contents + // ↓ - endnotes + struct NotesSection { + string[string] object_notes; + int previous_count; + int mkn; + static auto rgx = RgxI(); + private auto gather_notes_for_endnote_section( + ObjGenericComposite[] contents_am, + string[string] tag_in_seg, + int cntr, + ) { + assert((contents_am[cntr].metainfo.is_a == "para") + || (contents_am[cntr].metainfo.is_a == "heading") + || (contents_am[cntr].metainfo.is_a == "quote") + || (contents_am[cntr].metainfo.is_a == "group") + || (contents_am[cntr].metainfo.is_a == "block") + || (contents_am[cntr].metainfo.is_a == "verse")); + assert(cntr >= previous_count); + assert( + (contents_am[cntr].text).match( + rgx.inline_notes_al_all_note) + ); + mixin InternalMarkup; + previous_count = cntr; + static auto mkup = InlineMarkup(); + static auto munge = ObjInlineMarkupMunge(); + foreach(m; + (contents_am[cntr].text).matchAll( + rgx.inline_notes_al_special_char_note) + ) { + debug(endnotes_build) { writeln( + "{", mkup.ff_i, mkup.superscript, mkup.ff_o, m["char"], ".", mkup.ff_c, mkup.superscript, "}" + ~ mkup.mark_internal_site_lnk, + tag_in_seg["seg_lv4"], + ".fnSuffix#noteref_\n ", m["char"], " ", + m["note"]); // sometimes need segment name (segmented html & epub) + } + // you need anchor for segments at this point -> + object_notes["anchor"] ~= "note_" ~ m["char"] ~ "』"; + object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) + ? (links_and_images( + "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["char"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}#noteref_" + ~ m["char"]) ~ " " + ~ m["note"] ~ "』" + ) + : (links_and_images( + "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["char"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}" + ~ mkup.mark_internal_site_lnk + ~ tag_in_seg["seg_lv4"] + ~ ".fnSuffix#noteref_" + ~ m["char"]) ~ " " + ~ m["note"] ~ "』" + ); + } + foreach(m; + (contents_am[cntr].text).matchAll( + rgx.inline_notes_al_regular_number_note) + ) { + debug(endnotes_build) { writeln( + "{", mkup.ff_i, mkup.superscipt, mkup.ff_o, m["num"], ".", mkup.ff_c, mkup.superscipt, "}" + ~ mkup.mark_internal_site_lnk, + tag_in_seg["seg_lv4"], + ".fnSuffix#noteref_\n ", m["num"], " ", + m["note"]); // sometimes need segment name (segmented html & epub) + } + // you need anchor for segments at this point -> + object_notes["anchor"] ~= "note_" ~ m["num"] ~ "』"; + object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) + ? (links_and_images( + "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["num"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}#noteref_" + ~ m["num"]) ~ " " + ~ m["note"] ~ "』" + ) + : (links_and_images( + "{" ~ mkup.ff_i ~ mkup.superscript ~ mkup.ff_o ~ m["num"] ~ "." ~ mkup.ff_c ~ mkup.superscript ~ "}" + ~ mkup.mark_internal_site_lnk + ~ tag_in_seg["seg_lv4"] + ~ ".fnSuffix#noteref_" + ~ m["num"]) ~ " " + ~ m["note"] ~ "』" + ); + } + return object_notes; + } + private auto gathered_notes() { + string[][string] endnotes_; + if (object_notes.length > 1) { + endnotes_["notes"] = (object_notes["notes"].split(rgx.break_string))[0..$-1]; + endnotes_["anchor"] = (object_notes["anchor"].split(rgx.break_string))[0..$-1]; + } else { + endnotes_["notes"] = []; + endnotes_["anchor"] = []; + } + return endnotes_; + } + private ST_endnotes backmatter_endnote_objects(O)( + OCNset obj_cite_digits, + O opt_action, + ) { + mixin spineNode; + ObjGenericComposite[] the_document_endnotes_section; + auto endnotes_ = gathered_notes(); + string type_is; + string lev, lev_markup_number, lev_collapsed_number; + string attrib; + int[string] indent; + ObjGenericComposite comp_obj_; + if ((endnotes_["notes"].length > 0) + && (opt_action.backmatter && opt_action.section_endnotes)) { + { + comp_obj_ = set_object_heading("lev1", "backmatter", "endnotes", "Endnotes"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_endnotes"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "endnotes"; + comp_obj_.tags.anchor_tags = ["section_endnotes"]; + the_document_endnotes_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + ++mkn; + } + { + comp_obj_ = set_object_heading("lev4", "backmatter", "endnotes", "Endnotes"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "endnotes"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.tags.anchor_tags = ["endnotes"]; + the_document_endnotes_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + ++mkn; + } + } else { + comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there are no Endnotes"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + the_document_endnotes_section ~= comp_obj_; + } + if (opt_action.backmatter && opt_action.section_endnotes) { + ObjGenericComposite comp_obj_endnote_; + comp_obj_endnote_ = set_object_generic("backmatter", "endnotes", "para", "endnote", "", 0); + comp_obj_endnote_.metainfo.identifier = ""; + // comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_endnote_.attrib.indent_hang = 0; + comp_obj_endnote_.attrib.indent_base = 0; + comp_obj_endnote_.attrib.bullet = false; + foreach (i, endnote; endnotes_["notes"]) { + auto m = endnote.matchFirst(rgx.note_ref); + string notenumber = m["ref"].to!string; + string anchor_tag = "note_" ~ notenumber; + comp_obj_endnote_.tags.anchor_tags = [ endnotes_["anchor"][i] ]; + comp_obj_endnote_.has.inline_links = true; + comp_obj_endnote_.text = endnote.inline_markup_faces.strip; + the_document_endnotes_section ~= comp_obj_endnote_; + } + } + ST_endnotes ret; + { + ret.endnotes = the_document_endnotes_section; + ret.ocn = obj_cite_digits; + } + return ret; + } + } + // ↑ - endnotes + // ↓ - section book index + @system ST_flow_book_index flow_book_index_(B)( + char[] line, + string[string] an_object, + string book_idx_tmp, + uint[string] pith, + B opt_action, + ) { + static auto rgx = RgxI(); + if (auto m = line.match(rgx.book_index_item)) { // match book_index + debug(bookindexmatch) { writefln( + "* [bookindex] %s\n", + m["bookindex"].to!string, + ); + } + an_object["bookindex_nugget"] = m.captures[1].to!string; + } else if (auto m = line.match(rgx.book_index_item_open)) { // match open book_index + pith["section"] = eN.sect.book_index; + if (opt_action.backmatter && opt_action.section_bookindex) { + book_idx_tmp = m.captures[1].to!string; + debug(bookindexmatch) { writefln( "* [bookindex] %s\n", book_idx_tmp,); } + } + } else if (pith["section"] == eN.sect.book_index) { // book_index flag set + if (auto m = line.match(rgx.book_index_item_close)) { + pith["section"] = eN.sect.unset; + if (opt_action.backmatter + && opt_action.section_bookindex) { + an_object["bookindex_nugget"] = book_idx_tmp ~ m.captures[1].to!string; + debug(bookindexmatch) { writefln( "* [bookindex] %s\n", book_idx_tmp,); } + } + book_idx_tmp = ""; + } else { + if (opt_action.backmatter + && opt_action.section_bookindex) { + book_idx_tmp ~= line; + } + } + } + ST_flow_book_index ret; + { + ret.this_object = an_object; + ret.pith = pith; + ret.book_idx_tmp = book_idx_tmp; + } + return ret; + } + struct BookIndexNuggetHash { + string main_term, sub_term, sub_term_bits; + int object_number_offset, object_number_endpoint; + string[] object_numbers; + string[][string][string] bi_hash_nugget; + string[] bi_main_terms_split_arr; + string[][string][string] bookindex_nugget_hash(S)( + string bookindex_section, + OCNset obj_cite_digits, + S tag_in_seg, + ) { + debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } + debug(bookindexraw) { + if (!bookindex_section.empty) { + writeln( + "* [bookindex] ", + "[", obj_cite_digits.object_number.to!string, ": ", tag_in_seg["seg_lv4"], "] ", bookindex_section, + " - - - ", + "[", obj_cite_digits.object_number.to!string, "] ", bookindex_section + ); + } + } + static auto rgx = RgxI(); + if (!bookindex_section.empty) { + auto bi_main_terms_split_arr + = bookindex_section.split(rgx.bi_main_terms_split); + foreach (bi_main_terms_content; bi_main_terms_split_arr) { + auto bi_main_term_and_rest + = bi_main_terms_content.split(rgx.bi_main_term_plus_rest_split); + if (auto m = bi_main_term_and_rest[0].match( + rgx.bi_term_and_object_numbers_match) + ) { + main_term = m.captures[1].strip; + object_number_offset = m.captures[2].to!int; + object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); + object_numbers ~= (obj_cite_digits.object_number.to!string + ~ "-" ~ object_number_endpoint.to!string); + } else { + main_term = bi_main_term_and_rest[0].strip; + object_numbers ~= obj_cite_digits.object_number.to!string; + } + bi_hash_nugget[main_term]["_a"] ~= object_numbers; + object_numbers = null; + if (bi_main_term_and_rest.length > 1) { + auto bi_sub_terms_split_arr + = bi_main_term_and_rest[1].split( + rgx.bi_sub_terms_plus_object_number_offset_split + ); + foreach (sub_terms_bits; bi_sub_terms_split_arr) { + if (auto m = sub_terms_bits.match(rgx.bi_term_and_object_numbers_match)) { + sub_term = m.captures[1].strip; + object_number_offset = m.captures[2].to!int; + object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); + object_numbers ~= (obj_cite_digits.object_number.to!string + ~ " - " ~ object_number_endpoint.to!string); + } else { + sub_term = sub_terms_bits.strip; + object_numbers ~= obj_cite_digits.object_number.to!string; + } + if (!empty(sub_term)) { + bi_hash_nugget[main_term][sub_term] ~= object_numbers; + } + object_numbers = null; + } + } + } + } + return bi_hash_nugget; + } + invariant() { + } + } + struct BookIndexReportIndent { + int mkn, skn; + void bookindex_report_indented()( + string[][string][string] bookindex_unordered_hashes + ) { + auto mainkeys + = bookindex_unordered_hashes.byKey.array.sort().release; + foreach (mainkey; mainkeys) { + debug(bookindex1) { writeln(mainkey); } + auto subkeys + = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; + foreach (subkey; subkeys) { + debug(bookindex1) { + writeln(" ", subkey); + writeln(" ", to!string( + bookindex_unordered_hashes[mainkey][subkey] + )); + } + ++skn; + } + ++mkn; + } + } + } + struct BookIndexReportSection { + int mkn, skn; + static auto rgx = RgxI(); + static auto munge = ObjInlineMarkupMunge(); + void bookindex_write_section()( + string[][string][string] bookindex_unordered_hashes + ) { + auto mainkeys = + bookindex_unordered_hashes.byKey.array + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; + foreach (mainkey; mainkeys) { + write("_0_1 ⑆!┨", mainkey, "┣! "); + foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { + auto go = ref_.replaceAll(rgx.book_index_go, "$1"); + write(" {", ref_, "}#", go, ", "); + } + writeln(" \\\\"); + bookindex_unordered_hashes[mainkey].remove("_a"); + auto subkeys = + bookindex_unordered_hashes[mainkey].byKey.array + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; + foreach (subkey; subkeys) { + write(" ", subkey, ", "); + foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { + auto go = ref_.replaceAll(rgx.book_index_go, "$1"); + write(" {", ref_, "}#", go, ", "); + } + writeln(" \\\\"); + ++skn; + } + ++mkn; + } + } + @system ST_bookindex backmatter_bookindex_build_abstraction_section(B)( + string[][string][string] bookindex_unordered_hashes, + OCNset obj_cite_digits, + B opt_action, + ) { + debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } + mixin spineNode; + mixin InternalMarkup; + static auto mkup = InlineMarkup(); + string type_is; + string lev; + int heading_lev_markup, heading_lev_collapsed; + string attrib; + int[string] indent; + auto mainkeys = + bookindex_unordered_hashes.byKey.array + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; + ObjGenericComposite[] bookindex_section; + ObjGenericComposite comp_obj_; + auto node_para_int_ = node_metadata_para_int; + auto node_para_str_ = node_metadata_para_str; + if ((mainkeys.length > 0) + && (opt_action.backmatter + && opt_action.section_bookindex)) { + string bi_tmp; + string[] bi_tmp_tags; + { + comp_obj_ = set_object_heading("lev1", "backmatter", "bookindex", "Book Index"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_book_index"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "bookindex"; + comp_obj_.tags.anchor_tags = ["section_bookindex"]; + comp_obj_.has.inline_links = true; + bookindex_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + ++mkn; + } + { + comp_obj_ = set_object_heading("lev4", "backmatter", "bookindex", "Index"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "bookindex"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.metainfo.heading_lev_collapsed = 2; + comp_obj_.has.inline_links = false; + comp_obj_.tags.anchor_tags = ["bookindex"]; + bookindex_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + ++mkn; + } + import std.array : appender; + auto buffer = appender!(char[])(); + string[dchar] transTable = [' ' : "_"]; + foreach (mainkey; mainkeys) { + bi_tmp_tags = [""]; + bi_tmp = mkup.ff_i ~ mkup.bold ~ mkup.ff_o ~ mainkey ~ mkup.ff_c ~ mkup.bold ~ " "; + buffer.clear(); + bi_tmp_tags ~= translate(mainkey, transTable); + auto bkidx_lnk(string locs) { + string markup = ""; + if (auto m = locs.matchFirst(rgx.book_index_go)) { + markup + = links_and_images("{ " ~ m["link"] ~ " }" + ~ "#" ~ m["ocn"] ~ ", "); + } else { + writeln(__LINE__, ": ", locs); + } + return markup; + } + foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { + bi_tmp ~= bkidx_lnk(ref_); + } + bi_tmp ~= " \\\\\n "; + bookindex_unordered_hashes[mainkey].remove("_a"); + auto subkeys = + bookindex_unordered_hashes[mainkey].byKey.array + .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; + foreach (subkey; subkeys) { + bi_tmp ~= subkey ~ ", "; + buffer.clear(); + bi_tmp_tags ~= translate(subkey, transTable); + foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { + bi_tmp ~= bkidx_lnk(ref_); + } + bi_tmp ~= " \\\\\n "; + ++skn; + } + bi_tmp = bi_tmp.replaceFirst(rgx.trailing_linebreak, ""); + comp_obj_ = set_object_generic("backmatter", "bookindex", "para", "bookindex", bi_tmp.to!string.strip, 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.anchor_tags = bi_tmp_tags; + comp_obj_.attrib.indent_hang = 0; + comp_obj_.attrib.indent_base = 1; + comp_obj_.attrib.bullet = false; + comp_obj_.has.inline_links = true; + comp_obj_.text = bi_tmp.to!string.strip; + bookindex_section ~= comp_obj_; + ++mkn; + } + } else { // no book index, (figure out what to do here) + comp_obj_ = set_object_heading("lev1", "backmatter", "bookindex", "(skip) there is no Book Index"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + bookindex_section ~= comp_obj_; + } + ST_bookindex ret; + { + ret.bookindex = bookindex_section; + ret.ocn = obj_cite_digits; + } + return ret; + } + } + // ↑ - section book index + // ↓ - section glossary + // ↓ build + ST_the_section build_the_glossary_section( + char[] line, // line is immutable, not necessary to return unchanged + uint[string] pith, // double check, should not be necessary to pass pith + string[string][string] tag_assoc, // only for headings: html & epub + ) { + static auto rgx = RgxI(); + ObjGenericComposite comp_obj_; + ObjGenericComposite[] add_to_current_document_section; + indent = [ + "hang_position" : 0, + "base_position" : 0, + ]; + bullet = false; + pith["txt_is"] = eN.txt_is.para; + line_occur["para"] = eN.bi.off; + an_object_key = "glossary_nugget"; + ST_the_section ret; + if (line.matchFirst(rgx.heading_glossary)) { + { + comp_obj_ = set_object_heading("lev1", "backmatter", "glossary", "Glossary"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_glossary"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "glossary"; + comp_obj_.tags.anchor_tags = ["section_glossary"]; + comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + add_to_current_document_section ~= comp_obj_; // + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } { + comp_obj_ = set_object_heading("lev4", "backmatter", "glossary", "Glossary"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "glossary"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.metainfo.heading_lev_collapsed = 2; + comp_obj_.tags.anchor_tags = ["glossary"]; + add_to_current_document_section ~= comp_obj_; // + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + pith["ocn"] = eN.ocn.on; + } + { + ret.comp_section_obj ~= add_to_current_document_section; + ret.pith = pith; + ret.tag_assoc = tag_assoc; // only for headings: html & epub + } + } else { // para + { + auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + { + an_object = _get.this_object; + an_object_key = _get.this_object_key; + pith = _get.pith; + indent = _get.indent; + bullet = _get.bullet; + line_occur = _get.line_occur; + } + } + comp_obj_ = set_object_generic("backmatter", "glossary", "para", "glossary", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.attrib.indent_hang = indent["hang_position"]; + comp_obj_.attrib.indent_base = indent["base_position"]; + comp_obj_.attrib.bullet = bullet; + add_to_current_document_section ~= comp_obj_; // + pith["ocn"] = eN.ocn.on; + { + ret.comp_section_obj = add_to_current_document_section; + ret.pith = pith; + ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub + } + } + return ret; + } + // ↑ - section glossary + // ↓ - section bibliography + @system ST_biblio_section backmatter_make_the_bibliography_section()( + string[] biblio_unsorted_incomplete, + JSONValue[] bib_arr_json, + ) { + Bibliography biblio = Bibliography(); + ObjGenericComposite comp_obj_; + static auto mkup = InlineMarkup(); + ST_flow_bibliography _get = biblio.flow_bibliography_(biblio_unsorted_incomplete, bib_arr_json); + JSONValue[] biblio_ordered; + biblio_ordered = _get.biblio_sorted; + if (biblio_ordered.length > 0) { + { + comp_obj_ = set_object_heading("lev1", "backmatter", "bibliography", "Bibliography"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_bibliography"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "bibliography"; + comp_obj_.tags.anchor_tags = ["section_bibliography"]; + comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + the_document_bibliography_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } + { + comp_obj_ = set_object_heading("lev4", "backmatter", "bibliography", "Bibliography"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "bibliography"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.tags.anchor_tags = ["bibliography"]; + the_document_bibliography_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } + { + string out_; + foreach (entry; biblio_ordered) { + out_ = format("%s \"%s\"%s%s%s%s%s%s%s%s%s.", + ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str), + entry["fulltitle"].str, + ((entry["journal"].str.empty) ? "" : ", " ~ mkup.ff_i ~ mkup.italic ~ mkup.ff_o ~ entry["journal"].str ~ mkup.ff_c ~ mkup.italic), + ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str), + ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str), + ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""), + ", " ~ entry["year"].str, + ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str), + ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str), + ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str), + ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"), + ); + comp_obj_ = set_object_generic("backmatter", "bibliography", "para", "bibliography", out_.to!string.strip, 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.attrib.indent_hang = 0; + comp_obj_.attrib.indent_base = 1; + comp_obj_.attrib.bullet = bullet; + comp_obj_.tags.anchor_tags = [anchor_tag]; + the_document_bibliography_section ~= comp_obj_; + } + } + } else { + comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Bibliography"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + the_document_bibliography_section ~= comp_obj_; + } + debug(bibliosection) { foreach (o; the_document_bibliography_section) { writeln(o.text); } } + ST_biblio_section ret; + { + ret.bibliography_section = the_document_bibliography_section; + ret.tag_assoc = tag_assoc; // + } + return ret; + } + struct Bibliography { + @system ST_flow_bibliography flow_bibliography_()( + string[] biblio_unsorted_incomplete, + JSONValue[] bib_arr_json + ) { + JSONValue[] biblio_unsorted + = biblio_make_unsorted_array_of_json_objects(biblio_unsorted_incomplete, bib_arr_json); // TODO lookat returns + biblio_arr_json = []; + biblio_unsorted_incomplete = []; + JSONValue[] biblio_sorted__ = biblio_sort(biblio_unsorted); + debug(biblio0) { + biblio_debug(biblio_sorted__); + writeln("---"); + writeln("unsorted incomplete: ", biblio_unsorted_incomplete.length); + writeln("json: ", bib_arr_json.length); + writeln("unsorted: ", biblio_unsorted.length); + writeln("sorted: ", biblio_sorted__.length); + int cntr; + int[7] x; + while (cntr < x.length) { + writeln(cntr, ": ", biblio_sorted__[cntr]["fulltitle"]); + cntr++; + } + } + ST_flow_bibliography ret; + { + ret.biblio_sorted = biblio_sorted__; + ret.bib_arr_json = bib_arr_json; + ret.biblio_unsorted_incomplete = biblio_unsorted_incomplete; + } + return ret; + } + @system final private JSONValue[] biblio_make_unsorted_array_of_json_objects()( + string[] biblio_unordered, + JSONValue[] bib_arr_json + ) { + foreach (bibent; biblio_unordered) { + // update bib to include deemed_author, needed for: + // sort_bibliography_array_by_deemed_author_year_title + // either: sort on multiple fields, or; create such sort field + JSONValue j = parseJSON(bibent); + if (!empty(j["fulltitle"].str)) { + if (!empty(j["author_raw"].str)) { + j["deemed_author"] = j["author_arr"][0]; + } else if (!empty(j["editor_raw"].str)) { + j["deemed_author"] = j["editor_arr"][0]; + } + j["sortby_deemed_author_year_title"] = ( + j["deemed_author"].str ~ + "; " ~ + j["year"].str ~ + "; " ~ + j["fulltitle"].str + ); + } + bib_arr_json ~= j; + } + return bib_arr_json.dup; + } + @system final private JSONValue[] biblio_sort()(JSONValue[] biblio_unordered) { + JSONValue[] biblio_sorted_; + biblio_sorted_ + = sort!((a, b){ + return ((a["sortby_deemed_author_year_title"].str) < (b["sortby_deemed_author_year_title"].str)); + })(biblio_unordered).array; + debug(bibliosorted) { + foreach (j; biblio_sorted_) { + if (!empty(j["fulltitle"].str)) { writeln(j["sortby_deemed_author_year_title"]); } + } + } + return biblio_sorted_; + } + @system void biblio_debug()(JSONValue[] biblio_sorted) { + debug(biblio0) { + foreach (j; biblio_sorted) { + if (!empty(j["fulltitle"].str)) { writeln(j["sortby_deemed_author_year_title"]); } + } + } + } + } + // ↑ - section bibliography + // ↓ - section blurb + ST_the_section build_the_blurb_section(Opt) ( + char[] line, // line is immutable, not necessary to return unchanged + uint[string] pith, // double check, should not be necessary to pass pith + string[string][string] tag_assoc, // only for headings: html & epub + Opt opt_action, + ) { + static auto rgx = RgxI(); + ObjGenericComposite comp_obj_; + ObjGenericComposite[] add_to_current_document_section; + // assert (opt_action.backmatter && opt_action.section_blurb); + indent = [ + "hang_position" : 0, + "base_position" : 0, + ]; + bullet = false; + if (auto m = line.matchFirst(rgx.para_indent)) { + debug(paraindent) { writeln(line); } + indent["hang_position"] = (m["indent"]).to!int; + indent["base_position"] = (m["indent"]).to!int; + } else if (line.matchFirst(rgx.para_bullet)) { + debug(parabullet) { writeln(line); } + bullet = true; + } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { + debug(paraindenthang) { writeln(line); } + indent = [ + "hang_position" : (m["hang"]).to!int, + "base_position" : (m["indent"]).to!int, + ]; + } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { + debug(parabulletindent) { writeln(line); } + indent = [ + "hang_position" : (m["indent"]).to!int, + "base_position" : (m["indent"]).to!int, + ]; + bullet = true; + } + pith["txt_is"] = eN.txt_is.para; + line_occur["para"] = eN.bi.off; + an_object_key = "blurb_nugget"; + ST_the_section ret; + if (line.matchFirst(rgx.heading_blurb) + && (opt_action.backmatter && opt_action.section_blurb)) { + { + comp_obj_ = set_object_heading("lev1", "backmatter", "blurb", "Blurb"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = false; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "_part_blurb"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = "blurb"; + comp_obj_.tags.anchor_tags = ["section_blurb"]; + comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + add_to_current_document_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } + { + comp_obj_ = set_object_heading("lev4", "backmatter", "blurb", "Blurb"); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = true; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.metainfo.heading_lev_collapsed = 2; + comp_obj_.tags.anchor_tags = ["blurb"]; + add_to_current_document_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } + } else if (line.matchFirst(rgx.headings) + && (opt_action.backmatter && opt_action.section_blurb)) { + comp_obj_ = comp_obj_.init; + comp_obj_.metainfo.is_of_part = "backmatter"; + comp_obj_.metainfo.is_of_section = "blurb"; + comp_obj_.metainfo.is_of_type = "para"; + comp_obj_.metainfo.is_a = "heading"; + comp_obj_.text = line.to!string; + comp_obj_.metainfo.ocn = 0; + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.dummy_heading = false; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv + comp_obj_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv + comp_obj_.metainfo.parent_ocn = 1; + comp_obj_.metainfo.parent_lev_markup = 0; + add_to_current_document_section ~= comp_obj_; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + } else if (!(line.empty)) { + { + auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); + { + an_object = _get.this_object; + an_object_key = _get.this_object_key; + pith = _get.pith; + indent = _get.indent; + bullet = _get.bullet; + line_occur = _get.line_occur; + } + } + comp_obj_ = set_object_generic("backmatter", "blurb", "para", "blurb", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0); + comp_obj_.metainfo.identifier = ""; + comp_obj_.metainfo.object_number_off = true; + comp_obj_.metainfo.object_number_type = 0; + comp_obj_.attrib.indent_hang = indent["hang_position"]; + comp_obj_.attrib.indent_base = indent["base_position"]; + comp_obj_.has.inline_links = true; + comp_obj_.attrib.bullet = bullet; + add_to_current_document_section ~= comp_obj_; + } + pith["ocn"] = eN.ocn.on; + { + ret.comp_section_obj = add_to_current_document_section; + ret.pith = pith; + ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub + } + return ret; + } + // ↑ - section blurb + // ↓ - images + string[] extract_images()(string content_block) { + static auto rgx = RgxI(); + string[] images_; + if (auto m = content_block.matchAll(rgx.image)) { + images_ ~= m.captures[1]; + } + return images_; + } + @system auto _image_dimensions(O,M)(O obj, M manifested) { + static auto rgx = RgxI(); + if (obj.has.image_without_dimensions) { + import std.math; + import imageformats; + int w, h, chans; + real _w, _h; + int max_width = 640; + foreach (img; obj.text.matchAll(rgx.inline_image_without_dimensions)) { + try { + read_image_info(manifested.src.image_dir_path ~ "/" ~ img["img"], w, h, chans); + } catch (Exception ex) { + writeln("WARNING, image not found: ", img["img"], "\n ", manifested.src.image_dir_path ~ "/" ~ img["img"]); + } + // calculate, decide max width and proportionally reduce to keep w & h within it + debug(images) { writeln("width: ", w, ", height: ", h); } + if (w > max_width) { + _w = max_width; + _h = round((max_width / w.to!real) * h.to!real); + } else { + _w = w; + _h = h; + } + obj.text = obj.text.replaceFirst( + rgx.inline_image_without_dimensions, + format(q"┃%s☼%s,w%sh%s %s┃", + "$1", + "$3", + _w.to!string, + _h.to!string, + "$6", + ) + ); + } + debug(images) { writeln("image without dimensions: ", obj.text); } + } + return obj; + } + // ↑ - images + // ↓ - links + auto _links(O)(O obj) { + static auto rgx = RgxI(); + if (auto m = obj.text.match(rgx.inline_link_stow_uri)) { + debug(links) { + writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count); + writeln("links to stow: ", (obj.text.match(rgx.inline_link_stow_uri))); + } + int _n_matches = (obj.text.match(rgx.inline_link_stow_uri)).count.to!int; + for(int i = 0; i < _n_matches; ++i) { + if (obj.text.match(rgx.inline_link_stow_uri)) { + obj.stow.link ~= obj.text.matchFirst(rgx.inline_link_stow_uri)[2]; + obj.text = obj.text.replaceFirst( + rgx.inline_link_stow_uri, + format(q"┃┥%s┝┤%s├┃", "$1", i) + ); + } + } + } + return obj; + } + // ↑ - links + // ↓ - segnames + @system ST_segnames after_doc_determine_segnames( + ObjGenericComposite[] the_document_body_section, + ObjGenericComposite[] the_document_endnotes_section, + ObjGenericComposite[] the_document_glossary_section, + ObjGenericComposite[] the_document_bibliography_section, + ObjGenericComposite[] the_document_bookindex_section, + ObjGenericComposite[] the_document_blurb_section, + string[][string] segnames, + int html_segnames_ptr_cntr, + int html_segnames_ptr, + ) { + if (the_document_endnotes_section.length > 1) { + segnames["html"] ~= "endnotes"; + segnames["epub"] ~= "endnotes"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref obj; the_document_endnotes_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + if (obj.metainfo.heading_lev_markup == 4) { + obj.ptr.html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; + } + if (the_document_glossary_section.length > 1) { + segnames["html"] ~= "glossary"; + segnames["epub"] ~= "glossary"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref obj; the_document_glossary_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + if (obj.metainfo.heading_lev_markup == 4) { + obj.ptr.html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; + } + if (the_document_bibliography_section.length > 1) { + segnames["html"] ~= "bibliography"; + segnames["epub"] ~= "bibliography"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref obj; the_document_bibliography_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + if (obj.metainfo.heading_lev_markup == 4) { + obj.ptr.html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; + } + if (the_document_bookindex_section.length > 1) { + segnames["html"] ~= "bookindex"; + segnames["epub"] ~= "bookindex"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref obj; the_document_bookindex_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + if (obj.metainfo.heading_lev_markup == 4) { + obj.ptr.html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; + } + if (the_document_blurb_section.length > 1) { + segnames["html"] ~= "blurb"; + segnames["epub"] ~= "blurb"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref obj; the_document_blurb_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + if (obj.metainfo.heading_lev_markup == 4) { + obj.ptr.html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; + } + ST_segnames ret; + ret.segnames = segnames; + ret.html_segnames_ptr_cntr = html_segnames_ptr_cntr; + ret.html_segnames_ptr = html_segnames_ptr; + return ret; + } + // ↑ - segnames + // ↓ - ancestors descendants + struct NodeStructureMetadata { + int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; + int obj_cite_digit; + int[string] p_; // p_ parent_ + static auto rgx = RgxI(); + ObjGenericComposite node_location_emitter(La,Ta)( + string lev_markup_number, + string[string] tag_in_seg, + La lev_anchor_tag, + Ta tag_assoc, + OCNset obj_cite_digits, + int cntr_, + int ptr_, + string is_ + ) { + debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } + assert(is_ != "heading"); + assert(obj_cite_digits.object_number.to!int >= 0); + assert(is_ != "heading"); // should not be necessary + assert(obj_cite_digits.object_number.to!int >= 0); // should not be necessary + if (lv7 > eN.bi.off) { + p_["lev_markup_number"] = DocStructMarkupHeading.h_text_4; + p_["object_number"] = lv7; + } else if (lv6 > eN.bi.off) { + p_["lev_markup_number"] = DocStructMarkupHeading.h_text_3; + p_["object_number"] = lv6; + } else if (lv5 > eN.bi.off) { + p_["lev_markup_number"] = DocStructMarkupHeading.h_text_2; + p_["object_number"] = lv5; + } else { + p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; + p_["object_number"] = lv4; + } + ObjGenericComposite comp_obj_location; + comp_obj_location = comp_obj_location.init; + comp_obj_location.metainfo.is_a = is_; + comp_obj_location.metainfo.ocn = obj_cite_digits.object_number; + comp_obj_location.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_location.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + comp_obj_location.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"]; + comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; + comp_obj_location.metainfo.parent_ocn = p_["object_number"]; + comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; + debug(_node) { + if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); + } else { writeln("- ", _node.to!string); } + } + assert(comp_obj_location.metainfo.parent_lev_markup >= 4); + assert(comp_obj_location.metainfo.parent_lev_markup <= 7); + assert(comp_obj_location.metainfo.parent_ocn >= 0); + return comp_obj_location; + } + invariant() { + } + ObjGenericComposite node_emitter_heading(O,TaL,TA,SOAT)( + O an_object, + string[string] tag_in_seg, + TaL lev_anchor_tag, + TA tag_assoc, + OCNset obj_cite_digits, + int cntr_, + int ptr_, + string[] lv_ancestors_txt, + int html_segnames_ptr, + SOAT substantive_object_and_anchor_tags_struct, + ) { + string _text = an_object["substantive"]; + string lev_markup_number = an_object["lev_markup_number"]; + string lev_collapsed_number = an_object["lev_collapsed_number"]; + string dummy_heading_status = an_object["dummy_heading_status"]; + string is_ = an_object["is"]; + debug(asserts) { + static assert(is(typeof(lev) == string)); + static assert(is(typeof(obj_cite_digits.object_number) == int)); + } + assert(is_ == "heading"); + assert((obj_cite_digits.object_number).to!int >= 0); + assert( + lev_markup_number.match(rgx.levels_numbered), + ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ obj_cite_digits.object_number.to!string) + ); + if (lev_markup_number.match(rgx.levels_numbered)) { + if (lev_markup_number.to!int == 0) { + // TODO first hit (of two) with this assertion failure, check, fix & reinstate + // assert(obj_cite_digits.object_number.to!int == 1, + // "ERROR header lev markup number is: " ~ + // lev_markup_number.to!string ~ + // " obj_cite_digits.object_number.to!int should == 1 but is: " ~ + // obj_cite_digits.object_number.to!string ~ + // "\n" ~ _text); + } + } + switch (lev_markup_number.to!int) { + case 0: + lv = DocStructMarkupHeading.h_sect_A; + lv0 = obj_cite_digit; + lv1 = 0; lv2 = 0; lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; + p_["lev_markup_number"] = 0; + p_["object_number"] = 0; + break; + case 1: + lv = DocStructMarkupHeading.h_sect_B; + lv1 = obj_cite_digit; + lv2 = 0; lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_A; + p_["object_number"] = lv0; + break; + case 2: + lv = DocStructMarkupHeading.h_sect_C; + lv2 = obj_cite_digit; + lv3 = 0; lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_B; + p_["object_number"] = lv1; + break; + case 3: + lv = DocStructMarkupHeading.h_sect_D; + lv3 = obj_cite_digit; + lv4 = 0; lv5 = 0; lv6 = 0; lv7 = 0; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_C; + p_["object_number"] = lv2; + break; + case 4: + lv = DocStructMarkupHeading.h_text_1; + lv4 = obj_cite_digit; + lv5 = 0; lv6 = 0; lv7 = 0; + if (lv3 > eN.bi.off) { + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_D; + p_["object_number"] = lv3; + } else if (lv2 > eN.bi.off) { + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_C; + p_["object_number"] = lv2; + } else if (lv1 > eN.bi.off) { + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_B; + p_["object_number"] = lv1; + } else { + p_["lev_markup_number"] + = DocStructMarkupHeading.h_sect_A; + p_["object_number"] = lv0; + } + break; + case 5: + lv = DocStructMarkupHeading.h_text_2; + lv5 = obj_cite_digit; + lv6 = 0; lv7 = 0; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_text_1; + p_["object_number"] = lv4; + break; + case 6: + lv = DocStructMarkupHeading.h_text_3; + lv6 = obj_cite_digit; + lv7 = 0; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_text_2; + p_["object_number"] = lv5; + break; + case 7: + lv = DocStructMarkupHeading.h_text_4; + lv7 = obj_cite_digit; + p_["lev_markup_number"] + = DocStructMarkupHeading.h_text_3; + p_["object_number"] = lv6; + break; + default: + break; + } + ObjGenericComposite comp_obj_; + comp_obj_ = comp_obj_.init; + comp_obj_.metainfo.is_of_part = "body"; + comp_obj_.metainfo.is_of_section = "body"; + comp_obj_.metainfo.is_of_type = "para"; + comp_obj_.metainfo.is_a = "heading"; + comp_obj_.text = _text.to!string.strip; + comp_obj_.metainfo.ocn = obj_cite_digits.object_number; + comp_obj_.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_.metainfo.dummy_heading = (dummy_heading_status == "t") ? true: false; + comp_obj_.metainfo.object_number_off = obj_cite_digits.off; + // comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"]; + comp_obj_.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html; + comp_obj_.tags.heading_lev_anchor_tag = lev_anchor_tag; + comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"]; + comp_obj_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); + comp_obj_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); + comp_obj_.metainfo.parent_ocn = p_["object_number"]; + comp_obj_.metainfo.parent_lev_markup = p_["lev_markup_number"]; + comp_obj_.tags.heading_ancestors_text = lv_ancestors_txt; + comp_obj_.ptr.doc_object = cntr_; + comp_obj_.ptr.html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0); + comp_obj_.ptr.heading = ptr_; + comp_obj_.has.inline_notes_reg = substantive_object_and_anchor_tags_struct.has_notes_reg; + comp_obj_.has.inline_notes_star = substantive_object_and_anchor_tags_struct.has_notes_star; + comp_obj_.has.inline_links = substantive_object_and_anchor_tags_struct.has_links; + tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html; + tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub; + debug(_node) { + if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } + } + debug(nodeheading) { + if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } + } + assert(comp_obj_.metainfo.parent_lev_markup <= 7); + assert(comp_obj_.metainfo.parent_ocn >= 0); + if (lev_markup_number.match(rgx.levels_numbered_headings)) { + assert(comp_obj_.metainfo.heading_lev_markup <= 7); + assert(comp_obj_.metainfo.ocn >= 0); + if (comp_obj_.metainfo.parent_lev_markup > 0) { + assert(comp_obj_.metainfo.parent_lev_markup < comp_obj_.metainfo.heading_lev_markup); + if (comp_obj_.metainfo.ocn != 0) { + assert(comp_obj_.metainfo.parent_ocn < comp_obj_.metainfo.ocn); + } + } + if (comp_obj_.metainfo.heading_lev_markup == 0) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_B) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_C) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_B); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_D) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_C); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_1) { + assert(comp_obj_.metainfo.parent_lev_markup <= DocStructMarkupHeading.h_sect_D); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_2) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_1); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_3) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_2); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_4) { + assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_3); + } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_5) { + } + } + return comp_obj_; + } + invariant() { + } + } + @system ST_ancestors after_doc_determine_ancestors( + ObjGenericComposite[] the_document_body_section, + ObjGenericComposite[] the_document_endnotes_section, + ObjGenericComposite[] the_document_glossary_section, + ObjGenericComposite[] the_document_bibliography_section, + ObjGenericComposite[] the_document_bookindex_section, + ObjGenericComposite[] the_document_blurb_section, + ) { + int[] _get_ancestors_markup(ObjGenericComposite obj, int[] _ancestors_markup) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { writeln(obj.text); } + if (obj.metainfo.heading_lev_markup == 1) { + _ancestors_markup = [ + _ancestors_markup[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 2) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 3) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 4) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 5) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 6) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 7) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_markup == 8) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + _ancestors_markup[7] + ]; + } + _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; + } + debug(ancestor_markup) { writeln("marked up: ", _ancestors_markup); } + return _ancestors_markup; + } + int[] _get_ancestors_collapsed(ObjGenericComposite obj, int[] _ancestors_collapsed) { + if (obj.metainfo.is_a == "heading") { + if (obj.metainfo.heading_lev_collapsed == 1) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 2) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 3) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 4) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 5) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 6) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 7) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 8) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + _ancestors_collapsed[7] + ]; + } + _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; + } + debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); } + return _ancestors_collapsed; + } + // multiple 1~ levels, loop through document body + if (the_document_body_section.length > 1) { + int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_markup_; + _ancestors_markup = [1,0,0,0,0,0,0,0]; + _ancestors_markup_ ~= _ancestors_markup; + int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_collapsed_; + _ancestors_collapsed = [1,0,0,0,0,0,0,0]; + _ancestors_collapsed_ ~= _ancestors_collapsed; + foreach (ref obj; the_document_body_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); + obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed); + obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; + } + } + debug(ancestors) { + writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); + writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); + } + } + ST_ancestors ret; + ret.the_document_body_section = the_document_body_section; + ret.the_document_endnotes_section = the_document_endnotes_section; + ret.the_document_glossary_section = the_document_glossary_section; + ret.the_document_bibliography_section = the_document_bibliography_section; + ret.the_document_bookindex_section = the_document_bookindex_section; + ret.the_document_blurb_section = the_document_blurb_section; + return ret; + } + // ↑ - ancestors + // ↓ - descendants + // descendants + auto after_doc_get_descendants()(ObjGenericComposite[] document_sections) { + int[string] _heading_ocn_descendants; + string[] _ocn_open_key = ["","","","","","","",""]; + auto _doc_sect_length = document_sections.length - 1; + int _last_ocn; + foreach (_lg, ref obj; document_sections) { + if (obj.metainfo.is_a == "heading") { + foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) { + switch (dom_tag_status) with (DomTags) { + case none: break; + case open: + _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; + _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; + break; + case close: + if (_ocn_open_key[_dts_lv].empty) { + _ocn_open_key[_dts_lv] = "0"; + } + _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; + _ocn_open_key[_dts_lv] = (0).to!string; + break; + case close_and_open: + if (_ocn_open_key[_dts_lv].empty) { + _ocn_open_key[_dts_lv] = "0"; + } + _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; + _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; + _heading_ocn_descendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; + break; + case open_still: break; + default: break; + } + } + } + if (obj.metainfo.ocn > 0) { + _last_ocn = obj.metainfo.ocn; + } + if (_lg == _doc_sect_length) { + _heading_ocn_descendants["1"] = _last_ocn; // close existing o_n key + } + } + Tuple!(int, int)[] pairs; + foreach (pair; _heading_ocn_descendants.byPair) { + pairs ~= tuple(pair[0].to!int, pair[1]); + } + return pairs.sort; + } + // ↑ - descendants + // ↓ - assertions + pure void assertions_doc_structure()( + string[string] an_object, + string an_object_key, + int[string] lv + ) { + string msg_error_doc_struct = "\nERROR in document structure, check markup (heading level relationships):\n"; + if (lv["h3"] > eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h2"] > eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h1"] > eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h0"] > eN.bi.off) { + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else { + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h7"] > eN.bi.off) { + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h6"] > eN.bi.off) { + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h5"] > eN.bi.off) { + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else if (lv["h4"] > eN.bi.off) { + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } else { + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h0"] == eN.bi.off) { + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h1"] == eN.bi.off) { + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h2"] == eN.bi.off) { + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h3"] == eN.bi.off) { + } + if (lv["h4"] == eN.bi.off) { + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h5"] == eN.bi.off) { + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h6"] == eN.bi.off) { + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + } + if (lv["h7"] == eN.bi.off) { + } + switch ((an_object["lev"]).to!string) { + case "A": + if (lv["h0"] == eN.bi.off) { + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h0"] > eN.bi.off) + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ "should not enter level A a second time\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + } + break; + case "B": + if (lv["h1"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h1"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + } + break; + case "C": + if (lv["h2"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level C should not follow level A\n" + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h2"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + } + break; + case "D": + if (lv["h3"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level D should not follow level A\n" + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h3"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + } + break; + case "1": + if (lv["h4"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h4"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + } + break; + case "2": + if (lv["h5"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h5"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + } + break; + case "3": + if (lv["h6"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h6"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + } + break; + case "4": + if (lv["h7"] == eN.bi.off) { + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 3~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + } else { // (lv["h7"] > eN.bi.off) + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + } + break; + default: + break; + } + } + // ↑ - assertions +} +template docSectKeysSeq() { + auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { + struct doc_sect_keys_seq { + string[] scroll() { + return document_section_keys_sequenced["scroll"]; + } + string[] seg() { + return document_section_keys_sequenced["seg"]; + } + string[] sql() { + return document_section_keys_sequenced["sql"]; + } + string[] latex() { + return document_section_keys_sequenced["latex"]; + } + } + return doc_sect_keys_seq(); + } +} diff --git a/src/sisudoc/meta/metadoc_object_setter.d b/src/sisudoc/meta/metadoc_object_setter.d new file mode 100644 index 0000000..a2ceff6 --- /dev/null +++ b/src/sisudoc/meta/metadoc_object_setter.d @@ -0,0 +1,426 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + 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; + } + struct ObjGenericComposite { + string text = ""; + DocObj_MetaInfo_ metainfo; + DocObj_TxtAttrib_ attrib; + DocObj_Tags_ tags; + DocObj_Has_ has; + DocObj_Table_ table; + DocObj_CodeBlock_ code_block; + DocObj_Stow_ stow; + DocObj_Pointer_ ptr; + } + struct _theDoc { + ObjGenericComposite[] toc; + ObjGenericComposite[] head; + ObjGenericComposite[] body; + ObjGenericComposite[] bibliography; + ObjGenericComposite[] glossary; + ObjGenericComposite[] bookindex; + ObjGenericComposite[] blurb; + ObjGenericComposite[] endnotes; + } + struct TheObjects { + ObjGenericComposite[] oca; + } + ObjGenericComposite comp_obj_, comp_obj_location, comp_obj_poem_ocn, comp_obj_comment; + ObjGenericComposite[] the_document_toc_section, the_document_head_section, the_document_body_section, the_document_endnotes_section, the_document_bibliography_section, the_document_bookindex_section, the_document_glossary_section, the_document_blurb_section, the_document_xml_dom_tail_section; + struct OCNset { + int digit; + int object_number; + bool off; + string identifier; + int bkidx; + int type; + } + struct ST_endnotes { + ObjGenericComposite[] endnotes; + OCNset ocn; + } + struct ST_bookindex { + ObjGenericComposite[] bookindex; + OCNset ocn; + } + struct ST_biblio_section { + ObjGenericComposite[] bibliography_section; + string[string][string] tag_assoc; + } + struct ST_ancestors { + ObjGenericComposite[] the_document_body_section; + ObjGenericComposite[] the_document_endnotes_section; + ObjGenericComposite[] the_document_glossary_section; + ObjGenericComposite[] the_document_bibliography_section; + ObjGenericComposite[] the_document_bookindex_section; + ObjGenericComposite[] the_document_blurb_section; + } + struct ST_segnames { + string[][string] segnames; + int html_segnames_ptr_cntr; + int html_segnames_ptr; + } + struct ST_txtPlusHasFootnotes { + string obj_txt; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; + } + struct ST_txtPlusHasFootnotesUrlsImages { + string obj_txt; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; + bool has_urls; + bool has_images_without_dimensions; + } + struct ST_txtAndAnchorTagPlusHasFootnotesUrlsImages { + string obj_txt; + string anchor_tag; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; + bool has_links; // use same name + bool has_images_without_dimensions; + } + struct ST_the_section { + ObjGenericComposite[] comp_section_obj; // array: the heading has 2 members inserted, paras just 1 + uint[string] pith; + string[string][string] tag_assoc; // only for headings: html & epub + } + // book index variables + string book_idx_tmp; + string[][string][string] bookindex_unordered_hashes; + // node + struct ST_txt_by_line_common_reset { + int[string] line_occur; + string[string] this_object; + uint[string] pith; + } + struct ST_txt_by_line_block_start { + uint[string] pith; + uint[string] dochas; + string[string] object_number_poem; + } + struct ST_txt_by_line_block_generic { + uint[string] pith; + string[string] this_object; + } + struct ST_txt_by_line_block_poem { + int cntr; + uint[string] pith; + string[string] this_object; + } + struct ST_txt_by_line_block_biblio { + uint[string] pith; + int bib_entry; + string biblio_entry_str_json; + string[] biblio_arr_json; + } + struct ST_flow_book_index { + string[string] this_object; + uint[string] pith; + string book_idx_tmp; + } + struct ST_flow_heading_found { + string[string] heading_match_str; + Regex!(char)[string] heading_match_rgx; + uint[string] pith; + } + struct ST_flow_heading_make_set { + char[] line; + uint[string] pith; + string[string] this_object; + } + struct ST_flow_para_match { + uint[string] pith; + string[string] this_object; + string this_object_key; + int[string] indent; + bool bullet; + int[string] line_occur; + } + struct ST_flow_table_array_munge { + ObjGenericComposite table_object; + string[][] table_array; + } + struct ST_flow_table_of_contents_gather_headings { + ObjGenericComposite[] the_document_toc_section; + string[][string] lev4_subtoc; + } + struct ST_flow_bibliography { + JSONValue[] biblio_sorted; + JSONValue[] bib_arr_json; + string[] biblio_unsorted_incomplete; + } + struct ST_flow_table_closed_make_special_notation_table { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_; + int cntr; + uint[string] pith; + } + struct ST_flow_block_flag_line_empty { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + string[][string][string] bookindex_unordered_hashes; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_; + int cntr; + uint[string] pith; + } + struct ST_flow_table_substantive_munge { + ObjGenericComposite table_object; + string table_substantive; + } + struct _loopMarkupSrcByLineStruct { + ObjGenericComposite[] toc; + ObjGenericComposite[] body; + ObjGenericComposite[] glossary; + ObjGenericComposite[] blurb; + string[string] object_notes; + string[][string] segnames; + } + enum DocStructMarkupHeading { + h_sect_A, + h_sect_B, + h_sect_C, + h_sect_D, + h_text_1, + h_text_2, + h_text_3, + h_text_4, + h_text_5, // extra level, drop + content_non_header + } // header section A-D; header text 1-4 + enum Status { off, on, } + enum OCNtype { ocn, non, bkidx, } + enum DomTags { none, open, close, close_and_open, open_still, } + enum Substitute { match, markup, } + static auto eN() { + struct _e { + enum bi { + off, + on, + } + enum ocn { + off, + on, + closing, + bkidx, + reset, + } + enum sect { + unset, + head, + toc, + substantive, + bibliography, + glossary, + book_index, + blurb, + } + enum txt_is { + off, + para, + heading, + } + enum blk_is { + off, + code, + poem, + block, + group, + table, + quote, + } + enum blk_state { + off, + on, + closing, + } + enum blk_delim { + off, + curly, + tic, + curly_special, + tic_special, + } + } + return _e(); + } +} diff --git a/src/sisudoc/meta/metadoc_show_config.d b/src/sisudoc/meta/metadoc_show_config.d new file mode 100644 index 0000000..8a6af5d --- /dev/null +++ b/src/sisudoc/meta/metadoc_show_config.d @@ -0,0 +1,232 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_show_config; +@safe: +template spineShowSiteConfig() { + void spineShowSiteConfig(O,T)( + O opt_action, + T config, + ) { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + 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, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto min_repeat_number = 66; + auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length + + doc_matters.conf_make_meta.meta.creator_author.length + 4); + char_repeat_number = (char_repeat_number > min_repeat_number) + ? char_repeat_number + : min_repeat_number; + if (doc_matters.opt.action.show_config + && doc_matters.opt.action.debug_do + ) { + writeln(doc_matters.conf_make_meta.conf); + } + if (doc_matters.opt.action.show_config) { + writefln( + "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", + markup.repeat_character_by_number_provided("-", char_repeat_number), + doc_matters.conf_make_meta.meta.title_full, + doc_matters.conf_make_meta.meta.creator_author, + doc_matters.src.filename, + markup.repeat_character_by_number_provided("-", char_repeat_number), + "- webserv host name:", + doc_matters.conf_make_meta.conf.w_srv_host, + "- webserv doc root (part):", + doc_matters.conf_make_meta.conf.w_srv_data_root_part, + "- webserv doc path:", + doc_matters.conf_make_meta.conf.w_srv_data_root_path, + "- webserv images (location):", + doc_matters.conf_make_meta.conf.w_srv_images_root_part, + "- webserv doc root url:", + doc_matters.conf_make_meta.conf.w_srv_data_root_url, + "- webserv cgi host (host):", + doc_matters.conf_make_meta.conf.w_srv_cgi_host, + "- webserv cgi host path:", + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_path, + "- webserv cgi host (part):", + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_subpath, + "- webserv cgi search script:", + doc_matters.conf_make_meta.conf.w_srv_cgi_search_script, + "- webserv cgi search script in d:", + doc_matters.conf_make_meta.conf.w_srv_cgi_search_script_raw_fn_d, + "- webserv cgi url:", + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_url, + "- webserv cgi action:", + doc_matters.conf_make_meta.conf.w_srv_cgi_action, + // "- webserv cgi file links:", + // doc_matters.conf_make_meta.conf.w_srv_cgi_file_links, + "- webserv sqlite db:", + doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename, + "- output path:", + doc_matters.conf_make_meta.conf.output_path, + "- processing concordance max:", + doc_matters.conf_make_meta.conf.processing_concord_max, + // "- flag act0:", + // doc_matters.conf_make_meta.conf.flag_act0, + "- default papersize:", + doc_matters.conf_make_meta.conf.set_papersize, + "- default text wrap:", + doc_matters.conf_make_meta.conf.set_text_wrap, + "- default emphasis markup symbol:", + doc_matters.conf_make_meta.conf.set_emphasis, + "- default language:", + doc_matters.conf_make_meta.conf.set_language, + "- default hash digest:", + doc_matters.conf_make_meta.conf.set_digest, + "- search flag:", + doc_matters.conf_make_meta.conf.search_flag, + "- search action:", + doc_matters.conf_make_meta.conf.search_action, + "- search db:", + doc_matters.conf_make_meta.conf.search_db, + "- search title:", + doc_matters.conf_make_meta.conf.search_title, + ); + } + } +} diff --git a/src/sisudoc/meta/metadoc_show_make.d b/src/sisudoc/meta/metadoc_show_make.d new file mode 100644 index 0000000..817f5dc --- /dev/null +++ b/src/sisudoc/meta/metadoc_show_make.d @@ -0,0 +1,123 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_show_make; +@safe: +template spineShowMake() { + void spineShowMake(T)( + T doc_matters, + ) { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto min_repeat_number = 66; + auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length + + doc_matters.conf_make_meta.meta.creator_author.length + 4); + char_repeat_number = (char_repeat_number > min_repeat_number) + ? char_repeat_number + : min_repeat_number; + if (doc_matters.opt.action.show_make + && doc_matters.opt.action.debug_do + ) { + writeln(doc_matters.conf_make_meta.make); + } + if (doc_matters.opt.action.show_make) { + writefln( + "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", + markup.repeat_character_by_number_provided("-", char_repeat_number), + doc_matters.conf_make_meta.meta.title_full, + doc_matters.conf_make_meta.meta.creator_author, + doc_matters.src.filename, + markup.repeat_character_by_number_provided("-", char_repeat_number), + "- bold:", + doc_matters.conf_make_meta.make.bold, + "- breaks:", + doc_matters.conf_make_meta.make.breaks, + "- cover image:", + doc_matters.conf_make_meta.make.cover_image, + "- css:", + doc_matters.conf_make_meta.make.css, + "- emphasis:", + doc_matters.conf_make_meta.make.emphasis, + "- css:", + doc_matters.conf_make_meta.make.css, + "- footer:", + doc_matters.conf_make_meta.make.footer, + "- headings:", + doc_matters.conf_make_meta.make.headings, + "- home button image:", + doc_matters.conf_make_meta.make.home_button_image, + "- home button text:", + doc_matters.conf_make_meta.make.home_button_text, + "- italics:", + doc_matters.conf_make_meta.make.italics, + "- auto num top at level:", + doc_matters.conf_make_meta.make.auto_num_top_at_level, + "- auto num top level:", + doc_matters.conf_make_meta.make.auto_num_top_lv, + "- auto num depth:", + doc_matters.conf_make_meta.make.auto_num_depth, + "- texpdf font:", + doc_matters.conf_make_meta.make.texpdf_font, + ); + } + } +} diff --git a/src/sisudoc/meta/metadoc_show_metadata.d b/src/sisudoc/meta/metadoc_show_metadata.d new file mode 100644 index 0000000..320f28b --- /dev/null +++ b/src/sisudoc/meta/metadoc_show_metadata.d @@ -0,0 +1,171 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_show_metadata; +@safe: +template spineShowMetaData() { + void spineShowMetaData(T)( + T doc_matters, + ) { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto min_repeat_number = 66; + auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length + + doc_matters.conf_make_meta.meta.creator_author.length + 4); + char_repeat_number = (char_repeat_number > min_repeat_number) + ? char_repeat_number + : min_repeat_number; + if (doc_matters.opt.action.show_metadata + && doc_matters.opt.action.debug_do + ) { + writeln(doc_matters.conf_make_meta.meta); + } + if (doc_matters.opt.action.show_metadata) { + writefln( + "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", + markup.repeat_character_by_number_provided("-", char_repeat_number), + doc_matters.conf_make_meta.meta.title_full, + doc_matters.conf_make_meta.meta.creator_author, + doc_matters.src.filename, + markup.repeat_character_by_number_provided("-", char_repeat_number), + "- author:", + doc_matters.conf_make_meta.meta.creator_author, + "- author array:", + doc_matters.conf_make_meta.meta.creator_author_arr, + "- author surname:", + doc_matters.conf_make_meta.meta.creator_author_surname, + "- author email:", + doc_matters.conf_make_meta.meta.creator_author_email, + "- illustrator:", + doc_matters.conf_make_meta.meta.creator_illustrator, + "- translator:", + doc_matters.conf_make_meta.meta.creator_translator, + "- title full:", + doc_matters.conf_make_meta.meta.title_full, + "- title main:", + doc_matters.conf_make_meta.meta.title_main, + "- title sub:", + doc_matters.conf_make_meta.meta.title_subtitle, + "- title edition:", + doc_matters.conf_make_meta.meta.title_edition, + "- title language:", + doc_matters.conf_make_meta.meta.title_language, + "- title note:", + doc_matters.conf_make_meta.meta.title_note, + "- classify dewey:", + doc_matters.conf_make_meta.meta.classify_dewey, + "- classify library of congress:", + doc_matters.conf_make_meta.meta.classify_loc, + "- classify keywords:", + doc_matters.conf_make_meta.meta.classify_keywords, + "- classify topic register:", + doc_matters.conf_make_meta.meta.classify_topic_register, + "- date added to site:", + doc_matters.conf_make_meta.meta.date_added_to_site, + "- date available:", + doc_matters.conf_make_meta.meta.date_available, + "- date created:", + doc_matters.conf_make_meta.meta.date_created, + "- date issued:", + doc_matters.conf_make_meta.meta.date_issued, + "- date modified:", + doc_matters.conf_make_meta.meta.date_modified, + "- date published:", + doc_matters.conf_make_meta.meta.date_published, + "- date valid:", + doc_matters.conf_make_meta.meta.date_valid, + // links + "- notes abstract:", + doc_matters.conf_make_meta.meta.notes_abstract, + "- notes description:", + doc_matters.conf_make_meta.meta.notes_description, + "- original language:", + doc_matters.conf_make_meta.meta.original_language, + "- original language character:", + doc_matters.conf_make_meta.meta.original_language_char, + "- original source:", + doc_matters.conf_make_meta.meta.original_source, + "- original title:", + doc_matters.conf_make_meta.meta.original_title, + // publisher + "- rights copyright:", + doc_matters.conf_make_meta.meta.rights_copyright, + "- rights copyright text:", + doc_matters.conf_make_meta.meta.rights_copyright_text, + "- rights copyright audio:", + doc_matters.conf_make_meta.meta.rights_copyright_audio, + "- rights copyright cover:", + doc_matters.conf_make_meta.meta.rights_copyright_cover, + "- rights copyright illustrations:", + doc_matters.conf_make_meta.meta.rights_copyright_illustrations, + "- rights copyright photographs:", + doc_matters.conf_make_meta.meta.rights_copyright_photographs, + "- rights copyright translation:", + doc_matters.conf_make_meta.meta.rights_copyright_translation, + "- rights copyright video:", + doc_matters.conf_make_meta.meta.rights_copyright_video, + "- rights license:", + doc_matters.conf_make_meta.meta.rights_license, + ); + } + } +} diff --git a/src/sisudoc/meta/metadoc_show_summary.d b/src/sisudoc/meta/metadoc_show_summary.d new file mode 100644 index 0000000..379a1a7 --- /dev/null +++ b/src/sisudoc/meta/metadoc_show_summary.d @@ -0,0 +1,162 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta.metadoc_show_summary; +@safe: +template spineMetaDocSummary() { + void spineMetaDocSummary(S,T)( + const S doc_abstraction, + T doc_matters, + ) { + import + sisudoc.meta.defaults, + sisudoc.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto min_repeat_number = 66; + auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length + + doc_matters.conf_make_meta.meta.creator_author.length + 4); + char_repeat_number = (char_repeat_number > min_repeat_number) + ? char_repeat_number + : min_repeat_number; + if (doc_matters.opt.action.vox_gt1 + || doc_matters.opt.action.show_summary) { + string[string] check = [ + "last_object_number" : "NA [debug \"checkdoc\" not run]", + "last_object_number_body" : "0", + "last_object_number_book_index" : "0", + ]; + foreach (k; doc_matters.has.keys_seq.seg) { + foreach (obj; doc_abstraction[k]) { + if (obj.metainfo.is_of_part != "empty") { + if (!empty(obj.metainfo.object_number)) { + if (k == "body") { + check["last_object_number_body"] = obj.metainfo.object_number; + } + if (!(obj.metainfo.object_number.empty)) { + check["last_object_number"] = obj.metainfo.object_number; + } + } + if (k == "bookindex") { + if (obj.metainfo.object_number_type == 2) { + check["last_object_number_book_index"] = obj.metainfo.object_number_book_index; + } + } + } + } + } + writefln( + "%s\n\"%s\", %s\n%s [%s]\n%s\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%s", + markup.repeat_character_by_number_provided("-", char_repeat_number), + doc_matters.conf_make_meta.meta.title_full, + doc_matters.conf_make_meta.meta.creator_author, + doc_matters.src.filename, + doc_matters.src.language, + markup.repeat_character_by_number_provided("-", char_repeat_number), + "- toc arr length:", + to!int(doc_abstraction["toc"].length), + "- doc_abstraction arr length:", + to!int(doc_abstraction["body"].length), + " doc body last obj on.#:", + to!int(check["last_object_number_body"]), + " - number of tables:", + doc_matters.has.tables, + " - number of codeblocks:", + doc_matters.has.codeblocks, + " - number of poems:", + doc_matters.has.poems, + " - number of blocks:", + doc_matters.has.blocks, + " - number of groups:", + doc_matters.has.groups, + " - number of images:", + doc_matters.has.images, + "- endnotes length:", // subtract headings + (doc_abstraction["endnotes"].length > 2) + ? (to!int(doc_abstraction["endnotes"].length - 2)) + : 0, + "- glossary length:", + (doc_abstraction["glossary"].length > 1) + ? (to!int(doc_abstraction["glossary"].length)) + : 0, + "- biblio length:", + (doc_abstraction["bibliography"].length > 1) + ? (to!int(doc_abstraction["bibliography"].length)) + : 0, + "- bookindex length:", + (doc_abstraction["bookindex"].length > 1) + ? (to!int(doc_abstraction["bookindex"].length)) + : 0, + " book idx last obj on.#:", + to!int(check["last_object_number_book_index"]), + "- blurb length:", + (doc_abstraction["blurb"].length > 1) + ? (to!int(doc_abstraction["blurb"].length)) + : 0, + "* last obj on.#:", + to!int(check["last_object_number"]), + "number of segments:", + (doc_matters.has.segnames_lv4.length > 1) + ? (to!int(doc_matters.has.segnames_lv4.length)) + : 0, + markup.repeat_character_by_number_provided("-", min_repeat_number), + ); + } + } +} diff --git a/src/sisudoc/meta/package.d b/src/sisudoc/meta/package.d new file mode 100644 index 0000000..1926eb6 --- /dev/null +++ b/src/sisudoc/meta/package.d @@ -0,0 +1,64 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.meta; +public import + sisudoc.meta.defaults; +/+ std +/ +public import + std.array, + std.exception, + std.range, + std.regex, + std.stdio, + std.string, + std.typecons, + // std.uni, + std.utf, + std.conv : to; diff --git a/src/sisudoc/meta/rgx.d b/src/sisudoc/meta/rgx.d new file mode 100644 index 0000000..0b5f9f0 --- /dev/null +++ b/src/sisudoc/meta/rgx.d @@ -0,0 +1,270 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + regex: regular expressions used in sisu document parser ++/ +module 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[0-9]+)(?:-[0-9]+)?)"); + static trailing_comma = ctRegex!(",[ ]*$"); + static trailing_linebreak = ctRegex!(",[ ]{1,2}\\\\\\\\\n[ ]{4}$","m"); + static newline_eol_strip_preceding = ctRegex!("[ ]*\n"); + static newline_eol_delimiter_only = ctRegex!("^\n"); + static markup_inline_linebreak = ctRegex!(`\s*\\\\s*`, "m"); + static para_delimiter = ctRegex!("\n[ ]*\n+"); + static table_col_delimiter = ctRegex!("[ ]*\n+", "mg"); + static table_row_delimiter = ctRegex!("\n[ ]*\n+", "mg"); + static table_row_delimiter_special = ctRegex!("[ ]*\n", "mg"); + static table_col_delimiter_special = ctRegex!("[ ]*[|][ ]*", "mg"); + static levels_numbered = ctRegex!(`^[0-9]$`); + static levels_numbered_headings = ctRegex!(`^[0-7]$`); + static numeric_col = ctRegex!(`^[ 0-9,.%$£₤Є€€¥()-]+$`); + /+ comments +/ + static comment = ctRegex!(`^%+ `); + /+ header +/ + /+ header +/ + static variable_doc_title_author_date = ctRegex!(`@title-author-date`); + static variable_doc_title_author = ctRegex!(`@title-author`); + static variable_doc_title = ctRegex!(`@title`); + static variable_doc_author = ctRegex!(`@author|@creator`); + static variable_doc_date = ctRegex!(`@date`); + static raw_author_munge = ctRegex!(`(?P \S.+?),\s+(?P .+)`,"i"); + static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); + /+ heading operators +/ + static heading_a = ctRegex!(`^:?[A][~] `, "m"); + static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); + static headings = ctRegex!(`^:?(?P [A-D1-4])[~](?:[a-z0-9_.-]*[?]?|[!](?:glossary|bibliogrphy|biblio|references?|blurb))(?:\s|$)`,"i"); + static heading_seg_and_above = ctRegex!(`^:?([A-D1])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); + static heading_anchor_tag = ctRegex!(`^:?[A-D1-4][~](?P [a-z0-9_.-]+) `,"i"); + static heading_identify_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(?:(?:(?:chapter|article|section|clause)\s+[0-9.]+)|(?:[0-9]+))`,"i"); + static heading_extract_named_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(chapter|article|section|clause)\s+((?:[0-9]+[.:])*[0-9]+)(?=[.:;, ]|$)`,"i"); + static heading_extract_unnamed_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+((?:[0-9]+.)*[0-9]+)(?=[.:;, ]|$)`); + static heading_marker_missing_tag = ctRegex!(`^:?([A-D1-4])[~] `); + static heading_anchor_tag_plus_colon = ctRegex!(`^:?([A-D1-4][~])([a-z0-9_.:-]+) `,"i"); + static heading_marker_tag_has_colon = ctRegex!(`([:])`); + static heading_biblio = ctRegex!(`^1[~][!](biblio(?:graphy)?|references?)`); + static heading_glossary = ctRegex!(`^1[~][!](glossary)`); + static heading_blurb = ctRegex!(`^1[~][!](blurb)`); + /+ paragraph operators +/ + static para_bullet = ctRegex!(`^_[*] `); + static para_bullet_indent = ctRegex!(`^_(?P [1-9])[*] `); + static para_indent = ctRegex!(`^_(?P [1-9])[ ]`); + static para_indent_hang = ctRegex!(`^_(?P [0-9])_(?P [0-9])[ ]`); + static para_attribs = ctRegex!(`^_(?:(?:[0-9])(?:_([0-9]))?|(?:[1-9])?[*]) `); + static para_inline_link_anchor = ctRegex!(`\*[~](?P [a-z0-9_.-]+)(?= |$)`,"i"); + /+ blocked markup +/ + static block_open = ctRegex!("^((code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|^`{3} (code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?|^[{]table[(](?:h;)?(?P (?:[ ,]+[0-9]+)+)[)][}]"); + static block_poem_open = ctRegex!("^((poem(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|`{3} poem(?:[(][ a-zA-Z0-9;:,]*[)])?)"); + /+ blocked markup tics +/ + static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P [a-z][0-9a-z#+_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_poem_open = ctRegex!("^`{3} poem(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_group_open = ctRegex!("^`{3} group(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_block_open = ctRegex!("^`{3} block(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_quote_open = ctRegex!("^`{3} quote(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_table_open = ctRegex!("^`{3} table(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?"); // ctRegex!("^`{3} table(?:\(.*?\))?"); + static block_tic_close = ctRegex!("^(`{3})$","m"); + /+ blocked markup curly +/ + static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_code_close = ctRegex!(`^([}]code)`); + static block_curly_poem_open = ctRegex!(`^(poem(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_poem_close = ctRegex!(`^([}]poem)`); + static block_curly_group_open = ctRegex!(`^(group(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_group_close = ctRegex!(`^([}]group)`); + static block_curly_block_open = ctRegex!(`^(block(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_block_close = ctRegex!(`^([}]block)`); + static block_curly_quote_open = ctRegex!(`^(quote(?:[.](?P [a-z][0-9a-z_]+))?(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_quote_close = ctRegex!(`^([}]quote)`); + static block_curly_table_open = ctRegex!(`^table(?:[(](?P [ a-zA-Z0-9;:,]*)[)])?[{][ ]*$`); + static block_curly_table_close = ctRegex!(`^([}]table)`); + static block_curly_table_special_markup = ctRegex!(`^[{]table[(](?P (?:(h);)?(?P (?:[, ]+[0-9]+)+))[)][}]`, "mg"); + static code_numbering = ctRegex!(`(?P \blinenumber\b|\bnumber\b|\blnr\b)`); + static table_head_instructions = ctRegex!(`(?:(?P h);)?(?:[ ]+c(?P [0-9]):)?(?P (?:[, ]+[0-9]+[lr]?)+)`); + static table_col_widths_and_alignment = ctRegex!(`(?P [0-9]+)(?P [lr]?)`); + static table_col_widths = ctRegex!(`(?P [0-9]+)`); + static table_col_align_match = ctRegex!(`(?P [lr])`); + static table_col_separator_nl = ctRegex!(`[┊]$`, "mg"); + /+ inline markup footnotes endnotes +/ + static inline_notes_curly_gen = ctRegex!(`~\{.+?\}~`, "m"); + static inline_notes_curly = ctRegex!(`~\{\s*(.+?)\}~`, "mg"); + static inline_notes_curly_sp_asterisk = ctRegex!(`~\{[*]+\s+(.+?)\}~`, "m"); + static inline_notes_curly_sp_plus = ctRegex!(`~\{[+]+\s+(.+?)\}~`, "m"); + static note_ref = ctRegex!(`^\S+?noteref_(?P[0-9]+)`, "mg"); // {^{73.}^}#noteref_73 + static smid_inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); + static smid_inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); + static smid_inline_link_naked_url = ctRegex!(`(?P ^|[ (\[])(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?=[.,;:?!'"]?([ )\]]|$))`, "mg"); + static smid_inline_link_markup_regular = ctRegex!(`(?P^|[ (\[])\{\s*(?P.+?)\s*\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P .+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); + static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P .+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); + static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); + static smid_image = ctRegex!(`(?P (?:^|[ ])[{┥](?:~\^\s+|\s*))(?P[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P (?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); + static smid_image_generic = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + static smid_image_with_dimensions = ctRegex!(`(?P (?:^|[ ])[{┥](?:~\^\s+|\s*))(?P[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))\s+(?P \d+)x(?P \d+)\s*(?P (?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); + static smid_mod_image_without_dimensions = ctRegex!(`[{┥](?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0.*[}┝](?:image|┤.*?├|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + static smid_image_delimit = ctRegex!(`(?P ^|[ ])\{\s*(?P.+?)\s*\}(?:image)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + /+ inline markup book index +/ + static book_index_item = ctRegex!(`^=\{\s*(?P .+?)\}$`, "m"); + static book_index_item_open = ctRegex!(`^=\{\s*([^}]*?)$`); + static book_index_item_close = ctRegex!(`^(.*?)\}$`, "m"); + static auto_heading_numbering_lv1 = ctRegex!(`^1~`, "m"); + static auto_heading_numbering_off_lv1 = ctRegex!(`^1~\S*?-\s`, "m"); + static auto_heading_numbering_off_lv2 = ctRegex!(`^2~\S*?-\s`, "m"); + static auto_heading_numbering_off_lv3 = ctRegex!(`^3~\S*?-\s`, "m"); + static auto_heading_numbering_off_lv4 = ctRegex!(`^4~\S*?-\s`, "m"); + /+ no object_number object +/ + static object_number_off = ctRegex!(`~#[ ]*$`, "m"); + static object_number_off_dummy_heading = ctRegex!(`-#$`, "m"); + static object_number_off_all = ctRegex!(`[~-]#$`, "m"); + static repeated_character_line_separator = ctRegex!(`^(?:[ ]*(?:(?:[.][ ]*){4,}|(?:[-][ ]*|[~][ ]*|[*][ ]*|[$][ ]*|[#][ ]*|[\\][ ]*|[/][ ]*){2,})\s*?)+$`); + /+ no object_number block +/ + static object_number_off_block = ctRegex!(`^--~#$`); + static object_number_off_block_dummy_heading = ctRegex!(`^---#$`); + static object_number_off_block_close = ctRegex!(`^--\+#$`); + static object_number_block_marks = ctRegex!(`^--[+~-]#$`); + /+ ignore outside code blocks +/ + static skip_from_regular_parse = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); + /+ line & page breaks +/ + static break_string = ctRegex!(`』`); + /+ biblio tags +/ + static biblio_tags = ctRegex!(`^(is|au|author_raw|author|author_arr|editor_raw|ed|editor_arr|ti|title|subtitle|fulltitle|lng|language|trans|src|jo|journal|in|vol|volume|edn|edition|yr|year|pl|place|pb|pub|publisher|url|pg|pages|note|short_name|id):\s+(.+)`); + static biblio_abbreviations = ctRegex!(`^(au|ed|ti|lng|jo|vol|edn|yr|pl|pb|pub|pg|pgs|sn)$`); + /+ bookindex split +/ + static bi_main_terms_split = ctRegex!(`\s*;\s*`); + static bi_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); + static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); + static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); + static topic_register_main_terms_split = ctRegex!(`\s*;\s*`); + static topic_register_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); + static topic_register_sub_terms_split = ctRegex!(`\s*\|\s*`); + static topic_register_multiple_sub_terms_split = ctRegex!(`␣([^|␣]+(?:\|[^|␣]+)+)`); + static newline = ctRegex!("\n", "mg"); + static space = ctRegex!(`[ ]`, "mg"); + static spaces_keep = ctRegex!(`(?P ^[ ]+|[ ]{2,})`, "mg"); // code, verse, block + static spaces_line_start = ctRegex!(`^(?P [ ]+)`, "mg"); + static nbsp_char = ctRegex!(`░`, "mg"); + static nbsp_chars = ctRegex!(`[░]+`, "mg"); + static middle_dot = ctRegex!(`·`, "mg"); + static src_pth_sst_or_ssm = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9._-]+[.](?P ss[tm]))$`); + static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P [a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`); + static src_pth_contents = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`); + static src_pth_zip = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9._-]+[.]zip)$`); + static src_pth_types = ctRegex!(`^(?P [/]?[a-zA-Z0-9._-]+/)*(?P (?P [a-zA-Z0-9._-]+[.]ss[tm])|(?P [a-zA-Z0-9._-]+/pod[.]manifest)|(?P [a-zA-Z0-9._-]+[.]zip))$`); + static src_fn = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P (?P [a-zA-Z0-9._-]+)[.](?P ss[tm]))$`); + static src_fn_master = ctRegex!(`^(?P /?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9._-]+[.]ssm)$`); + static src_fn_find_inserts = ctRegex!(`^(?P /?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9._-]+[.]ss[im])$`); + static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P [a-zA-Z0-9._-]+/)*(?P [a-zA-Z0-9._-]+[.]ss[ti])$`); + static src_base_parent_dir_name = ctRegex!(`[/](?P (?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + static src_formalised_file_path_parts = ctRegex!(`(?P (?:[/a-zA-Z0-9._-]+?)(?P [a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + /+ line breaks +/ + static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg"); + static br_linebreaks_newlines = ctRegex!(`[\n┘┙]`, "mg"); + static br_linebreaks = ctRegex!(`[┘┙]`, "mg"); + static br_line = ctRegex!(`┘`, "mg"); + static br_line_inline = ctRegex!(`┙`, "mg"); + static br_line_spaced = ctRegex!(`┚`, "mg"); + /+ inline markup footnotes endnotes +/ + static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); + static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented + static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); + static inline_notes_al_gen_text = ctRegex!(`【(?P .+?)】`, "m"); + static inline_notes_al_all_note = ctRegex!(`【(?P \d+|(?:[*]|[+])+)\s+(?P .+?)\s*】`, "mg"); + static inline_notes_al_regular_number_note = ctRegex!(`【(?P \d+)\s+(?P .+?)\s*】`, "mg"); + static inline_notes_al_special_char_note = ctRegex!(`【(?P (?:[*]|[+])+)\s+(?P .+?)】`, "mg"); + static inline_al_delimiter_open_regular = ctRegex!(`【\s`, "m"); + static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); + static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); + static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|.+))`, "mg"); + /+ inline markup links +/ + static inline_image = ctRegex!(`(?P ┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P \d+)h(?P \d+))\s*(?P .*?┝┤.*?├)`, "mg"); + static inline_image_without_dimensions = ctRegex!(`(?P ┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P 0)h(?P 0))\s*(?P .*?┝┤.*?├)`, "mg"); + static inline_image_info = ctRegex!(`☼?(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P \d+)h(?P \d+)`, "mg"); + static inline_link_anchor = ctRegex!(`┃(?P \S+?)┃`, "mg"); // TODO *~text_link_anchor + static inline_link = ctRegex!(`┥(?P .+?)┝┤(?P#?(\S+?))├`, "mg"); + static inline_link_empty = ctRegex!(`┥(?P .+?)┝┤├`, "mg"); + static inline_link_number = ctRegex!(`┥(?P .+?)┝┤(?P [0-9]+)├`, "mg"); // not used + static inline_link_number_only = ctRegex!(`(?P ┥.+?┝)┤(?P [0-9]+)├`, "mg"); + static inline_link_stow_uri = ctRegex!(`┥(?P .+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links + static inline_link_hash = ctRegex!(`┥(?P .+?)┝┤(?P#(?P \S+?))├`, "mg"); + static inline_link_seg_and_hash = ctRegex!(`┥(?P .+?)┝┤(?P(?P [^/#├]*)#(?P .+?))├`, "mg"); + static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); + static inline_link_toc_to_backmatter = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static url = ctRegex!(`https?://`, "mg"); + static uri = ctRegex!(`(?:https?|git)://`, "mg"); + static uri_identify_components = ctRegex!(`(?P (?:https?|git)://)(?P \S+?/)(?P [^/]+)$`, "mg"); + static inline_link_subtoc = ctRegex!(`^(?P [5-7])~ ┥(?P .+?)┝┤(?P.+?)├`, "mg"); + static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); + static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); + static mark_internal_site_lnk = ctRegex!(`¤`, "mg"); + static quotation_mark_sql_insert_delimiter = ctRegex!("[']", "mg"); + /+ inline markup font face mod +/ + static inline_mark_emphasis = ctRegex!(`(?P[*])\{(?P .+?)\}[*]`, "mg"); + static inline_mark_bold = ctRegex!(`(?P[!])\{(?P .+?)\}[!]`, "mg"); + static inline_mark_underscore = ctRegex!(`(?P[_])\{(?P .+?)\}[_]`, "mg"); + static inline_mark_italics = ctRegex!(`(?P[/])\{(?P .+?)\}[/]`, "mg"); + static inline_mark_superscript = ctRegex!(`(?P\^)\{(?P .+?)\}\^`, "mg"); + static inline_mark_subscript = ctRegex!(`(?P[,])\{(?P .+?)\}[,]`, "mg"); + static inline_mark_strike = ctRegex!(`(?P[-])\{(?P .+?)\}[-]`, "mg"); + static inline_mark_insert = ctRegex!(`(?P[+])\{(?P .+?)\}[+]`, "mg"); + static inline_mark_mono = ctRegex!(`(?P[#])\{(?P .+?)\}[#]`, "mg"); + static inline_mark_cite = ctRegex!(`(?P["])\{(?P .+?)\}["]`, "mg"); + static inline_faces_line = ctRegex!(`^[*!/_]_ (?P .+?)((?: [\\]{2}|[~]#){0,2}$)`); + static inline_emphasis_line = ctRegex!(`^\*_ (?P .+?)(?P (?: [\\]{2}|[~]#){0,2}$)`); + static inline_bold_line = ctRegex!(`^!_ (?P .+?)(?P (?: [\\]{2}|[~]#){0,2}$)`); + static inline_italics_line = ctRegex!(`^/_ (?P .+?)(?P (?: [\\]{2}|[~]#){0,2}$)`); + static inline_underscore_line = ctRegex!(`^__ (?P .+?)(?P (?: [\\]{2}|[~]#){0,2}$)`); + } +} diff --git a/src/sisudoc/meta/rgx_files.d b/src/sisudoc/meta/rgx_files.d new file mode 100644 index 0000000..05db651 --- /dev/null +++ b/src/sisudoc/meta/rgx_files.d @@ -0,0 +1,72 @@ +/+ +- 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 - 2024 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +/++ + regex: regular expressions used in sisu document parser ++/ +module sisudoc.meta.rgx_files; +@safe: +static template spineRgxFiles() { + static struct RgxFiles { + static src_pth_sst_or_ssm = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9._-]+[.](?P ss[tm]))$`); + static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P [a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`); + static src_pth_contents = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P [a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`); + static src_pth_zip = ctRegex!(`^(?P [/]?(?:[a-zA-Z0-9._-]+/)*)(?P