diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2024-04-10 22:24:34 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2024-04-10 23:08:18 -0400 | 
| commit | 90873fabd7451e1dd8c4b39303906e19bdc481f7 (patch) | |
| tree | 2dbb0e41f3e9c761645c8b37dafe979a01d38d32 /src/sisudoc | |
| parent | 0.15.0 (diff) | |
0.16.0 sisudoc (src/sisudoc sisudoc spine)
- src/sisudoc (replaces src/doc_reform)
- sisudoc spine (used more)
Diffstat (limited to 'src/sisudoc')
46 files changed, 33537 insertions, 0 deletions
diff --git a/src/sisudoc/COPYRIGHT b/src/sisudoc/COPYRIGHT new file mode 100644 index 0000000..37ec057 --- /dev/null +++ b/src/sisudoc/COPYRIGHT @@ -0,0 +1,166 @@ +- Name: spine - SiSU Spine, Doc Reform +  - Description: documents, structuring, processing, publishing, search +    - static content generator + +  - Author: Ralph Amissah +    [ralph.amissah@gmail.com] + +  - Copyright: (C) 2015 - 2024 Ralph Amissah + +  - code under src/* src/sisudoc/* +    - License: AGPL 3 or later: + +      Spine, Doc Reform (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, Doc Reform (related to SiSU) uses standard: +    - docReform markup syntax (based on SiSU markup) +      - standard SiSU markup syntax with modified headers and minor +        modifications +    - docReform object numbering (based on SiSU object citation numbering) +      - standard SiSU document object numbering + +  - Homepages: +    [https://www.sisudoc.org] + +- Spine, Doc Reform (SiSU) markup samples +  Individual document content Copyright (Author) [as stated in document header] +  Individual document content License (Author) [as stated in document header] + +- Dependencies [check dub.json or dub.sdl] + +  - Name: d2sqlite3 +    - Description: +      This is a small wrapper around SQLite for the D programming language. + +    - Author: +      [Nicolas Sicard] +      [https://github.com/dlang-community/d2sqlite3/graphs/contributors] + +    - Copyright: (C) 2011-2018, Nicolas Sicard + +    - code: +      - License: BSL-1.0 +        Boost Software License 1.0 +        [https://www.boost.org/LICENSE_1_0.txt] + +    - Homepages: +      [https://github.com/dlang-community/d2sqlite3] +      [https://code.dlang.org/packages/d2sqlite3] + +    - src/ext_depends/d2sqlite3 +    - sundry/spine_search_cgi/src/ext_depends_cgi/d2sqlite3 + +  - Name: dyaml +    - Description: +      D:YAML is an open source YAML parser and emitter library for the D programming language. + +    - Author: +      [Ferdinand Majerech] + +    - Copyright: (C) 2011-2018, Ferdinand Majerech + +    - code: +      - License: BSL-1.0 +        Boost Software License 1.0 +        [https://www.boost.org/LICENSE_1_0.txt] + +    - Homepages: +      [https://github.com/dlang-community/D-YAML] +      [https://code.dlang.org/packages/dyaml] + +    - src/ext_depends/D-YAML + +  - Name: imageformats +    - Description: + +    - Author: +      [Tero Hänninen] + +    - Copyright: (C) Tero Hänninen + +    - code: +      - License: BSL-1.0 +        Boost Software License 1.0 +        [https://www.boost.org/LICENSE_1_0.txt] + +    - Homepages: +      [https://github.com/lgvz/imageformats] +      [https://code.dlang.org/packages/imageformats] + +    - src/ext_depends/imageformats + +  - Name: tinyendian (dyaml dependency) +    - Description: +      TinyEndian is a minimal endianness library for the D programming language. + +    - Author: +      [Ferdinand Majerech] + +    - Copyright: (C) 2014 Ferdinand Majerech + +    - code: +      - License: BSL-1.0 +        Boost Software License 1.0 +        [https://www.boost.org/LICENSE_1_0.txt] + +    - Homepages: +      [https://github.com/dlang-community/tinyendian] +      [https://code.dlang.org/packages/tinyendian] + +    - src/ext_depends/tinyendian + +- Name: cgi.d +  - Description: + +  - Author: +    [Adam D. Ruppe] + +  - Copyright: (C) 2008 - 2023 Adam D. Ruppe + +  - code: cgi.d +    aria2c https://raw.githubusercontent.com/adamdruppe/arsd/master/cgi.d + +    - License: BSL-1.0 +      Boost Software License 1.0 +      [https://www.boost.org/LICENSE_1_0.txt] +      (Check the bottom of the file for details) + +  - Homepages: +    [https://github.com/adamdruppe/arsd] + +  - sundry/spine_search_cgi/src/ext_depends_cgi/arsd + +- Name: dub2nix +  - Description: + +  - Author: +    [Lionello Lunesu] + +  - Copyright: (C) 2019 Lionello Lunesu + +  - code: mkDub.nix (modified as needed) +    - License: MIT License + +  - Homepages: +    [https://github.com/lionello/dub2nix] diff --git a/src/sisudoc/conf/compile_time_info.d b/src/sisudoc/conf/compile_time_info.d new file mode 100644 index 0000000..e1ce86b --- /dev/null +++ b/src/sisudoc/conf/compile_time_info.d @@ -0,0 +1,88 @@ +/+ +- 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/] + ++/ +/++ +  compile_time_info ++/ +module sisudoc.conf.compile_time_info; +@safe: +template CompileTimeInfo() { +  version(Windows) { +    pragma(msg, "[ Windows compilation ]"); +    enum os = "Windows"; +  } else version(OSX) { +    pragma(msg, "[ Mac OS X POSIX System compilation ]"); +    enum os = "OSX"; +  } else version(linux) { +    pragma(msg, "[ Linux POSIX System compilation ]"); +    enum os = "Linux"; +  } else version(FreeBSD) { +    pragma(msg, "[ FreeBSD POSIX System compilation ]"); +    enum os = "FreeBSD"; +  } else version(OpenBSD) { +    pragma(msg, "[ OpenBSD POSIX System compilation ]"); +    enum os = "OpenBSD"; +  } else version(NetBSD) { +    pragma(msg, "[ NetBSD POSIX System compilation ]"); +    enum os = "NetBSD"; +  } else version(DragonFlyBSD) { +    pragma(msg, "[ DragonFlyBSD POSIX System compilation ]"); +    enum os = "DragonFlyBSD"; +  } else version(POSIX) { +    pragma(msg, "[ POSIX System compilation ]"); +    enum os = "POSIX"; +  } else { +    static assert(0, "OS not listed"); +  } +  version(D_LP64) { +    enum bits = "64 bit"; +  } else { +    enum bits = "32 bit"; +  } +} diff --git a/src/sisudoc/io_in/paths_source.d b/src/sisudoc/io_in/paths_source.d new file mode 100644 index 0000000..071abff --- /dev/null +++ b/src/sisudoc/io_in/paths_source.d @@ -0,0 +1,888 @@ +/+ +- 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/] + ++/ +/++ +  read configuration files<BR> +  - read config files<BR> +  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<dir>(?:[a-zA-Z0-9._-]+))/pod/" ~ filename.stripExtension)) +            ) { +              _dir = ((path_and_fn.chainPath("../../")).asNormalizedPath).array; +              assert(_dir == m.captures["dir"]); +            } else { +              _dir = ((path_and_fn.chainPath("../../../")).asNormalizedPath).array; +              assert(_dir == absolute_path_to_src +                .match(rgx_files.src_base_parent_dir_name).captures["dir"]); +            } +            if (_opt_action.debug_do) { +              writeln("--> (base_dir)  ", _dir); +            } +            return _dir; +          } +          string base_parent_dir_path() { +            string _dir; +            if ( +              auto m = (absolute_path_to_src) +              .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/pod/" ~ filename.stripExtension)) +            ) { +              _dir = ((path_and_fn.chainPath("../../")).asNormalizedPath).array; +            } else { +              _dir = ((path_and_fn.chainPath("../../../")).asNormalizedPath).array; +            } +            return _dir; +          } +          string base_dir_path() { +            string _dir; +            if ( +              auto m = (absolute_path_to_src) +              .match(rgx_files.src_formalised_file_path_parts) +            ) { +              _dir = ((m.captures["pth"]).asNormalizedPath).array; +            } else if ( +             auto m = (absolute_path_to_src) +             .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/pod/" ~ filename.stripExtension)) +            ) { +              _dir = ((path_and_fn.chainPath("../")).asNormalizedPath).array; +            } else { +              _dir = ((path_and_fn.chainPath("../../")).asNormalizedPath).array; +            } +            if (_opt_action.debug_do) { +              writeln("--> (base_dir_path) ", _dir); +            } +            return _dir; +          } +          string media_dir_path() { +            string _dir = ((base_dir_path.chainPath("media")).asNormalizedPath).array; +            return _dir; +          } +          string image_dir_path() { +            string _paths; +            string[] _possible_img_pths = [ "./image", "../image", "../../image" ]; +            string _img_pth_found = ""; +            if (is_pod) { +              _img_pth_found = ((file_with_absolute_path.dirName ~ "/../../image").asNormalizedPath).array; +            } else { +              string _img_pth(string _possible_img_pth) { +                return ((file_with_absolute_path.dirName ~ "/" ~ _possible_img_pth).asNormalizedPath).array; +              } +              foreach(_possible_img_pth; _possible_img_pths) { +                if (exists(_img_pth(_possible_img_pth))) { +                  _img_pth_found = _img_pth(_possible_img_pth); +                  break; +                } else { +                  _paths ~= " " ~ _img_pth(_possible_img_pth); +                } +              } +            } +            if (_img_pth_found.empty) { +              writeln("WARNING not image path found, searched: ", _paths); +            } +            return _img_pth_found; +          } +          auto conf_dir_path() { +            return ((base_dir_path.chainPath("conf")).asNormalizedPath).array; +          } +          auto base_parent_dir() { +            string _dir; +            if ( +              auto m = (absolute_path_to_src) +              .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/pod/" ~ filename.stripExtension)) +            ) { +              _dir = m.captures["dir"]; +            } else { +              _dir = (absolute_path_to_src).match(rgx_files.src_base_parent_dir_name).captures["dir"]; +            } +            if (_opt_action.debug_do) { +              writeln("--> (base_parent_dir) ", _dir); +            } +            return _dir; +          } +          string[] config_dirs() { +            string[] _config_dirs; +            if (is_pod) { +            } else {} +            return _config_dirs; +          } +          string[] image_dirs() { +            string[] _image_dirs; +            if (is_pod) { +            } else {} +            return _image_dirs; +          } +        } +        return SRC_(); +      } +      auto output() { +        /+ +          - command line if output path set +          - config file if found and set set +            - search for and if exists read config +              - default paths to config related to: +                - source markup path; +                - current dir; +                - home dir +              - get output path if set +          - (program) default within current directory? +        +/ +        auto _env = _env; +        struct Out_ { +          auto path() { +            auto _output_path = _env["pwd"]; +            if ((_opt_action.output_dir_set.length > 0) +              && isValidPath(_opt_action.output_dir_set) +            ) { +              _output_path = ((_opt_action.output_dir_set).asNormalizedPath).array; +              if (!exists(_output_path)) { +                try { +                  _output_path.mkdirRecurse; +                // } catch (ErrnoException ex) { +                } catch (Exception ex) { +                  // Handle error +                } +              } +              assert(_output_path.isDir, +                "not a directory: " ~ _output_path); +              // TODO always test that is a directory and it is writable +            } +            return _output_path; +          } +        } +        return Out_(); +      } +    } +    return ManifestMatters_(); +  } +} +template configFilePaths() { +  auto configFilePaths(M,E)( +    M      _manifested, +    E      _env, +    string _cli_config_path_set = "" +  ) { +    struct ConfFilePaths { +      string config_filename_document() { +        return "dr_document_make"; +      } +      string config_filename_site() { +        return "config_local_site"; +      } +      auto possible_config_path_locations() { +        struct _ConfFilePaths { +          string[] dr_document_make() { +            /+ FIX clean up conf paths ↓ +/ +            /+ config local site (file system only, not in pod) +/ +            /+ return paths +/ +            string[] _possible_config_path_locations; +            if (_cli_config_path_set.empty) { +              if (_manifested.src.is_pod) { +                /+ config document in pod +/ +                string _dr_doc_conf_pod; +                string _dr_doc_conf_pod_text; +                _dr_doc_conf_pod = asNormalizedPath(chainPath( +                  to!string(_env["pwd"]), +                  _manifested.pod.manifest_path ~ "/conf" +                )).array; +                _dr_doc_conf_pod_text = asNormalizedPath(chainPath( +                  to!string(_env["pwd"]), +                  _manifested.pod.manifest_path ~ "/media/text/" ~ _manifested.src.lng ~ "/conf" +                )).array; +                /+ return paths +/ +                _possible_config_path_locations = [ +                  _dr_doc_conf_pod_text, +                  _dr_doc_conf_pod, +                ]; +              } else { +                /+ config document (& or local site) on filesystem +/ +                string _dr_doc_conf_pwd   = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; // think about +                string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; +                /+ return paths +/ +                _possible_config_path_locations = [ +                  _dr_doc_conf_pwd, +                  _dr_doc_conf_pwd_a, +                  _dr_doc_conf_pwd_b, +                  _dr_doc_conf_pwd_c, +                  _dr_doc_conf_pwd_d, +                ]; +              } +            } else if (_cli_config_path_set.isDir) { +               _possible_config_path_locations = [_cli_config_path_set ]; +            // } else if (_cli_config_path_set.isFile) { // use file, taken care of elsewhere +            } +            /+ FIX clean up conf paths ↑ +            (compare pwd to doc path location, and build config path) +            +/ +            return _possible_config_path_locations; +          } +          string[] config_local_site() { +            /+ FIX clean up conf paths ↓ +/ +            /+ config local site (file system only, not in pod) +/ +            string[] _possible_config_path_locations; +            if (_cli_config_path_set.empty) { +              string _dot_pwd        = ((chainPath(to!string(_env["pwd"]), ".dr")).asNormalizedPath).array; +              string _underscore_pwd = ((chainPath(to!string(_env["pwd"]), "_dr")).asNormalizedPath).array; +              string _dot_home       = ((chainPath(to!string(_env["home"]), ".dr")).asNormalizedPath).array; +              /+ return paths +/ +              if (_manifested.src.is_pod) { +                string _collection_root_a = ((chainPath(to!string(_manifested.pod.collection_root.to!string), ".dr")).asNormalizedPath).array; +                string _collection_root_b = ((chainPath(to!string(_manifested.pod.collection_root.to!string), "_dr")).asNormalizedPath).array; +                _possible_config_path_locations = [ +                  _dot_pwd, +                  _underscore_pwd, +                  _collection_root_a, +                  _collection_root_b, +                  _dot_home, +                  "/etc/dr", +                ]; +              } else { +                /+ config document (& or local site) on filesystem +/ +                string _dr_doc_conf_pwd   = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; +                string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; +                _possible_config_path_locations = [ +                  _dr_doc_conf_pwd, +                  _dr_doc_conf_pwd_a, +                  _dr_doc_conf_pwd_b, +                  _dr_doc_conf_pwd_c, +                  _dr_doc_conf_pwd_d, +                  _dot_pwd, +                  _underscore_pwd, +                  _dot_home, +                  "/etc/dr" +                ]; +              } +            } else { +              _possible_config_path_locations = [ +                _cli_config_path_set +              ]; +            } +            /+ FIX clean up conf paths ↑ +            (compare pwd to doc path location, and build config path) +            +/ +            return _possible_config_path_locations; +          } +        } +        return _ConfFilePaths(); +      } +    } +    return ConfFilePaths(); +  } +} +template spinePathsSRC() { +  mixin spineRgxFiles; +  static auto rgx_files = RgxFiles(); +  auto spinePathsSRC(D,Fn)( +    D   _pwd, +    Fn  _fn_src_and_path, +  ) { +    struct drSrcPaths { +      auto pwd() { +        return _pwd; +      } +      string language() { +        // use command line info as well? +        string _k; +        if (auto m = _fn_src_and_path.match(rgx_files.language_code_and_filename)) { +          _k = m.captures[1]; +        } else { /+ unknown until doc_meta read, (could provide & use command line info?) +/ +          _k = "xx"; // original default was "en" but is not known +        } +        return _k; +      } +      string doc_root() { +        return "dr_doc"; +      } +      auto media_root() { +        return ((doc_root.chainPath("media")).asNormalizedPath).array; +      } +      auto conf_root() { +        return ((doc_root.chainPath("conf")).asNormalizedPath).array; +      } +      auto text_root() { +        return ((media_root.chainPath("text")).asNormalizedPath).array; +      } +      auto image_root() { +        return ((media_root.chainPath("image")).asNormalizedPath).array; +      } +      auto doc_src_fn_with_path_for_text_root_and_lng() { +        return ((text_root.chainPath(language)).asNormalizedPath).array; +      } +      auto doc_src_fn() { +        return ((_fn_src_and_path.baseName).asNormalizedPath).array; +      } +      auto doc_src_with_path() { +        return ((pwd.chainPath(_fn_src_and_path)).asNormalizedPath).array; +      } +    } +    return drSrcPaths(); +  } +} + + +template spinePathsPods() { +  string _suffix = ".zip"; +  auto spinePathsPods(M)(M doc_matters) { +    string _base_dir_pod = (doc_matters.output_path.length > 0) +    ? doc_matters.output_path ~ "/pod" +    : "/pod"; +    string _base_dir_doc = "dr_doc"; +    struct _PodPaths { +      string base_filename_(string fn_src) { +        return  fn_src.baseName.stripExtension; +      } +      string internal_base() { +        return "pod"; +      } +      string pod_dir_() { +        return _base_dir_pod; +      } +      string dr_doc_dir_() { +        return _base_dir_doc; +      } +      string pod_filename_(string fn_src) { +        return _base_dir_pod.chainPath(base_filename_(fn_src) ~ _suffix).array; +      } +      string base_filesystem_(string fn_src) { +        string pth = _base_dir_pod.chainPath(base_filename_(fn_src)).array; +        assert(pth == _base_dir_pod ~ "/"  ~ base_filename_(fn_src), +          pth ~ " == "  ~ _base_dir_pod ~ "/" ~ base_filename_(fn_src) ~ "?"); +        return pth; +      } +      string output_pod_manifest_file(string fn_src) { +        return base_filesystem_(fn_src).chainPath("pod.manifest").array; +      } +      string base_pod_(string fn_src) { +        return _base_dir_pod.chainPath(base_filename_(fn_src)).array; // change this +      } +      auto base_filename(string fn_src) { +        auto pth_1_ = base_filename_(fn_src); +        auto pth_2_ = base_filename_(fn_src); +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto pod_filename(string fn_src) { +        auto pth_1_ = pod_filename_(fn_src); +        auto pth_2_ = pod_filename_(fn_src); +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto base(string fn_src) { +        auto pth_1_ = ""; +        auto pth_2_ = base_filesystem_(fn_src); +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto pod_root(string fn_src) { +        auto pth_1_ = "pod"; +        auto pth_2_ = ((base(fn_src).filesystem_open_zpod.chainPath("")).asNormalizedPath).array; // "dr_doc" +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto conf_root(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = "conf"; +        auto pth_2_ = ((pod_root(fn_src).filesystem_open_zpod.chainPath("conf")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto css(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((conf_root(fn_src).zpod.chainPath("css")).asNormalizedPath).array; +        auto pth_2_ = ((conf_root(fn_src).filesystem_open_zpod.chainPath("css")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto pod_manifest(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((pod_root(fn_src).zpod.chainPath("pod.manifest")).asNormalizedPath).array; +        auto pth_2_ = ((pod_root(fn_src).filesystem_open_zpod.chainPath("pod.manifest")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto media_root(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((pod_root(fn_src).zpod.chainPath("media")).asNormalizedPath).array; +        auto pth_2_ = ((pod_root(fn_src).filesystem_open_zpod.chainPath("media")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto text_root(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((media_root(fn_src).zpod.chainPath("text")).asNormalizedPath).array; +        auto pth_2_ = ((media_root(fn_src).filesystem_open_zpod.chainPath("text")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto doc(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = text_root(fn_src).zpod; +        auto pth_2_ = text_root(fn_src).filesystem_open_zpod; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto doc_lng(string fn_src, string lng) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((text_root(fn_src).zpod.chainPath(lng)).asNormalizedPath).array; +        auto pth_2_ = ((text_root(fn_src).filesystem_open_zpod.chainPath(lng)).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto image_root(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((media_root(fn_src).zpod.chainPath("image")).asNormalizedPath).array; +        auto pth_2_ = ((media_root(fn_src).filesystem_open_zpod.chainPath("image")).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto fn_pod_filelist(string fn_src) { +        auto pod_root_ = pod_root(fn_src); +        auto _manifested = PodManifest!()(doc_matters.opt.action, fn_src).pod_manifest_filename; +        auto pth_1_ = _manifested; +        auto pth_2_ = ((pod_root(fn_src).filesystem_open_zpod.chainPath(_manifested)).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto fn_doc(string fn_src, string lng) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((doc_lng(fn_src, lng).zpod.chainPath(fn_src.baseName)).asNormalizedPath).array; +        auto pth_2_ = ((doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_src.baseName)).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +      auto fn_doc_insert(string fn_src, string fn_insert, string lng) { +        auto pod_root_ = pod_root(fn_src); +        auto pth_1_ = ((doc_lng(fn_src, lng).zpod.chainPath(fn_insert.baseName)).asNormalizedPath).array; +        auto pth_2_ = ((doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_insert.baseName)).asNormalizedPath).array; +        struct _pods { +          auto zpod() { +            return pth_1_; +          } +          auto filesystem_open_zpod() { +            // assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); +            return pth_2_; +          } +        } +        return _pods(); +      } +    } +    return _PodPaths(); +  } +} diff --git a/src/sisudoc/io_in/read_config_files.d b/src/sisudoc/io_in/read_config_files.d new file mode 100644 index 0000000..c71364c --- /dev/null +++ b/src/sisudoc/io_in/read_config_files.d @@ -0,0 +1,279 @@ +/+ +- 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/] + ++/ +/++ +  read configuration files<BR> +  - read config files<BR> +  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;<BR> +  - open markup files<BR> +  - 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 ~ "<br>"); +        string[] pair = pair_str.split("="); +        canned_query[pair[0]] = pair[1]; +      } +      // foreach (field, content; canned_query) { +      //   cgi.write(field ~ ": " ~ content ~ "<br>"); +      // } +    } +    static struct Rgx { +      // static canned_query   = ctRegex!(`\A(?P<matched>.+)\Z`,                            "m"); +      static search_text_area  = ctRegex!(`\A(?P<matched>.+)\Z`,                            "m"); +      // static fulltext       = ctRegex!(`\A(?P<matched>.+)\Z`,                            "m"); +      static line              = ctRegex!(`^(?P<matched>.+?)(?: ~|$)`,                      "m"); +      static text              = ctRegex!(`(?:^|\s~\s*)text:\s+(?P<matched>.+?)(?: ~|$)`,   "m"); +      static author            = ctRegex!(`(?:^|\s~\s*)author:\s+(?P<matched>.+)$`,         "m"); +      static title             = ctRegex!(`(?:^|\s~\s*)title:\s+(?P<matched>.+)$`,          "m"); +      static uid               = ctRegex!(`(?:^|\s~\s*)uid:\s+(?P<matched>.+)$`,            "m"); +      static fn                = ctRegex!(`(?:^|\s~\s*)fn:\s+(?P<matched>.+)$`,             "m"); +      static keywords          = ctRegex!(`(?:^|\s~\s*)keywords:\s+(?P<matched>.+)$`,       "m"); +      static topic_register    = ctRegex!(`(?:^|\s~\s*)topic_register:\s+(?P<matched>.+)$`, "m"); +      static subject           = ctRegex!(`(?:^|\s~\s*)subject:\s+(?P<matched>.+)$`,        "m"); +      static description       = ctRegex!(`(?:^|\s~\s*)description:\s+(?P<matched>.+)$`,    "m"); +      static publisher         = ctRegex!(`(?:^|\s~\s*)publisher:\s+(?P<matched>.+)$`,      "m"); +      static editor            = ctRegex!(`(?:^|\s~\s*)editor:\s+(?P<matched>.+)$`,         "m"); +      static contributor       = ctRegex!(`(?:^|\s~\s*)contributor:\s+(?P<matched>.+)$`,    "m"); +      static date              = ctRegex!(`(?:^|\s~\s*)date:\s+(?P<matched>.+)$`,           "m"); +      static results_type      = ctRegex!(`(?:^|\s~\s*)type:\s+(?P<matched>.+)$`,           "m"); +      static format            = ctRegex!(`(?:^|\s~\s*)format:\s+(?P<matched>.+)$`,         "m"); +      static source            = ctRegex!(`(?:^|\s~\s*)source:\s+(?P<matched>.+)$`,         "m"); +      static language          = ctRegex!(`(?:^|\s~\s*)language:\s+(?P<matched>.+)$`,       "m"); +      static relation          = ctRegex!(`(?:^|\s~\s*)relation:\s+(?P<matched>.+)$`,       "m"); +      static coverage          = ctRegex!(`(?:^|\s~\s*)coverage:\s+(?P<matched>.+)$`,       "m"); +      static rights            = ctRegex!(`(?:^|\s~\s*)rights:\s+(?P<matched>.+)$`,         "m"); +      static comment           = ctRegex!(`(?:^|\s~\s*)comment:\s+(?P<matched>.+)$`,        "m"); +      // static abstract_         = ctRegex!(`(?:^|\s~\s*)abstract:\s+(?P<matched>.+)$`,       "m"); +      static src_filename_base = ctRegex!(`^src_filename_base:\s+(?P<matched>.+)$`,         "m"); +    } +    struct searchFields { +      string canned_query      = ""; // GET  canned_query     == cq +      string search_text_area  = ""; // POST search_text_area == tsa +      string text              = ""; // text              == txt +      string author            = ""; // author            == au +      string title             = ""; // title             == ti +      string uid               = ""; // uid               == uid +      string fn                = ""; // fn                == fn +      string keywords          = ""; // keywords          == kw +      string topic_register    = ""; // topic_register    == tr +      string subject           = ""; // subject           == su +      string description       = ""; // description       == de +      string publisher         = ""; // publisher         == pb +      string editor            = ""; // editor            == ed +      string contributor       = ""; // contributor       == ct +      string date              = ""; // date              == dt +      string format            = ""; // format            == fmt +      string source            = ""; // source            == src sfn +      string language          = ""; // language          == lng +      string relation          = ""; // relation          == rl +      string coverage          = ""; // coverage          == cv +      string rights            = ""; // rights            == rgt +      string comment           = ""; // comment           == cmt +      // string abstract          = ""; +      string src_filename_base = ""; // src_filename_base == bfn +      string results_type      = ""; // results_type      == rt     radio +      string sql_match_limit   = ""; // sql_match_limit   == sml    radio +      string sql_match_offset  = ""; // sql_match_offset  == smo +      string stats             = ""; // stats             == sts    checked +      string echo              = ""; // echo              == ec     checked +      string url               = ""; // url               == url    checked +      string searched          = ""; // searched          == se     checked +      string sql               = ""; // sql               == sql    checked +    } +    auto rgx  = Rgx(); +    auto got  = searchFields(); +    if (environment.get("REQUEST_METHOD", "POST") == "POST") { +      if ("sf" in cgi.post) { +        got.search_text_area =  cgi.post["sf"]; +        if (auto m = got.search_text_area.matchFirst(rgx.text)) { +          got.text = m["matched"]; +          got.canned_query ~= "sf=" ~ m["matched"]; +        } else if (auto m = got.search_text_area.matchFirst(rgx.line)) { +          if ( +            !(m["matched"].matchFirst(rgx.author)) +            && !(m["matched"].matchFirst(rgx.title)) +          ) { +            got.text = m["matched"]; +            got.canned_query ~= "sf=" ~ m["matched"]; +          } +        } +        if (auto m = got.search_text_area.matchFirst(rgx.author)) { +          got.author = m["matched"]; +          got.canned_query ~= "&au=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.title)) { +          got.title = m["matched"]; +          got.canned_query ~= "&ti=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.uid)) { +          got.uid = m["matched"]; +          got.canned_query ~= "&uid=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.fn)) { +          got.fn = m["matched"]; +          got.canned_query ~= "&fn=" ~ m["matched"]; +        } else if ("fn" in cgi.post) { +          got.search_text_area ~= "\nfn: " ~ cgi.post["fn"] ~ "\n"; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.keywords)) { +          got.keywords = m["matched"]; +          got.canned_query ~= "&kw=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) { +          got.topic_register = m["matched"]; +          got.canned_query ~= "&tr=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.subject)) { +          got.subject = m["matched"]; +          got.canned_query ~= "&su=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.description)) { +          got.description = m["matched"]; +          got.canned_query ~= "&de=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.publisher)) { +          got.publisher = m["matched"]; +          got.canned_query ~= "&pb=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.editor)) { +          got.editor = m["matched"]; +          got.canned_query ~= "&ed=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.contributor)) { +          got.contributor = m["matched"]; +          got.canned_query ~= "&ct=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.date)) { +          got.date = m["matched"]; +          got.canned_query ~= "&dt=" ~ m["matched"]; +        } +        // if (auto m = got.search_text_area.matchFirst(rgx.results_type)) { +        //   got.results_type = m["matched"]; +        //   got.canned_query ~= "&rt=" ~ m["matched"]; +        // } +        if (auto m = got.search_text_area.matchFirst(rgx.format)) { +          got.format = m["matched"]; +          got.canned_query ~= "&fmt=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.source)) { +          got.source = m["matched"]; +          got.canned_query ~= "&src=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.language)) { +          got.language = m["matched"]; +          got.canned_query ~= "&lng=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.relation)) { +          got.relation = m["matched"]; +          got.canned_query ~= "&rl=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.coverage)) { +          got.coverage = m["matched"]; +          got.canned_query ~= "&cv=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.rights)) { +          got.rights = m["matched"]; +          got.canned_query ~= "&rgt=" ~ m["matched"]; +        } +        if (auto m = got.search_text_area.matchFirst(rgx.comment)) { +          got.comment = m["matched"]; +          got.canned_query ~= "&cmt=" ~ m["matched"]; +        } +        // if (auto m = search_text_area.matchFirst(rgx.abstract)) { +        //   got.abstract = m["matched"]; +        // } +        if (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) { +          got.src_filename_base = m["matched"]; +          got.canned_query ~= "&bfn=" ~ m["matched"]; +        } +      } +      if ("fn" in cgi.post) { +        got.fn =  cgi.post["fn"]; +        got.canned_query ~= "&fn=" ~ cgi.post["fn"]; +      } +      if ("rt" in cgi.post) { +        got.results_type =  cgi.post["rt"]; +        got.canned_query ~= "&rt=" ~ cgi.post["rt"]; +      } +      if ("sts" in cgi.post) { +        got.stats =  cgi.post["sts"]; +        got.canned_query ~= "&sts=" ~ cgi.post["sts"]; +      } +      if ("ec" in cgi.post) { +        got.echo =  cgi.post["ec"]; +        got.canned_query ~= "&ec=" ~ cgi.post["ec"]; +      } +      if ("url" in cgi.post) { +        got.url =  cgi.post["url"]; +        got.canned_query ~= "&url=" ~ cgi.post["url"]; +      } +      if ("se" in cgi.post) { +        got.searched =  cgi.post["se"]; +        got.canned_query ~= "&se=" ~ cgi.post["se"]; +      } +      if ("sql" in cgi.post) { +        got.sql =  cgi.post["sql"]; +        got.canned_query ~= "&sql=" ~ cgi.post["sql"]; +      } +      if ("sml" in cgi.post) { +        got.sql_match_limit =  cgi.post["sml"]; +        got.canned_query ~= "&sml=" ~ cgi.post["sml"]; +      } +      if ("smo" in cgi.post) { +        got.sql_match_offset = "0";   // cgi.post["smo"]; +        got.canned_query ~= "&smo=0"; //  ~ cgi.post["smo"]; +      } +      got.canned_query = got.canned_query.strip.split(" ").join("%%20"); +      conf.query_string = got.canned_query; +      // cgi.write("f.canned_query: " ~ got.canned_query ~ "<br>"); +    } else if (environment.get("REQUEST_METHOD", "POST") == "GET") { +      got.canned_query = environment.get("QUERY_STRING", ""); +      // cgi.write("f.canned_query: " ~ got.canned_query ~ "<br>"); +      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 ~ "<br>"); +    } +    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<offset_key>[&]smo=)(?P<offset_val>[0-9]+)`); +      static results_type       = ctRegex!(`[&]rt=(?P<results_type>idx|txt)`); +      static results_type_index = ctRegex!(`[&]rt=idx`); +      static results_type_text  = ctRegex!(`[&]rt=txt`); +      static fn                 = ctRegex!(`[&]fn=(?P<fn>[^&]+)`); +    } +    return RgxCS(); +  } +  string show_matched_objects (string fn) { +    auto rgx = regex_canned_search; +    string _matched_objects_text = ""; +    string _url = canned_url; +    string _url_new = ""; +    string _matches_show_text  = "&rt=txt"; +    string _matches_show_index = "&rt=idx"; +    string _fn = "&fn=" ~ fn; +    _url_new = _url; +    if (_url_new.match(rgx.results_type_index)) { +      _url_new = _url_new.replace(rgx.results_type_index, _matches_show_text); +    } else if (_url.match(rgx.results_type_text)) { +      _url_new = _url_new.replace(rgx.results_type_text, _matches_show_index); +    } else { +      if (!(_url.match(rgx.results_type))) { +        _url_new = _url ~ _matches_show_text; +      } +    } +    if (!(_url_new.match(rgx.fn))) { +      _url_new = _url_new ~ _fn; +    } +    _matched_objects_text = +      "<font size=\"2\" color=\"#666666\">" +      ~ "<a href=\"" +      ~ _url_new +      ~ "\">" +      ~ "※" +      ~ "</a></font>"; +    return _matched_objects_text; +  } +  string base                  ; // = ""; +  string tip                   ; // = ""; +  string search_note           ; // = ""; +  uint   sql_match_offset_count   = 0; +  string previous_next () { +    auto rgx = regex_canned_search; +    string _previous_next = ""; +    int    _current_offset_value = 0; +    string _set_offset_next = ""; +    string _set_offset_previous = ""; +    string _url = canned_url; +    string _url_previous = ""; +    string _url_next = ""; +    string arrow_previous = ""; +    string arrow_next = ""; +    if (auto m = _url.matchFirst(rgx.track_offset)) { +      _current_offset_value = m.captures["offset_val"].to!int; +      _set_offset_next = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int + cv.sql_match_limit.to!int).to!string; +      _url_next = _url.replace(rgx.track_offset, _set_offset_next); +      if (_current_offset_value < cv.sql_match_limit.to!int) { +        _url_previous = ""; +      } else { +        _url_previous = ""; +        _set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string; +        _url_previous = _url.replace(rgx.track_offset, _set_offset_previous); +      } +    } else {// _current_offset_value = 0; +      _url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string; +    } +    if (_url_previous.empty) { +      arrow_previous = ""; +    } else { +      arrow_previous = +        "<font size=\"2\" color=\"#666666\">" +        ~ "<a href=\"" +        ~ _url_previous +        ~ "\">" +        ~ "<< prev" +        ~ "</a> || </font>"; +    } +    arrow_next = +      "<font size=\"2\" color=\"#666666\">" +      ~ "<a href=\"" +      ~ _url_next +      ~ "\">" +      ~ "next >>" +      ~ "</a></font>"; +    _previous_next = "<hr>" ~ arrow_previous ~ arrow_next; +    return _previous_next; +  } +  { +    header = format(q"┃ +<!DOCTYPE html> +<html> +<head> +  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +  <title> +  %s +  </title> +  <meta name="sourcefile" content="SiSU.sst"> +  <link rel="generator" href="sisudoc.org"> +  <link rel="shortcut icon" href="https://%%s/image_sys/spine.ico"> +  <style media = "all"> +   *{ +    padding                  : 0px; +    margin                   : 2px; +  } +  body { +    height                   : 100vh; +    background-color         : #%s; +  } +  body { +    color                    : #%s; +    background               : #%s; +    background-color         : #%s; +  } +  a:link { +    color                    : #%s; +    text-decoration          : none; +  } +  a:visited { +    color                    : #%s; +    text-decoration          : none; +  } +  a:hover { +    color                    : #%s; +    background-color         : #%s; +  } +  a.lnkocn:link { +    color                    : #%s; +    text-decoration          : none; +  } +  a.lnkocn:visited { +    color                    : #%s; +    text-decoration          : none; +  } +  a.lnkocn:hover { +    color                    : #%s; +    font-size                : 15px; +  } +  a:hover img { +    background-color         : #%s; +  } +  a:active { +    color                    : #%s; +    text-decoration          : underline; +  } +  .flex-container { +    display                  : flex; +  } +  div.publication { +    margin-top               : 2px; +    margin-bottom            : 4px; +    margin-left              : 0%%%%; +    margin-right             : 0%%%%; +  } +  div.textview_ocn { +    margin-left              : 0%%%%; +    margin-right             : 1%%%%; +  } +  div.textview_found { +    margin-left              : 1%%%%; +    margin-right             : 1%%%%; +  } +  textarea { +    color                    : #%s; +    background-color         : #%s; +  } +  span.match { +    color                    : #%s; +    background-color         : #%s; +  } +  p.norm { } +  p.center { text-align      : center; } +  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.publication { +    font-size                : 100%%%%; +    margin-left              : 0em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.ocn_is { +    font-size                : 100%%%%; +    display                  : inline-block; +  } +  p.matched_ocn { +    font-size                : 90%%%%; +    margin-left              : 2em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p[indent="h0i1"] { +    padding-left             : 1em; +    text-indent              : -1em; +  } +  p[indent="h0i2"] { +    padding-left             : 2em; +    text-indent              : -2em; +  } +  p[indent="h0i3"] { +    padding-left             : 3em; +    text-indent              : -3em; +  } +  p[indent="h0i4"] { +    padding-left             : 4em; +    text-indent              : -4em; +  } +  p[indent="h0i5"] { +    padding-left             : 5em; +    text-indent              : -5em; +  } +  p[indent="h0i6"] { +    padding-left             : 6em; +    text-indent              : -6em; +  } +  p[indent="h0i7"] { +    padding-left             : 7em; +    text-indent              : -7em; +  } +  p[indent="h0i8"] { +    padding-left             : 8em; +    text-indent              : -8em; +  } +  p[indent="h0i9"] { +    padding-left             : 9em; +    text-indent              : -9em; +  } +  p[indent="h1i0"] { +    padding-left             : 0em; +    text-indent              : 1em; +  } +  p[indent="h1i1"] { +    padding-left             : 1em; +    text-indent              : 0em; +  } +  p[indent="h1i2"] { +    padding-left             : 2em; +    text-indent              : -1em; +  } +  p[indent="h1i3"] { +    padding-left             : 3em; +    text-indent              : -2em; +  } +  p[indent="h1i4"] { +    padding-left             : 4em; +    text-indent              : -3em; +  } +  p[indent="h1i5"] { +    padding-left             : 5em; +    text-indent              : -4em; +  } +  p[indent="h1i6"] { +    padding-left             : 6em; +    text-indent              : -5em; +  } +  p[indent="h1i7"] { +    padding-left             : 7em; +    text-indent              : -6em; +  } +  p[indent="h1i8"] { +    padding-left             : 8em; +    text-indent              : -7em; +  } +  p[indent="h1i9"] { +    padding-left             : 9em; +    text-indent              : -8em; +  } +  p[indent="h2i0"] { +    padding-left             : 0em; +    text-indent              : 2em; +  } +  p[indent="h2i1"] { +    padding-left             : 1em; +    text-indent              : 1em; +  } +  p[indent="h2i2"] { +    padding-left             : 2em; +    text-indent              : 0em; +  } +  p[indent="h2i3"] { +    padding-left             : 3em; +    text-indent              : -1em; +  } +  p[indent="h2i4"] { +    padding-left             : 4em; +    text-indent              : -2em; +  } +  p[indent="h2i5"] { +    padding-left             : 5em; +    text-indent              : -3em; +  } +  p[indent="h2i6"] { +    padding-left             : 6em; +    text-indent              : -4em; +  } +  p[indent="h2i7"] { +    padding-left             : 7em; +    text-indent              : -5em; +  } +  p[indent="h2i8"] { +    padding-left             : 8em; +    text-indent              : -6em; +  } +  p[indent="h2i9"] { +    padding-left             : 9em; +    text-indent              : -7em; +  } +  p[indent="h3i0"] { +    padding-left             : 0em; +    text-indent              : 3em; +  } +  p[indent="h3i1"] { +    padding-left             : 1em; +    text-indent              : 2em; +  } +  p[indent="h3i2"] { +    padding-left             : 2em; +    text-indent              : 1em; +  } +  p[indent="h3i3"] { +    padding-left             : 3em; +    text-indent              : 0em; +  } +  p[indent="h3i4"] { +    padding-left             : 4em; +    text-indent              : -1em; +  } +  p[indent="h3i5"] { +    padding-left             : 5em; +    text-indent              : -2em; +  } +  p[indent="h3i6"] { +    padding-left             : 6em; +    text-indent              : -3em; +  } +  p[indent="h3i7"] { +    padding-left             : 7em; +    text-indent              : -4em; +  } +  p[indent="h3i8"] { +    padding-left             : 8em; +    text-indent              : -5em; +  } +  p[indent="h3i9"] { +    padding-left             : 9em; +    text-indent              : -6em; +  } +  p[indent="h4i0"] { +    padding-left             : 0em; +    text-indent              : 4em; +  } +  p[indent="h4i1"] { +    padding-left             : 1em; +    text-indent              : 3em; +  } +  p[indent="h4i2"] { +    padding-left             : 2em; +    text-indent              : 2em; +  } +  p[indent="h4i3"] { +    padding-left             : 3em; +    text-indent              : 1em; +  } +  p[indent="h4i4"] { +    padding-left             : 4em; +    text-indent              : 0em; +  } +  p[indent="h4i5"] { +    padding-left             : 5em; +    text-indent              : -1em; +  } +  p[indent="h4i6"] { +    padding-left             : 6em; +    text-indent              : -2em; +  } +  p[indent="h4i7"] { +    padding-left             : 7em; +    text-indent              : -3em; +  } +  p[indent="h4i8"] { +    padding-left             : 8em; +    text-indent              : -4em; +  } +  p[indent="h4i9"] { +    padding-left             : 9em; +    text-indent              : -5em; +  } +  p[indent="h5i0"] { +    padding-left             : 0em; +    text-indent              : 5em; +  } +  p[indent="h5i1"] { +    padding-left             : 1em; +    text-indent              : 4em; +  } +  p[indent="h5i2"] { +    padding-left             : 2em; +    text-indent              : 3em; +  } +  p[indent="h5i3"] { +    padding-left             : 3em; +    text-indent              : 2em; +  } +  p[indent="h5i4"] { +    padding-left             : 4em; +    text-indent              : 1em; +  } +  p[indent="h5i5"] { +    padding-left             : 5em; +    text-indent              : 0em; +  } +  p[indent="h5i6"] { +    padding-left             : 6em; +    text-indent              : -1em; +  } +  p[indent="h5i7"] { +    padding-left             : 7em; +    text-indent              : -2em; +  } +  p[indent="h5i8"] { +    padding-left             : 8em; +    text-indent              : -3em; +  } +  p[indent="h5i9"] { +    padding-left             : 9em; +    text-indent              : -4em; +  } +  p[indent="h6i0"] { +    padding-left             : 0em; +    text-indent              : 6em; +  } +  p[indent="h6i1"] { +    padding-left             : 1em; +    text-indent              : 5em; +  } +  p[indent="h6i2"] { +    padding-left             : 2em; +    text-indent              : 4em; +  } +  p[indent="h6i3"] { +    padding-left             : 3em; +    text-indent              : 3em; +  } +  p[indent="h6i4"] { +    padding-left             : 4em; +    text-indent              : 2em; +  } +  p[indent="h6i5"] { +    padding-left             : 5em; +    text-indent              : 1em; +  } +  p[indent="h6i6"] { +    padding-left             : 6em; +    text-indent              : 0em; +  } +  p[indent="h6i7"] { +    padding-left             : 7em; +    text-indent              : -1em; +  } +  p[indent="h6i8"] { +    padding-left             : 8em; +    text-indent              : -2em; +  } +  p[indent="h6i9"] { +    padding-left             : 9em; +    text-indent              : -3em; +  } +  p[indent="h7i0"] { +    padding-left             : 0em; +    text-indent              : 7em; +  } +  p[indent="h7i1"] { +    padding-left             : 1em; +    text-indent              : 6em; +  } +  p[indent="h7i2"] { +    padding-left             : 2em; +    text-indent              : 5em; +  } +  p[indent="h7i3"] { +    padding-left             : 3em; +    text-indent              : 4em; +  } +  p[indent="h7i4"] { +    padding-left             : 4em; +    text-indent              : 3em; +  } +  p[indent="h7i5"] { +    padding-left             : 5em; +    text-indent              : 2em; +  } +  p[indent="h7i6"] { +    padding-left             : 6em; +    text-indent              : 1em; +  } +  p[indent="h7i7"] { +    padding-left             : 7em; +    text-indent              : 0em; +  } +  p[indent="h7i8"] { +    padding-left             : 8em; +    text-indent              : -1em; +  } +  p[indent="h7i9"] { +    padding-left             : 9em; +    text-indent              : -2em; +  } +  p[indent="h8i0"] { +    padding-left             : 0em; +    text-indent              : 8em; +  } +  p[indent="h8i1"] { +    padding-left             : 1em; +    text-indent              : 7em; +  } +  p[indent="h8i2"] { +    padding-left             : 2em; +    text-indent              : 6em; +  } +  p[indent="h8i3"] { +    padding-left             : 3em; +    text-indent              : 5em; +  } +  p[indent="h8i4"] { +    padding-left             : 4em; +    text-indent              : 4em; +  } +  p[indent="h8i5"] { +    padding-left             : 5em; +    text-indent              : 3em; +  } +  p[indent="h8i6"] { +    padding-left             : 6em; +    text-indent              : 2em; +  } +  p[indent="h8i7"] { +    padding-left             : 7em; +    text-indent              : 1em; +  } +  p[indent="h8i8"] { +    padding-left             : 8em; +    text-indent              : 0em; +  } +  p[indent="h8i9"] { +    padding-left             : 9em; +    text-indent              : -1em; +  } +  p[indent="h9i0"] { +    padding-left             : 0em; +    text-indent              : 9em; +  } +  p[indent="h9i1"] { +    padding-left             : 1em; +    text-indent              : 8em; +  } +  p[indent="h9i2"] { +    padding-left             : 2em; +    text-indent              : 7em; +  } +  p[indent="h9i3"] { +    padding-left             : 3em; +    text-indent              : 6em; +  } +  p[indent="h9i4"] { +    padding-left             : 4em; +    text-indent              : 5em; +  } +  p[indent="h9i5"] { +    padding-left             : 5em; +    text-indent              : 4em; +  } +  p[indent="h9i6"] { +    padding-left             : 6em; +    text-indent              : 3em; +  } +  p[indent="h9i7"] { +    padding-left             : 7em; +    text-indent              : 2em; +  } +  p[indent="h9i8"] { +    padding-left             : 8em; +    text-indent              : 1em; +  } +  p[indent="h9i9"] { +    padding-left             : 9em; +    text-indent              : 0em; +  } +  p.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                : 80%%%%; +    display                  : inline; +  } +  p.endnote { +    font-size                : 96%%%%; +    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; +  } +  p.small { +    font-size                : 80%%%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  .tiny, .tiny_left, .tiny_right, .tiny_center { +    font-size                : 10px; +    margin-top               : 0px; +    margin-bottom            : 0px; +    color                    : #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.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; +  } +  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                : 95%%%%; +    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; +  } +  note { white-space         : pre; } +  em { +    font-weight              : bold; +    font-style               : italic; +  } +  p.left,th.left,td.left { +    text-align               : left; +  } +  p.small_left,th.small_left,td.small_left { +    text-align               : left; +    font-size                : 80%%%%; +  } +  p.right,th.right,td.right { +    text-align               : right; +  } +  ul, li { +    list-style-type          : none; +    list-style               : none; +    padding-left             : 20px; +    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             : 125%%%%; } +  h1 { font-size             : 120%%%%; } +  h2 { font-size             : 115%%%%; } +  h3 { font-size             : 110%%%%; } +  h4 { font-size             : 105%%%%; } +  h5 { font-size             : 100%%%%; } +  h6 { font-size             : 100%%%%; } +  h7 { font-size             : 100%%%%; } +  h0, h1, h2, h3, h4, h5, h6, h7 { +    text-shadow              : .2em .2em .3em #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                : 120%%%%; +    line-height              : 150%%%%; +  } +  h1.toc { +    margin-left              : 1em; +    font-size                : 115%%%%; +    line-height              : 150%%%%; +  } +  h2.toc { +    margin-left              : 2em; +    font-size                : 110%%%%; +    line-height              : 140%%%%; +  } +  h3.toc { +    margin-left              : 3em; +    font-size                : 105%%%%; +    line-height              : 120%%%%; +  } +  h4.toc { +    margin-left              : 4em; +    font-size                : 100%%%%; +    line-height              : 120%%%%; +  } +  h5.toc { +    margin-left              : 5em; +    font-size                : 95%%%%; +    line-height              : 110%%%%; +  } +  h6.toc { +    margin-left              : 6em; +    font-size                : 90%%%%; +    line-height              : 110%%%%; +  } +  h7.toc { +    margin-left              : 7em; +    font-size                : 85%%%%; +    line-height              : 100%%%%; +  } +  .subtoc { +    margin-right             : 34%%%%; +    font-weight              : normal; +  } +  h5.subtoc { +    margin-left              : 2em; +    font-size                : 80%%%%; +    margin-top               : 2px; +    margin-bottom            : 2px; +  } +  h6.subtoc { +    margin-left              : 3em; +    font-size                : 75%%%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +  } +  h7.subtoc { +    margin-left              : 4em; +    font-size                : 70%%%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +  } +  hr { +    display                  : block; +    height                   : 1px; +    width                    : 100%%%%; +    border                   : 0; +    border-top               : 1px solid #AAAAAA; +    border-color             : #AAAAAA +    background-color         : #AAAAAA +    margin-left              : 0%%%%; +    margin-right             : 0em; +    margin-top               : 0.5em; +    margin-bottom            : 0.5em; +    padding                  : 0; +  } +</style> +</head> +<body lang="en" xml:lang="en"> +┃", +    conf.http_host, +   ); +  } +  { +    table = format(q"┃ +<table summary="band" border="0" cellpadding="2" cellspacing="0"> +<tr><td width="20%%%%"> + <table summary="home button / home information" border="0" cellpadding="2" cellspacing="0"> + <tr><td align="left"> +  %s + </td></tr> + </table> +</td> +<td> +</td></tr> +</table> +┃"); +  } +  { +    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 = +            "<font size=\"2\" color=\"#666666\">" +            ~ "POST: " +            ~ "<a href=\"" +            ~ method_post_url_construct +            ~ "\">" +            ~ method_post_url_construct +            ~ "</a></font>" +            ~ "<br>"; +        } else if (conf.request_method == "GET") { +          _the_can = +            "<font size=\"2\" color=\"#666666\">" +            ~ "GET:  " +            ~ "<a href=\"" +            ~ method_get_url +            ~ "\">" +            ~ method_get_url +            ~ "</a></font>"; +        } +        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"┃ +<font size="2" color="#666666"> +<b>database:</b> <font size="2" color="#004000">%%s</font>; <b>selected view:</b> <font size="2" color="#004000">index</font> +<b>search string:</b> %%s %%s %%s %%s %%s %%s<br> +%%s %%s %%s %%s %%s %%s +</font> +┃", +          cv.db_selected, +          (tf.text.empty   ? "" : "\"text:   <font size=\"2\" color=\"#004000\">" ~ tf.text   ~ "</font>; "), +          (tf.title.empty  ? "" : "\"title:  <font size=\"2\" color=\"#004000\">" ~ tf.title  ~ "</font>; "), +          (tf.author.empty ? "" : "\"author: <font size=\"2\" color=\"#004000\">" ~ tf.author ~ "</font>; "), +          (tf.date.empty   ? "" : "\"date    <font size=\"2\" color=\"#004000\">" ~ tf.date   ~ "</font>; "), +          (tf.uid.empty    ? "" : "\"uid:    <font size=\"2\" color=\"#004000\">" ~ tf.uid    ~ "</font>; "), +          (tf.fn.empty     ? "" : "\"fn:     <font size=\"2\" color=\"#004000\">" ~ tf.fn     ~ "</font>; "), +          (tf.text.empty   ? "" :  "text:    <font size=\"2\" color=\"#004000\">" ~ tf.text   ~ "</font><br>"), +          (tf.title.empty  ? "" : "title:    <font size=\"2\" color=\"#004000\">" ~ tf.title  ~ "</font><br>"), +          (tf.author.empty ? "" :  "author:  <font size=\"2\" color=\"#004000\">" ~ tf.author ~ "</font><br>"), +          (tf.date.empty   ? "" :  "date:    <font size=\"2\" color=\"#004000\">" ~ tf.date   ~ "</font><br>"), +          (tf.uid.empty    ? "" : "\"uid:    <font size=\"2\" color=\"#004000\">" ~ tf.uid    ~ "</font>; "), +          (tf.fn.empty     ? "" : "\"fn:     <font size=\"2\" color=\"#004000\">" ~ tf.fn     ~ "</font>; "), +        ); +      } +      return tip; +    } +    form = format(q"┃ +<form action="%%s" id="SubmitForm" method="post" accept-charset="UTF-8"> +  <table cellpadding="2"> +  <tr><td valign=\"top\"> +      <textarea id="find" name="sf" type="text" rows="6" cols="40" maxlength="256" wrap="virtual">%%s</textarea> +  </td> +  <td valign=\"top\"> +    %%s +    %%s +    %%s +  </td></tr></table> +  <td valign=\"top\"><tr><td> +    <font size="2" color="#%s"> +    <input type="hidden" name="db" value="%%s"> +    <input type="submit" value="SiSU search"> +    <input type="radio" name="rt" id="results_type_index" value="idx" %%s> index +    <input type="radio" name="rt" id="results_type_text" value="txt" %%s> text / grep; +    match limit: +    <input type="radio" name="sml" id="sql_match_limit_1000" value="1000" %%s> 1,000 +    <input type="radio" name="sml" id="sql_match_limit_2500" value="2500" %%s> 2,500 +    <br> +      <input type="checkbox" name="ec" %%s> echo query +      <input type="checkbox" name="url" %%s> search url +      <input type="checkbox" name="se" %%s> searched +      <input type="checkbox" name="sql" %%s> sql statement +      <input type="hidden" name="smo" value="0"> +    <br> +    </font> +  </td></tr> +  </table> +</form> +┃", +      "%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 ~ "<br>"); +      // } +    } +    { // debug cgi info +      // cgi.write("db_selected: "         ~ cv.db_selected ~ "<br>\n"); +      // cgi.write("search_text: "         ~ cv.search_text ~ "<br>\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 ~ "<br>\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") ~ ";<br>\n"); +      // cgi.write("cv.checked_tip: "      ~ (cv.checked_tip ? "checked" : "off") ~ "; \n"); +      // cgi.write("cv.checked_sql: "      ~ (cv.checked_sql ? "checked" : "off") ~ "<br>\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 = "<span class=\"match\">"; +        string _span_close  = "</span>"; +        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"<a href=[^>]+?>"); +        foreach (_sf; _sf_arr) { +          auto rgx_matched_text = regex(_sf, "i"); +          auto rgx_marked_pair  = regex(r"┤(?P<keep>" ~ _sf ~ ")├", "i"); +          if (auto m = _txt.matchFirst(rgx_url)) { +            _txt = replaceAll!(m => +                _mark_open +                ~  m.captures[0] +                ~ _mark_close +              )(_txt, rgx_matched_text); +            _txt = replaceAll!(m => +                replaceAll!(u => +                  u["keep"] +                )(m.hit, rgx_marked_pair) +              )(_txt, rgx_url); +            _txt = replaceAll!(m => +                _span_match +                ~  m["keep"] +                ~ _span_close +              )(_txt, rgx_marked_pair); +          } else { +            _txt = replaceAll!(m => +                _span_match +                ~  m.captures[0] +                ~ _span_close +              )(_txt, rgx_matched_text); +          } +        } +        return _txt; +      } +      string select_field_like(string db_field, string search_field) { +        string where_ = ""; +        if (!(search_field.empty)) { +          string _sf = search_field.strip.split("%%20").join(" "); +          if (_sf.match(r" OR ")) { +            _sf = _sf.split(" OR ").join("%%' OR " ~ db_field ~ " LIKE '%%"); +          } +          if (_sf.match(r" AND ")) { +            _sf = _sf.split(" AND ").join("%%' AND " ~ db_field ~ " LIKE '%%"); +          } +          _sf = "( " ~ db_field ~ " LIKE\n  '%%" ~ _sf ~ "%%' )"; +          where_ ~= format(q"┃ +  %%s +┃", +            _sf +          ); +        } +        return where_; +      } +      string[] _fields; +      _fields ~= select_field_like("doc_objects.clean",                         tf.text); +      _fields ~= select_field_like("metadata_and_text.title",                   tf.title); +      _fields ~= select_field_like("metadata_and_text.creator_author",          tf.author); +      _fields ~= select_field_like("metadata_and_text.uid",                     tf.uid); +      _fields ~= select_field_like("metadata_and_text.src_filename_base",       tf.fn); +      _fields ~= select_field_like("metadata_and_text.src_filename_base",       tf.src_filename_base); +      _fields ~= select_field_like("metadata_and_text.language_document_char",  tf.language); +      _fields ~= select_field_like("metadata_and_text.date_published",          tf.date); +      _fields ~= select_field_like("metadata_and_text.classify_keywords",       tf.keywords); +      _fields ~= select_field_like("metadata_and_text.classify_topic_register", tf.topic_register); +      string[] fields; +      foreach (f; _fields) { +        if (!(f.empty)) { fields ~= f; } +      } +      string fields_str = ""; +      fields_str ~= fields.join(" AND "); +      sql_select.the_body ~= format(q"┃ +SELECT +  metadata_and_text.uid, +  metadata_and_text.title, +  metadata_and_text.creator_author_last_first, +  metadata_and_text.creator_author, +  metadata_and_text.src_filename_base, +  metadata_and_text.language_document_char, +  metadata_and_text.date_published, +  metadata_and_text.classify_keywords, +  metadata_and_text.classify_topic_register, +  doc_objects.body, +  doc_objects.seg_name, +  doc_objects.ocn, +  metadata_and_text.uid +FROM +  doc_objects, +  metadata_and_text +WHERE ( +  %%s +  ) +AND +  doc_objects.uid_metadata_and_text = metadata_and_text.uid +ORDER BY +  metadata_and_text.creator_author_last_first, +  metadata_and_text.date_published DESC, +  metadata_and_text.title, +  metadata_and_text.language_document_char, +  metadata_and_text.src_filename_base, +  doc_objects.ocn +LIMIT %%s OFFSET %%s +;┃", +        fields_str, +        cv.sql_match_limit, +        cv.sql_match_offset, +      ); +      (cv.checked_sql) +      ? cgi.write(previous_next +          ~ "<hr><font size=\"2\" color=\"#666666\">" +          ~ sql_select.the_body.strip.split("\n  ").join(" ").split("\n").join("<br>") +          ~ "</font>\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) ? "" : "</p>"; +            _matched_ocn_open = (idx == 1) ? "" : "<p class=\"matched_ocn\">"; +            _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 +              ~ "<hr><div class=\"publication\">" +                ~ "<p class=\"publication\"><a href=\"" +                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" +                  ~ row["language_document_char"].as!string ~ "/html/" +                  ~ row["src_filename_base"].as!string ~ "/" +                  ~ "toc.html" +                ~ "\">\"" +                  ~ row["title"].as!string ~ "\"" +                ~ "</a> " +                ~ _date +                ~ "[" ~ row["language_document_char"].as!string ~ "] " +                ~ row["creator_author_last_first"].as!string +                ~ " " +                ~ show_matched_objects(row["src_filename_base"].as!string) +                ~ "</p>" +              ~ "</div>" +            ); +          } +          if (cv.results_type == "txt") { +            if (row["ocn"].as!string != "0") { +              cgi.write( +                "<div class=\"flex-container\">" +                ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">" +                  ~ "<p class=\"ocn_is\"><a href=\"" +                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" +                    ~ row["language_document_char"].as!string ~ "/html/" +                    ~ row["src_filename_base"].as!string ~ "/" +                    ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string +                  ~ "\">" +                    ~ row["ocn"].as!string +                  ~ "</a>:</p>" +                ~ "</div>" +                ~ "<div class=\"textview_found\">" +                  ~ highlight_text_matched(row["body"].as!string, tf.text) +                ~ "</div>" +                ~ "</div>" +              ); +            } else { +              cgi.write( +                "<div class=\"flex-container\">" +                ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">" +                  ~ "<p class=\"ocn_is\"><a href=\"" +                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" +                    ~ row["language_document_char"].as!string ~ "/html/" +                    ~ row["src_filename_base"].as!string ~ "/toc.html" +                  ~ "\">" +                    ~ row["ocn"].as!string +                  ~ "</a>:</p>" +                ~ "</div>" +                ~ "<div class=\"textview_found\">" +                  ~ highlight_text_matched(row["body"].as!string, tf.text) +                ~ "</div>" +                ~ "</div>" +              ); +            } +          } else { +            if (row["ocn"].as!string != "0") { +              cgi.write( +                _matched_ocn_open +                ~ "<a href=\"" +                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" +                  ~ row["language_document_char"].as!string ~ "/html/" +                  ~ row["src_filename_base"].as!string ~ "/" +                  ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string +                ~ "\">" +                  ~ row["ocn"].as!string +                ~ "</a>, " +              ); +            } else { +              cgi.write( +                _matched_ocn_open +                ~ "<a href=\"" +                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" +                  ~ row["language_document_char"].as!string ~ "/html/" +                  ~ row["src_filename_base"].as!string ~ "/toc.html" +                ~ "\">" +                  ~ row["ocn"].as!string +                ~ "</a>, " +              ); +            } +            _matched_ocn_open = ""; +          } +        } +        cgi.write( previous_next); + +      } else { // offset_not_beyond_limit = false; +        cgi.write("select_query_results empty<p>\n"); +      } +      cgi.write("<br><p class=\"center\"><a href=\"https://sisudoc.org/\" target=\"_top\"> +<label for=\"find\"><b>≅ SiSU spine</b></label> +</a> <label for=\"find\">(generated) search form</label> +<br><a href=\"https://git.sisudoc.org/\" target=\"_top\"> +  git</a> +</p> +"); +    } +    sql_search_query; +  } +  { +    db.close; +  } +  { +    string tail = format(q"┃ +</body> +┃"); +    cgi.write(tail); +  } +} +mixin GenericMain!cgi_function_intro; +≓", +  get_doc_collection_subroot(make_and_meta_struct.conf.output_path), +  make_and_meta_struct.conf.output_path ~ "/sqlite/", +  _sqlite_db_fn, +  (opt_action.cgi_search_title.empty) +    ? make_and_meta_struct.conf.w_srv_cgi_search_form_title +    : opt_action.cgi_search_title, +  (opt_action.css_theme_default) ? "FFFFFF" : "000000", +  (opt_action.css_theme_default) ? "000000" : "CCCCCC", +  (opt_action.css_theme_default) ? "FFFFFF" : "000000", +  (opt_action.css_theme_default) ? "FFFFFF" : "000000", +  (opt_action.css_theme_default) ? "003399" : "FFFFFF", +  (opt_action.css_theme_default) ? "003399" : "999999", +  "000000", +  (opt_action.css_theme_default) ? "F9F9AA" : "555555", +  (opt_action.css_theme_default) ? "777777" : "BBBBBB", +  (opt_action.css_theme_default) ? "32CD32" : "9ACD32", +  (opt_action.css_theme_default) ? "777777" : "BBBBBB", +  (opt_action.css_theme_default) ? "FFFFFF" : "000000", +  (opt_action.css_theme_default) ? "003399" : "888888", +  (opt_action.css_theme_default) ? "000000" : "FFFFFF", +  (opt_action.css_theme_default) ? "FFFFFF" : "777777", +  (opt_action.css_theme_default) ? "000000" : "FFFF48", +  (opt_action.css_theme_default) ? "FFFF48" : "777748", +  (opt_action.cgi_search_title.empty) +    ? make_and_meta_struct.conf.w_srv_cgi_search_form_title +    : opt_action.cgi_search_title, +  (opt_action.css_theme_default) ? "222222" : "AAAAAA", +  _cgi_search_script, +  _sqlite_db_fn, +).strip; +    string _cgi_path = (opt_action.output_dir_set.length > 0) +    ? opt_action.output_dir_set +    : (make_and_meta_struct.conf.w_srv_data_root_path.length > 0) +      ? make_and_meta_struct.conf.w_srv_data_root_path +      : ""; +    auto pth_sqlite_cgi = spinePathsSQLiteCGI!()(_cgi_search_script_raw_fn_d, _cgi_search_script, _cgi_path); +    { // cgi-bin search form src d +      try { +        if (!exists(pth_sqlite_cgi.src)) { +          pth_sqlite_cgi.src.mkdirRecurse; +        } +        if (!exists(pth_sqlite_cgi.cgi_bin)) { +          pth_sqlite_cgi.cgi_bin.mkdirRecurse; +        } +        auto f = File(pth_sqlite_cgi.search_form_path_out, "w"); +        f.write(the_cgi_search_form); +        // foreach (o; metadata_) { +        //   f.writeln(o); +        // } +      } catch (ErrnoException ex) { +        // Handle error +      } +      // if (!(opt_action.quiet)) { +      //   writeln(" ", pth_sqlite_cgi.search_form); +      // } +    } +    string the_dub_sdl = format(q"≓ +name "spine_cgi_sqlite_search" +description "spine cgi sqlite search" +authors "Ralph Amissah" +copyright "Copyright © 2022, Ralph Amissah" +license "GPL-3.0+" +dependency "d2sqlite3" version="%s" +dependency "arsd-official:cgi" version="%s" +  subConfiguration "arsd-official:cgi" "cgi" +targetType "executable" +targetPath "./cgi-bin" +mainSourceFile "%s" +configuration "default" { +  targetType "executable" +  targetName "%s" +  postGenerateCommands "notify-send -t 0 'D executable ready' 'spine cgi sqlite search d'" +} +≓", +  "~>0.18.3", // d2sqlite3 dependency version +  "~>7.2.0",  // arsd-official:cgi dependency version +  "src/" ~ _cgi_search_script_raw_fn_d, +  _cgi_search_script +).strip; +    { // dub.sdl +      try { +        auto f = File(pth_sqlite_cgi.dub_sdl_path_out, "w"); +        f.write(the_dub_sdl); +        // foreach (o; metadata_) { +        //   f.writeln(o); +        // } +      } catch (ErrnoException ex) { +        // Handle error +      } +    } +    // { // get cgi.d +    //   // import std.net.curl, std.stdio; +    //   // char[] cgi_d; +    //   // if (opt_action.allow_downloads) { +    //   //   try { +    //   //     cgi_d = get!HTTP("https://raw.githubusercontent.com/adamdruppe/arsd/master/cgi.d"); +    //   //   } catch (ErrnoException ex) { +    //   //     // Handle error +    //   //     // CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError); +    //   //     CurlCode perform(ThrowOnError throwOnError = No.throwOnError); +    //   //   } +    //   //   if (cgi_d && cgi_d.length > 0) { +    //   //     try { +    //   //       auto f = File(pth_sqlite_cgi.cgi_d_path_out, "w"); +    //   //       f.write(cgi_d); +    //   //     } catch (ErrnoException ex) { +    //   //       // Handle error +    //   //     } +    //   //   } +    //   // } +    // } +  } +} diff --git a/src/sisudoc/io_out/create_zip_file.d b/src/sisudoc/io_out/create_zip_file.d new file mode 100644 index 0000000..36863eb --- /dev/null +++ b/src/sisudoc/io_out/create_zip_file.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/] + ++/ +module sisudoc.io_out.create_zip_file; +@safe: +template createZipFile() { +  import +    std.file, +    std.outbuffer, +    std.string, +    std.zip; +  void createZipFile( +    string zip_file_name, +    void[] compressed_zip_data, +  ) { +    try { +      write(zip_file_name, compressed_zip_data); +    } catch (ZipException ex) { +      // Handle Errors +    } +  } +} diff --git a/src/sisudoc/io_out/defaults.d b/src/sisudoc/io_out/defaults.d new file mode 100644 index 0000000..be7c122 --- /dev/null +++ b/src/sisudoc/io_out/defaults.d @@ -0,0 +1,186 @@ +/+ +- 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.io_out.defaults; +@safe: + +template InternalMarkup() { +  import std.array; +  static struct InlineMarkup { +    string en_a_o = "【";      string en_a_c = "】"; +    string en_b_o = "〖";      string en_b_c = "〗"; +    string quote_o = "“";      string quote_c = "”"; +    string ff_i = "⑆";         string ff_o = "┨";         string ff_c = "┣"; // fontface +    string lnk_o = "┥";        string lnk_c = "┝"; +    string url_o = "┤";        string url_c = "├"; +    string emph = "*"; +    string bold = "!"; +    string italic = "/"; +    string underscore = "_"; +    string superscript = "^"; +    string subscript = ","; +    string mono = "■"; +    string cite = "‖"; +    string mark_internal_site_lnk = "¤"; +    string nbsp                   = "░"; +    string br_line                = "┘"; +    string br_line_inline         = "┙"; +    string br_line_spaced         = "┚"; +    string br_obj                 = "break_obj"; +    string br_page_line           = "┼"; +    string br_page                = "┿"; +    string br_page_new            = "╂"; +    string tc_s                   = "┊"; +    string tc_o                   = "┏"; +    string tc_c                   = "┚"; +    string tc_p                   = "┆"; +    string img                    = "☼"; +    string sep                    = "␣"; // "~";"␣"; // "~"; +    string uid_sep                = ":"; +    string on_o  = "「";       string on_c  = "」"; +    string mk_bullet               = "● "; +    static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { +      _indent_spaces = replicate(_indent_spaces, indent); +      return _indent_spaces; +    } +    static string repeat_character_by_number_provided(C,N)(C _character ="-", N number=10) { +      _character = replicate(_character, number); +      return _character; +    } +  } +} +template spineLanguageCodes() { +  /+ language codes +/ +  struct Lang { +    static string[string][string] codes() { +      auto _lang_codes = [ +        "am":    [ "c": "am",    "n": "Amharic",           "t": "Amharic",                   "xlp": "amharic"      ], +        "bg":    [ "c": "bg",    "n": "Bulgarian",         "t": "Български (Bəlgarski)",     "xlp": "bulgarian"    ], +        "bn":    [ "c": "bn",    "n": "Bengali",           "t": "Bengali",                   "xlp": "bengali"      ], +        "br":    [ "c": "br",    "n": "Breton",            "t": "Breton",                    "xlp": "breton"       ], +        "ca":    [ "c": "ca",    "n": "Catalan",           "t": "catalan",                   "xlp": "catalan"      ], +        "cs":    [ "c": "cs",    "n": "Czech",             "t": "česky",                     "xlp": "czech"        ], +        "cy":    [ "c": "cy",    "n": "Welsh",             "t": "Welsh",                     "xlp": "welsh"        ], +        "da":    [ "c": "da",    "n": "Danish",            "t": "dansk",                     "xlp": "danish"       ], +        "de":    [ "c": "de",    "n": "German",            "t": "Deutsch",                   "xlp": "german"       ], +        "el":    [ "c": "el",    "n": "Greek",             "t": "Ελληνικά (Ellinika)",       "xlp": "greek"        ], +        "en":    [ "c": "en",    "n": "English",           "t": "English",                   "xlp": "english"      ], +        "eo":    [ "c": "eo",    "n": "Esperanto",         "t": "Esperanto",                 "xlp": "esperanto"    ], +        "es":    [ "c": "es",    "n": "Spanish",           "t": "español",                   "xlp": "spanish"      ], +        "et":    [ "c": "et",    "n": "Estonian",          "t": "Estonian",                  "xlp": "estonian"     ], +        "eu":    [ "c": "eu",    "n": "Basque",            "t": "basque",                    "xlp": "basque"       ], +        "fi":    [ "c": "fi",    "n": "Finnish",           "t": "suomi",                     "xlp": "finnish"      ], +        "fr":    [ "c": "fr",    "n": "French",            "t": "français",                  "xlp": "french"       ], +        "ga":    [ "c": "ga",    "n": "Irish",             "t": "Irish",                     "xlp": "irish"        ], +        "gl":    [ "c": "gl",    "n": "Galician",          "t": "Galician",                  "xlp": "galician"     ], +        "he":    [ "c": "he",    "n": "Hebrew",            "t": "Hebrew",                    "xlp": "hebrew"       ], +        "hi":    [ "c": "hi",    "n": "Hindi",             "t": "Hindi",                     "xlp": "hindi"        ], +        "hr":    [ "c": "hr",    "n": "Croatian",          "t": "Croatian",                  "xlp": "croatian"     ], +        "hy":    [ "c": "hy",    "n": "Armenian",          "t": "Armenian",                  "xlp": "armenian"     ], +        "ia":    [ "c": "ia",    "n": "Interlingua",       "t": "Interlingua",               "xlp": "interlingua"  ], +        "is":    [ "c": "is",    "n": "Icelandic",         "t": "Icelandic",                 "xlp": "icelandic"    ], +        "it":    [ "c": "it",    "n": "Italian",           "t": "Italiano",                  "xlp": "italian"      ], +        "ja":    [ "c": "ja",    "n": "Japanese",          "t": "日本語 (Nihongo)",         "xlp": "japanese"      ], +        "ko":    [ "c": "ko",    "n": "Korean",            "t": "Korean",                    "xlp": "korean"       ], +        "la":    [ "c": "la",    "n": "Latin",             "t": "Latin",                     "xlp": "latin"        ], +        "lo":    [ "c": "lo",    "n": "Lao",               "t": "Lao",                       "xlp": "lao"          ], +        "lt":    [ "c": "lt",    "n": "Lithuanian",        "t": "Lithuanian",                "xlp": "lithuanian"   ], +        "lv":    [ "c": "lv",    "n": "Latvian",           "t": "Latvian",                   "xlp": "latvian"      ], +        "ml":    [ "c": "ml",    "n": "Malayalam",         "t": "Malayalam",                 "xlp": "malayalam"    ], +        "mr":    [ "c": "mr",    "n": "Marathi",           "t": "Marathi",                   "xlp": "marathi"      ], +        "nl":    [ "c": "nl",    "n": "Dutch",             "t": "Nederlands",                "xlp": "dutch"        ], +        "no":    [ "c": "no",    "n": "Norwegian",         "t": "norsk",                     "xlp": "norsk"        ], +        "nn":    [ "c": "nn",    "n": "Norwegian Nynorsk", "t": "nynorsk",                   "xlp": "nynorsk"      ], +        "oc":    [ "c": "oc",    "n": "Occitan",           "t": "Occitan",                   "xlp": "occitan"      ], +        "pl":    [ "c": "pl",    "n": "Polish",            "t": "polski",                    "xlp": "polish"       ], +        "pt":    [ "c": "pt",    "n": "Portuguese",        "t": "Português",                 "xlp": "portuges"     ], +        "pt_BR": [ "c": "pt_BR", "n": "Portuguese Brazil", "t": "Brazilian Português",       "xlp": "brazilian"    ], +        "ro":    [ "c": "ro",    "n": "Romanian",          "t": "română",                    "xlp": "romanian"     ], +        "ru":    [ "c": "ru",    "n": "Russian",           "t": "Русский (Russkij)",         "xlp": "russian"      ], +        "sa":    [ "c": "sa",    "n": "Sanskrit",          "t": "Sanskrit",                  "xlp": "sanskrit"     ], +        "se":    [ "c": "se",    "n": "Sami",              "t": "Samin",                     "xlp": "samin"        ], +        "sk":    [ "c": "sk",    "n": "Slovak",            "t": "slovensky",                 "xlp": "slovak"       ], +        "sl":    [ "c": "sl",    "n": "Slovenian",         "t": "Slovenian",                 "xlp": "slovenian"    ], +        "sq":    [ "c": "sq",    "n": "Albanian",          "t": "Albanian",                  "xlp": "albanian"     ], +        "sr":    [ "c": "sr",    "n": "Serbian",           "t": "Serbian",                   "xlp": "serbian"      ], +        "sv":    [ "c": "sv",    "n": "Swedish",           "t": "svenska",                   "xlp": "swedish"      ], +        "ta":    [ "c": "ta",    "n": "Tamil",             "t": "Tamil",                     "xlp": "tamil"        ], +        "te":    [ "c": "te",    "n": "Telugu",            "t": "Telugu",                    "xlp": "telugu"       ], +        "th":    [ "c": "th",    "n": "Thai",              "t": "Thai",                      "xlp": "thai"         ], +        "tk":    [ "c": "tk",    "n": "Turkmen",           "t": "Turkmen",                   "xlp": "turkmen"      ], +        "tr":    [ "c": "tr",    "n": "Turkish",           "t": "Türkçe",                    "xlp": "turkish"      ], +        "uk":    [ "c": "uk",    "n": "Ukranian",          "t": "українська (ukrajins\"ka)", "xlp": "ukrainian"    ], +        "ur":    [ "c": "ur",    "n": "Urdu",              "t": "Urdu",                      "xlp": "urdu"         ], +        "us":    [ "c": "en",    "n": "English (American)","t": "English",                   "xlp": "english"      ], +        "vi":    [ "c": "vi",    "n": "Vietnamese",        "t": "Vietnamese",                "xlp": "vietnamese"   ], +        "zh":    [ "c": "zh",    "n": "Chinese",           "t": "中文",                     "xlp": "chinese"       ], +        "en":    [ "c": "en",    "n": "English",           "t": "English",                   "xlp": "english"      ], +        "xx":    [ "c": "xx",    "n": "Default",           "t": "English",                   "xlp": "english"      ], +      ]; +      return _lang_codes; +    } +    static string[] code_arr_ptr() { +      string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; +      return _lang_codes; +    } +    static string[] code_arr() { +      string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; +      return _lang_codes; +    } +    static auto codes_() { +      return "(" ~ join(code_arr,"|") ~ ")"; +    } +    static auto codes_regex() { +      return regex(codes_); +    } +  } +} diff --git a/src/sisudoc/io_out/epub3.d b/src/sisudoc/io_out/epub3.d new file mode 100644 index 0000000..b4ff21b --- /dev/null +++ b/src/sisudoc/io_out/epub3.d @@ -0,0 +1,810 @@ +/+ +- 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.epub3; +@safe: +template outputEPub3() { +  import +    std.file, +    std.outbuffer, +    std.uri, +    std.zip, +    std.conv : to; +  import +    sisudoc.io_out, +    sisudoc.io_out.rgx, +    sisudoc.io_out.rgx_xhtml, +    sisudoc.io_out.create_zip_file, +    sisudoc.io_out.xmls, +    sisudoc.io_out.xmls_css; +  mixin InternalMarkup; +  mixin outputXHTMLs; +  static auto rgx = RgxO(); +  static auto rgx_xhtml = RgxXHTML(); +  string special_characters_text(string _txt) { +    _txt = _txt +      .replaceAll(rgx_xhtml.ampersand,    "&")  // "&" +      .replaceAll(rgx_xhtml.quotation,    """) // """ +      .replaceAll(rgx_xhtml.less_than,    "<")   // "<" +      .replaceAll(rgx_xhtml.greater_than, ">")   // ">" +      .replaceAll(rgx.br_line,            "<br />") +      .replaceAll(rgx.br_line_inline,     "<br />") +      .replaceAll(rgx.br_line_spaced,     "<br />\n<br />") +      .replaceAll(rgx.nbsp_char,          " "); +    return _txt; +  } +  string epub3_mimetypes() { +    string o; +    o = format(q"┃application/epub+zip┃") ~ "\n"; +    return o; +  } +  string epub3_container_xml() { +    string o; +    o = format(q"┃<?xml version="1.0" encoding="utf-8"?>┃") ~ "\n"; +    o ~= format(q"┃<container version="1.0" +  xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> +  <rootfiles> +    <rootfile full-path="OEBPS/content.opf" +      media-type="application/oebps-package+xml" /> +  </rootfiles>┃") ~ "\n</container>\n"; +    return o; +  } +  string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { +    auto xhtml_format = outputXHTMLs(); +    auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); +    string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! +    string content = format(q"┃<?xml version="1.0" encoding="utf-8"?> +  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" prefix="rendition: http://www.idpf.org/vocab/rendition/#"> +    <metadata +      xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" +      xmlns:dcterms="https://purl.org/dc/terms/" +      xmlns:dc="https://purl.org/dc/elements/1.1/" +      unique-identifier="urn:uuid:%s" version="2.0"> +      <dc:title id="title">%s</dc:title> +      <meta refines="#title" property="title-type">main</meta> +      <dc:title id="subtitle">%s</dc:title> +      <meta refines="#subtitle" property="title-type">subtitle</meta> +      <dc:creator file-as="%s" id="aut">%s</dc:creator> +      <dc:language>%s</dc:language> +      <dc:date id="published">%s</dc:date> +      <dc:rights>Copyright: %s</dc:rights> +      <dc:identifier scheme="URI">%s</dc:identifier> +      <dc:identifier id="bookid">urn:uuid:%s</dc:identifier> +    </metadata> +    <manifest> +      <item id="css" href="%s" media-type="text/css"/> +      <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> +  ┃", +      _uuid, +      xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_main), +      (doc_matters.conf_make_meta.meta.title_sub.empty) +        ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_sub), +      (doc_matters.conf_make_meta.meta.creator_author.empty) +        ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), +      (doc_matters.conf_make_meta.meta.creator_author.empty) +        ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), +      doc_matters.src.language,                                   // language, fix (needed in dochead metadata) +      (doc_matters.conf_make_meta.meta.date_published.empty) +        ? "" : xhtml_format.special_characters_date(doc_matters.conf_make_meta.meta.date_published), +      (doc_matters.conf_make_meta.meta.rights_copyright.empty) +        ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), +      _uuid, +      _uuid, +      (pth_epub3.fn_oebps_css).chompPrefix("OEBPS/"), +    ); +    content ~= parts["manifest_documents"]; +    // TODO sort jpg & png +    foreach (image; doc_matters.srcs.image_list) { +      content ~= format(q"┃      <item id="%s" href="%s/%s" media-type="image/%s" /> +  ┃", +        image.baseName.stripExtension, +        (pth_epub3.doc_oebps_image).chompPrefix("OEBPS/"), +        image, +        image.extension.chompPrefix("."), +      ); +    } +    content ~= "  " ~ "</manifest>"         ~ "\n  "; +    content ~= "  " ~ "<spine>"             ~ "\n  "; +    content ~= parts["spine"]; +    content ~= "  " ~ "</spine>"            ~ "\n  "; +    content ~= "  " ~ "<guide>"             ~ "\n  "; +    content ~= parts["guide"]; +    content ~= "  " ~ "</guide>"            ~ "\n  "; +    content ~= ""   ~ "</package>"; +    debug(epubmanifest) { +      foreach (section; doc_matters.has.keys_seq.seg) { // TODO +        foreach (obj; doc_abstraction[section]) { +          if (obj.metainfo.is_a == "heading") { +            if (obj.metainfo.heading_lev_markup == 4) { +              writefln( +                "%s~ [%s.xhtml] %s", +                obj.marked_up_level, +                obj.tags.segment_anchor_tag_epub, +                obj.text +              ); +            } else if (obj.metainfo.heading_lev_markup > 4) { +              writefln( +                "%s~ [%s.xhtml#%s] %s", +                obj.marked_up_level, +                obj.tags.segment_anchor_tag_epub, +                obj.metainfo.object_number, +                obj.text +              ); +            } +          } +        } +      } +    } +    return content; +  } +  string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { +    enum DomTags { none, open, close, close_and_open, open_still, } +    auto markup = InlineMarkup(); +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    string toc; +    bool _new_title_set = false; +    string toc_head = format(q"┃<html xmlns="https://www.w3.org/1999/xhtml" +      xmlns:epub="http://www.idpf.org/2007/ops"> +  <head> +    <title>%s</title> +  </head> +  <body> +  <section epub:type="frontmatter toc"> +    <header> +      <h1>Contents</h1> +    </header> +    <nav epub:type="toc" id="toc"> +  ┃", +            (doc_matters.conf_make_meta.meta.title_full).special_characters_text, +          ); +    string _toc_nav_tail = ""; +    // writeln(doc_matters.has.keys_seq.seg); // DEBUG line +    foreach (sect; doc_matters.has.keys_seq.seg) { +      foreach (obj; doc_abstraction[sect]) { +        if ((sect == "head") && (obj.metainfo.is_a == "heading")) { +          toc = toc_head; +        } +        if (sect == "tail") { // skip +        } else if ((sect != "tail") && (obj.metainfo.is_a == "heading")) { +          string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; +          foreach_reverse (n; 0 .. 7) { +            string k = n.to!string; +            switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { +            case DomTags.none : +              break; +            case DomTags.close : +              toc ~= markup.indent_by_spaces_provided((n + 1), "    ") ~ "</li>" ~ "\n"; +              toc ~= markup.indent_by_spaces_provided(n, "    ") ~ "</ol>" ~ "\n"; +              break; +            case DomTags.close_and_open : +              toc ~= markup.indent_by_spaces_provided((n + 1), "    ") ~ "</li>" ~ "\n"; +              goto default; +            case DomTags.open : +              if (!(_new_title_set)) { +                toc ~= markup.indent_by_spaces_provided(n, "    ") ~ "<ol>" ~ "\n"; +              } +              goto default; +            default : +              if ((obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.close_and_open || +                   obj.metainfo.dom_structure_collapsed_tags_status[n] == DomTags.open +              )) { +                if ((sect == "head") && (obj.metainfo.is_a == "heading")) { +                  toc ~= format(q"┃      <li> +        <a href="_the_title.xhtml">%s</a> +      </li>┃", +                    obj.text +                      .replaceAll(rgx.inline_notes_al_gen, "") +                      .replaceAll(rgx.br_line_inline, "<br />") +                      .strip, +                  ); +                  toc ~= "\n"; +                  _new_title_set = true; +                } else { +                  _new_title_set = false; +                  string _hashtag = ""; +                  if ((obj.metainfo.heading_lev_markup <= 4) && (obj.metainfo.ocn == 0)) { +                    _hashtag = "#" ~ obj.metainfo.ocn.to!string; +                  } +                  string _href = "<a href=\"" +                    ~ obj.tags.segment_anchor_tag_epub ~ ".xhtml" +                    ~ _hashtag +                    ~ "\">"; +                  toc ~= markup.indent_by_spaces_provided((n + 1), "    ") ~ "<li>" ~ "\n" +                  ~ markup.indent_by_spaces_provided((n + 2), "    ") +                  ~ _href ~ _txt.special_characters_text ~ "</a>" ~ "\n"; +                } +              } +              break; +            } +            if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) { +              // writeln(n, ": ", sect, ": ", _txt, " - ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG +              // read last heading (heading prior to closing) and determine what those instructions imply still need to be done +              // CLOSE // DomTags { 0 none, 1 open, 2 close, 3 close_and_open, 4 open_still, } +              if (n == 6) {_toc_nav_tail = "";} +              switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { +              case 0: case 2: +              // case DomTags.none: case DomTags.close: +                break; +              case 1: case 3: case 4: +              // case DomTags.open: case DomTags.close_and_open: case DomTags.open_still: +                if (n != 0) { +                  _toc_nav_tail ~= "   " ~ markup.indent_by_spaces_provided((n + 1), "  ") ~ "</li>" ~ "\n"; +                  _toc_nav_tail ~= "   " ~ markup.indent_by_spaces_provided(n, "  ") ~ "</ol>" ~ "\n"; +                } +                break; +              default : +                break; +              } +              if (n == 0) { +                _toc_nav_tail ~="  </nav> +  </section> +  </body> +  </html>\n"; +              } +            } +          } +        } +      } +    } +    toc ~= _toc_nav_tail; +    return toc; +  } +  @system void outputEPub3(D,I)( +    const D    doc_abstraction, +          I    doc_matters, +  ) { +    mixin spineRgxOut; +    mixin spineRgxXHTML; +    auto xhtml_format = outputXHTMLs(); +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    string[] doc; +    string segment_filename; +    string[] top_level_headings = ["","","",""]; +    string[string] oepbs_content_parts; +    string suffix = ".xhtml"; +    struct writeOut { /+ epub specific documents +/ +      /+ fixed output +/ +      string mimetypes; +      string meta_inf_container_xml; +      string oebps_toc_nav_xhtml; +      /+ variable output +/ +      string oebps_content_opf; +      string[][string] doc_epub3; +      string[][string] doc_epub3_endnotes; +      string[] doc_parts; +    } +    auto epubWrite = writeOut(); +    foreach (section; doc_matters.has.keys_seq.seg) { +      foreach (obj; doc_abstraction[section]) { +        string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); +        if (obj.metainfo.is_a == "heading") { +          assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          switch (obj.metainfo.heading_lev_markup) { +          case 0: .. case 3: +            /+ fill buffer, and replace with new levels from 1 to 3 +/ +            switch (obj.metainfo.heading_lev_markup) { +            case 0: +              top_level_headings[0] = ""; +              top_level_headings[1] = ""; +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 1: +              top_level_headings[1] = ""; +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 2: +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 3: +              top_level_headings[3] = ""; +              goto default; +            default: +              epubWrite.doc_parts ~= obj.tags.segment_anchor_tag_epub; +              epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc_matters); +              Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); +              epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= t[0]; +              epubWrite.doc_epub3_endnotes[obj.tags.segment_anchor_tag_epub] ~= t[1]; +              break; +            } +            break; +          case 4: +            segment_filename = obj.tags.segment_anchor_tag_epub; +            epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters); +            Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); +            epubWrite.doc_epub3[segment_filename] ~= t[0]; +            epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +            break; +          case 5: .. case 7: +            Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub"); +            epubWrite.doc_epub3[segment_filename] ~= t[0]; +            epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +            break; +          case 8: .. case 9: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_epub) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); +                writeln(__FILE__, ":", __LINE__, ": ", obj.text); +              } +            } +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_epub) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); +              } +            } +            break; +          } +        } else { +          assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          Tuple!(string, string[]) t; +          switch (obj.metainfo.is_of_part) { +          case "frontmatter":             assert(section == "head" || "toc"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "toc": +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_epub) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_epub) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +                } +              } +              break; +            } +            break; +          case "body":                    assert(section == "body"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "para": +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_epub) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            case "block": +              switch (obj.metainfo.is_a) { +              case "quote": +                t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "group": +                t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "block": +                t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "poem": +                break; +              case "verse": +                t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0].to!string; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "code": +                epubWrite.doc_epub3[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters); +                break; +              case "table": +                epubWrite.doc_epub3[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters); +                epubWrite.doc_epub3_endnotes[segment_filename] ~= ""; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_epub) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_epub) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +                } +              } +              break; +            } +            break; +          case "backmatter": +            assert(section == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "endnote":             assert(section == "endnotes"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                break; +              case "glossary":            assert(section == "glossary"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "bibliography":        assert(section == "bibliography"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "bookindex":           assert(section == "bookindex"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "blurb":               assert(section == "blurb"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              case "tail":                assert(section == "tail"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub"); +                epubWrite.doc_epub3[segment_filename] ~= t[0]; +                epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1]; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_epub) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_epub) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +                } +              } +              break; +            } +            break; +          case "comment": +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_epub) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); +              } +            } +            break; +          } +        } +        if (obj.metainfo.is_a == "heading") { +          // assert(obj.text.length > 0); // check assertion +          if (obj.metainfo.heading_lev_markup <= 4) { +            oepbs_content_parts["manifest_documents"] ~= +              format(q"┃<item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +              obj.tags.segment_anchor_tag_epub, +            ); +            oepbs_content_parts["spine"] ~= +              format(q"┃<itemref idref="%s.xhtml" linear="yes" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +            ); +            oepbs_content_parts["guide"] ~= +              format(q"┃<reference type="%s" href="%s" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +              obj.tags.segment_anchor_tag_epub, +            ); +          } else if (obj.metainfo.heading_lev_markup > 4) { +            oepbs_content_parts["manifest_documents"] ~= +              format(q"┃<item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +              obj.metainfo.object_number, +              obj.tags.segment_anchor_tag_epub, +              obj.metainfo.object_number, +            ); +            oepbs_content_parts["spine"] ~= +              format(q"┃<itemref idref="%s.xhtml#%s" linear="yes" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +              obj.metainfo.object_number, +            ); +            oepbs_content_parts["guide"] ~= +              format(q"┃<reference type="%s#%s" href="%s#%s" /> +              ┃", +              obj.tags.segment_anchor_tag_epub, +              obj.metainfo.object_number, +              obj.tags.segment_anchor_tag_epub, +              obj.metainfo.object_number, +            ); +          } +        } +      } +    } +    /+ epub specific documents +/ +    epubWrite.mimetypes              = epub3_mimetypes; +    epubWrite.meta_inf_container_xml = epub3_container_xml; +    epubWrite.oebps_toc_nav_xhtml    = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters); +    epubWrite.oebps_content_opf      = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts); +    epubWrite.epub3_write_output_files(doc_matters); +  } +  @system void epub3_write_output_files(W,M)( +    W epub_write, +    M doc_matters, +  ) { +    debug(asserts) { +      static assert(is(typeof(epub_write.doc_epub3)              == string[][string])); +      static assert(is(typeof(epub_write.mimetypes)              == string)); +      static assert(is(typeof(epub_write.meta_inf_container_xml) == string)); +      static assert(is(typeof(epub_write.oebps_toc_nav_xhtml)    == string)); +      static assert(is(typeof(epub_write.oebps_content_opf)      == string)); +    } +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); +    auto xhtml_format = outputXHTMLs(); +    /+ zip file +/ +    auto fn_epub = pth_epub3.epub_file(doc_matters.src.filename); +    auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive(); +    /+ zip archive member files +/ +    void EPUBzip()(string contents, string fn) { +      auto zip_arc_member_file = new ArchiveMember(); +      zip_arc_member_file.name = fn; +      auto zip_data = new OutBuffer(); +      (doc_matters.opt.action.debug_do_epub) +      ? zip_data.write(contents.dup) +      : zip_data.write(contents.dup +        .replaceAll(rgx.spaces_line_start, "") +        .replaceAll(rgx.newline, " ") +        .strip +      ); +      zip_arc_member_file.expandedData = zip_data.toBytes(); +      zip.addMember(zip_arc_member_file); +      createZipFile!()(fn_epub, zip.build()); +    } +    try { +      if (!exists(pth_epub3.base)) { +        pth_epub3.base.mkdirRecurse; +      } +      if (!exists(pth_epub3.base ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_epub3.base ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../../index.html", +        )); +      } +      { /+ debug +/ +        if (doc_matters.opt.action.debug_do_epub) { +          if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { +            pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename).mkdirRecurse; +          } +          if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename))) { +            pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename).mkdirRecurse; +          } +          if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename))) { +            pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename).mkdirRecurse; +          } +        } +      } +      { /+ OEBPS/[segments].xhtml (the document contents) +/ +        foreach (seg_filename; doc_matters.has.segnames_lv_0_to_4) { +          string fn = pth_epub3.fn_oebps_content_xhtml(seg_filename); +          auto zip_arc_member_file = new ArchiveMember(); +          zip_arc_member_file.name = fn; +          auto zip_data = new OutBuffer(); +          { /+ debug +/ +            if (doc_matters.opt.action.debug_do_epub) { +              string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); +              auto f = File(fn_dbg, "w"); +              foreach (docseg; epub_write.doc_epub3[seg_filename]) { +                f.writeln(docseg); +              } +              foreach (docseg; epub_write.doc_epub3_endnotes[seg_filename]) { +                f.writeln(docseg); +              } +              f.writeln(xhtml_format.tail(doc_matters)); +            } +          } +          foreach (docseg; epub_write.doc_epub3[seg_filename]) { +            zip_data.write(docseg.dup); +          } +          foreach (docseg; epub_write.doc_epub3_endnotes[seg_filename]) { +            zip_data.write(docseg.dup); +          } +          zip_data.write(xhtml_format.tail(doc_matters).dup); +          zip_arc_member_file.expandedData = zip_data.toBytes(); +          zip.addMember(zip_arc_member_file); +          /+ create the zip file +/ +          createZipFile!()(fn_epub, zip.build()); +        } +      } +      string fn; +      string fn_dbg; +      File f; +      { /+ mimetypes (identify zip file type) +/ +        { /+ debug +/ +          if (doc_matters.opt.action.debug_do_epub) { +            fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.src.filename); +            File(fn_dbg, "w").writeln(epub_write.mimetypes); +          } +        } +        fn = pth_epub3.fn_mimetypes; +        EPUBzip(epub_write.mimetypes, fn); +      } +      { /+  META-INF/container.xml (identify doc root) +/ +        { /+ debug +/ +          if (doc_matters.opt.action.debug_do_epub) { +            fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.src.filename); +            File(fn_dbg, "w").writeln(epub_write.meta_inf_container_xml); +          } +        } +        fn = pth_epub3.fn_dmi_container_xml; +        EPUBzip(epub_write.meta_inf_container_xml, fn); +      } +      { /+ OEBPS/toc_nav.xhtml (navigation toc epub3) +/ +        { /+ debug +/ +          if (doc_matters.opt.action.debug_do_epub) { +            fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.src.filename); +            File(fn_dbg, "w").writeln(epub_write.oebps_toc_nav_xhtml); +          } +        } +        fn = pth_epub3.fn_oebps_toc_nav_xhtml; +        EPUBzip(epub_write.oebps_toc_nav_xhtml, fn); +      } +      { /+ OEBPS/content.opf (doc manifest) +/ +        { /+ debug +/ +          if (doc_matters.opt.action.debug_do_epub) { +            fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.src.filename); +            File(fn_dbg, "w").writeln(epub_write.oebps_content_opf); +          } +        } +        fn = pth_epub3.fn_oebps_content_opf; +        EPUBzip(epub_write.oebps_content_opf, fn); +      } +      { /+ OEBPS/_dr/image (images) +/ +        foreach (image; doc_matters.srcs.image_list) { +          { /+ debug +/ +            if (doc_matters.opt.action.debug_do_epub) { +              if (doc_matters.opt.action.vox_gt2) { +                writeln( +                  doc_matters.src.image_dir_path, "/", image, " -> ", +                  pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image +                ); +              } +              if (exists(doc_matters.src.image_dir_path ~ "/" ~ image)) { +                (doc_matters.src.image_dir_path ~ "/" ~ image) +                .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); +              } +            } +          } +          auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; +          auto fn_out =  pth_epub3.doc_oebps_image ~ "/" ~ image; +          if (exists(fn_src)) { +            { +              auto zip_arc_member_file = new ArchiveMember(); +              zip_arc_member_file.name = fn_out; +              auto zip_data = new OutBuffer(); +              zip_data.write(cast(char[]) ((fn_src).read)); +              zip_arc_member_file.expandedData = zip_data.toBytes(); +              zip.addMember(zip_arc_member_file); +              createZipFile!()(fn_epub, zip.build()); +            } +          } +        } +      } +      { /+ OEBPS/epub.css +/ +        auto css = spineCss(doc_matters); +        { /+ debug +/ +          if (doc_matters.opt.action.debug_do_epub) { +            fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.src.filename); +            File(fn_dbg, "w").writeln(css.epub); +          } +        } +        fn = pth_epub3.fn_oebps_css; +        auto zip_arc_member_file = new ArchiveMember(); +        zip_arc_member_file.name = fn; +        auto zip_data = new OutBuffer(); +        zip_data.write(css.epub.dup); +        zip_arc_member_file.expandedData = zip_data.toBytes(); +        zip.addMember(zip_arc_member_file); +        createZipFile!()(fn_epub, zip.build()); +      } +    } catch (ErrnoException ex) { +      // Handle error +    } +    if (doc_matters.opt.action.vox_gt0) { +      writeln(" ", fn_epub); +    } +    debug(epub_archive) { +      if (exists(fn_epub)) { +        try { +          auto zipped = new ZipArchive((fn_epub).read); +          foreach (filename, member; zipped.directory) { +            auto data = zipped.expand(member); +            writeln(filename, " length ", data.length); +          } +        } catch (ZipException ex) { +          // Handle errors +        } +      } +    } +  } +} diff --git a/src/sisudoc/io_out/html.d b/src/sisudoc/io_out/html.d new file mode 100644 index 0000000..d9aaa58 --- /dev/null +++ b/src/sisudoc/io_out/html.d @@ -0,0 +1,626 @@ +/+ +- 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.html; +@safe: +template outputHTML() { +  import +    std.file, +    std.outbuffer, +    std.uri, +    std.conv : to; +  import +    sisudoc.io_out, +    sisudoc.io_out.rgx, +    sisudoc.meta.rgx_files, +    sisudoc.io_out.rgx_xhtml, +    sisudoc.io_out.create_zip_file, +    sisudoc.io_out.xmls, +    sisudoc.io_out.xmls_css; +  mixin outputXHTMLs; +  void scroll(D,M)( +    const        D    doc_abstraction, +                 M    doc_matters, +  ) { +    mixin spineRgxOut; +    mixin spineRgxXHTML; +    auto xhtml_format = outputXHTMLs(); +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    string[] doc_html; +    string[] doc; +    string suffix = ".html"; +    string previous_section = ""; +    string delimit = ""; +    foreach (section; doc_matters.has.keys_seq.scroll) { +      foreach (obj; doc_abstraction[section]) { +        delimit = xhtml_format.div_delimit(section, previous_section); +        string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); +        switch (obj.metainfo.is_of_part) { +        case "frontmatter":              assert(section == "head" || "toc"); +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "toc": +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                } +              } +              break; +            } +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +              } +            } +            break; +          } +          break; +        case "body":                     assert(section == "body" || "head"); +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "para": +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                } +              } +              break; +            } +            break; +          case "block": +            switch (obj.metainfo.is_a) { +            case "quote": +              doc_html ~= xhtml_format.quote_scroll(_txt, obj, doc_matters); +              break; +            case "group": +              doc_html ~= xhtml_format.group_scroll(_txt, obj, doc_matters); +              break; +            case "block": +              doc_html ~= xhtml_format.block_scroll(_txt, obj, doc_matters); +              break; +            case "poem": +              break; +            case "verse": +              doc_html ~= xhtml_format.verse_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "code": +              doc_html ~= xhtml_format.code(_txt, obj, doc_matters); +              break; +            case "table": +              doc_html ~= xhtml_format.table(_txt, obj, doc_matters); +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                } +              } +              break; +            } +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +              } +            } +            break; +          } +          break; +        case "backmatter": +          assert(section == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "endnote":              assert(section == "endnotes"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "glossary":             assert(section == "glossary"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "bibliography":         assert(section == "bibliography"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "bookindex":            assert(section == "bookindex"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "blurb":                assert(section == "blurb"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            case "tail":                 assert(section == "tail"); +              doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix); +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                } +              } +              break; +            } +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +              } +            } +            break; +          } +          break; +        case "comment": +          break; +        default: +          { /+ debug +/ +            if (doc_matters.opt.action.debug_do_html) { +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +              writeln(__FILE__, ":", __LINE__, ": ", obj.text); +            } +          } +          break; +        } +      } +    } +    doc = xhtml_format.html_head(doc_matters, "scroll") +    ~ doc_html +    ~ xhtml_format.dom_close +    ~ xhtml_format.tail(doc_matters); +    scroll_write_output(doc, doc_matters); +  } +  @trusted void scroll_write_output(D,M)( +    D doc, +    M doc_matters, +  ) { +    debug(asserts) { +      static assert(is(typeof(doc)    == string[])); +    } +    auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +    try { +      if (!exists(pth_html.base)) { +        pth_html.base.mkdirRecurse; +      } +      { +        auto f = File(pth_html.fn_scroll(doc_matters.src.filename), "w"); +        foreach (o; doc) { +          f.writeln(o); +        } +      } +      if (!exists(pth_html.base ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_html.base ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../../index.html", +        )); +      } +    } catch (ErrnoException ex) { +      // Handle error +    } +    if (doc_matters.opt.action.vox_gt0) { +      writeln(" ", pth_html.fn_scroll(doc_matters.src.filename)); +    } +  } +  void seg(D,M)( +    const D    doc_abstraction, +          M    doc_matters, +  ) { +    mixin spineRgxOut; +    mixin spineRgxXHTML; +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    auto xhtml_format = outputXHTMLs(); +    string[][string] doc_html; +    string[][string] doc_html_endnotes; +    string[] doc; +    string segment_filename; +    string[] top_level_headings = ["","","",""]; +    string previous_seg_filename = ""; +    string suffix = ".html"; +    string previous_section = ""; +    string delimit = ""; +    foreach (section; doc_matters.has.keys_seq.seg) { +      foreach (obj; doc_abstraction[section]) { +        delimit = xhtml_format.div_delimit(section, previous_section); +        string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); +        if (obj.metainfo.is_a == "heading") { +          assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          switch (obj.metainfo.heading_lev_markup) { +          case 0: .. case 3: +            /+ fill buffer, and replace with new levels from 1 to 3 +/ +            switch (obj.metainfo.heading_lev_markup) { +            case 0: +              top_level_headings[0] = ""; +              top_level_headings[1] = ""; +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 1: +              top_level_headings[1] = ""; +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 2: +              top_level_headings[2] = ""; +              top_level_headings[3] = ""; +              goto default; +            case 3: +              top_level_headings[3] = ""; +              goto default; +            default: +              Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); +              top_level_headings[obj.metainfo.heading_lev_markup] = t[0]; +              break; +            } +            break; +          case 4: +            segment_filename = obj.tags.segment_anchor_tag_epub; +            doc_html[segment_filename] ~= xhtml_format.html_head(doc_matters, "seg"); +            auto navigation_bar = xhtml_format.nav_pre_next_svg(obj, doc_matters); +            doc_html[segment_filename] ~= navigation_bar.toc_pre_next; +            previous_seg_filename = segment_filename; +            foreach (top_level_heading; top_level_headings) { +              doc_html[segment_filename] ~= top_level_heading; +            } +            Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); +            doc_html[segment_filename] ~= t[0].to!string; +            doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc_matters); +            doc_html_endnotes[segment_filename] ~= t[1]; +            break; +          case 5: .. case 7: +            Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg"); +            doc_html[segment_filename] ~= t[0].to!string; +            doc_html_endnotes[segment_filename] ~= t[1]; +            break; +          case 8: .. case 9: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); +                writeln(__FILE__, ":", __LINE__, ": ", obj.text); +              } +            } +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); +              } +            } +            break; +          } +        } else { +          assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          Tuple!(string, string[]) t; +          switch (obj.metainfo.is_of_part) { +          case "frontmatter":             assert(section == "head" || "toc"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "toc": +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0].to!string; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_html) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                } +              } +              break; +            } +            break; +          case "body":                    assert(section == "body"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "para": +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0].to!string; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_html) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            case "block": +              switch (obj.metainfo.is_a) { +              case "quote": +                t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "seg"); +                goto default; +              case "group": +                t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "seg"); +                goto default; +              case "block": +                t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "seg"); +                goto default; +              case "poem": +                break; +              case "verse": +                t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "seg"); +                goto default; +              case "code": +                doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters); +                break; +              case "table": +                doc_html[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters); +                doc_html_endnotes[segment_filename] ~= ""; +                break; +              default: +                if ((obj.metainfo.is_a == "quote" +                  || obj.metainfo.is_a == "group" +                  || obj.metainfo.is_a == "block" +                  || obj.metainfo.is_a == "verse" +                )) { +                  doc_html[segment_filename] ~= t[0].to!string; +                  doc_html_endnotes[segment_filename] ~= t[1]; +                } else { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_html) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +                } +              } +              break; +            } +            break; +          case "backmatter": +            assert(section == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +            switch (obj.metainfo.is_of_type) { +            case "para": +              switch (obj.metainfo.is_a) { +              case "endnote":             assert(section == "endnotes"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                break; +              case "glossary":            assert(section == "glossary"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              case "bibliography":        assert(section == "bibliography"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              case "bookindex":           assert(section == "bookindex"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              case "blurb":               assert(section == "blurb"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              case "tail":                assert(section == "tail"); +                t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg"); +                doc_html[segment_filename] ~= t[0]; +                doc_html_endnotes[segment_filename] ~= t[1]; +                break; +              default: +                { /+ debug +/ +                  if (doc_matters.opt.action.debug_do_html) { +                    writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +                  } +                } +                break; +              } +              break; +            default: +              { /+ debug +/ +                if (doc_matters.opt.action.debug_do_html) { +                  writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); +                } +              } +              break; +            } +            break; +          case "comment": +            break; +          default: +            { /+ debug +/ +              if (doc_matters.opt.action.debug_do_html) { +                writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); +              } +            } +            break; +          } +        } +      } +    } +    seg_write_output(doc_html, doc_html_endnotes, doc_matters); +  } +  @trusted void seg_write_output(D,E,M)( // @system? +    D doc_html, +    E doc_html_endnotes, +    M doc_matters, +  ) { +    debug(asserts) { +      static assert(is(typeof(doc_html)      == string[][string])); +    } +    mixin spineRgxFiles; +    static auto rgx_files = RgxFiles(); +    auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +    auto xhtml_format = outputXHTMLs(); +    auto m = doc_matters.src.filename.matchFirst(rgx_files.src_fn); +    try { +      if (!exists(pth_html.seg(doc_matters.src.filename))) { +        pth_html.seg(doc_matters.src.filename).mkdirRecurse; +      } +      foreach (seg_filename; doc_matters.has.segnames_lv4) { +        auto f = File(pth_html.fn_seg(doc_matters.src.filename, seg_filename), "w"); +        foreach (docseg; doc_html[seg_filename]) { +          f.writeln(docseg); +        } +        foreach (docseg; doc_html_endnotes[seg_filename]) { +          f.writeln(docseg); +        } +        f.writeln(xhtml_format.tail(doc_matters)); +      } +      if (!exists(pth_html.fn_seg(doc_matters.src.filename, "index"))) { +        symlink("./toc.html", (pth_html.fn_seg(doc_matters.src.filename, "index"))); +      } +    } catch (ErrnoException ex) { +      // handle error +    } +    if (doc_matters.opt.action.vox_gt0) { +      writeln(" ", pth_html.fn_seg(doc_matters.src.filename, "toc")); +    } +  } +  void css(M)(M doc_matters) { +    auto css = spineCss(doc_matters); +    auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +    try { +      if (!exists(pth_html.css)) { +        (pth_html.css).mkdirRecurse; +      } +      { +        auto f = File(pth_html.fn_seg_css, "w"); +        f.writeln(css.html_seg); +        f = File(pth_html.fn_scroll_css, "w"); +        f.writeln(css.html_scroll); +      } +      if (!exists(pth_html.css ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_html.css ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "./css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../index.html", +        )); +      } +    } catch (ErrnoException ex) { +      // Handle error +    } +  } +  @trusted void images_cp(M)( // @system +    M    doc_matters, +  ) { +    { /+ (copy html images) +/ +      auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +      if (!exists(pth_html.image)) { +        pth_html.image.mkdirRecurse; +      } +      foreach (image; doc_matters.srcs.image_list) { +        auto fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; +        auto fn_src_out = pth_html.image ~ "/" ~ image; +        debug(images_html) { +          writeln(fn_src_in, " -> ", fn_src_out); +        } +        if (exists(fn_src_in)) { +          fn_src_in.copy(fn_src_out); +        } else { +          if (doc_matters.opt.action.vox_gt0) { +            writeln("WARNING image not found: ", fn_src_in); +          } +        } +      } +      if (!exists(pth_html.image ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_html.image ~"/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", +        )); +      } +    } +  } +} diff --git a/src/sisudoc/io_out/html_snippet.d b/src/sisudoc/io_out/html_snippet.d new file mode 100644 index 0000000..480246a --- /dev/null +++ b/src/sisudoc/io_out/html_snippet.d @@ -0,0 +1,103 @@ +/+ +- 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.html_snippet; +@safe: +template htmlSnippet() { +  import +    std.file, +    std.outbuffer, +    std.format, +    std.uri, +    std.conv : to; +  import +    sisudoc.io_out.rgx, +    sisudoc.meta.rgx_files, +    sisudoc.io_out.rgx_xhtml; +  auto format_html_blank_page_guide_home()( +    string css_style, +    string home_url, +    string collection_home_path +  ) { +    auto html_blank_default = format(q"┃<!DOCTYPE html> +<html> +  <head> +    <meta http-equiv="Content-Type" content="text/plain; charset=UTF-8" /> +    <link href="%s" rel="stylesheet" /> +  </head> +  <body> +    <p class="icons"> +      <a href="%s" class="lnkicon">⟰ </a>  +      <a href="%s" class="lnkicon"> ≅ </a> +    </p> +  </body> +</html>┃", +      css_style, +      home_url, +      collection_home_path +    ); +    return html_blank_default; +  } +  string special_characters_text(string _txt) { +    mixin spineRgxOut; +    mixin spineRgxXHTML; +    static auto rgx = RgxO(); +    static auto rgx_xhtml = RgxXHTML(); +    _txt = _txt +      .replaceAll(rgx_xhtml.ampersand,    "&")  // "&" +      .replaceAll(rgx_xhtml.quotation,    """) // """ +      .replaceAll(rgx_xhtml.less_than,    "<")   // "<" +      .replaceAll(rgx_xhtml.greater_than, ">")   // ">" +      .replaceAll(rgx.br_line,            "<br />") +      .replaceAll(rgx.br_line_inline,     "<br />") +      .replaceAll(rgx.br_line_spaced,     "<br />\n<br />") +      .replaceAll(rgx.nbsp_char,          " "); +    return _txt; +  } +} diff --git a/src/sisudoc/io_out/hub.d b/src/sisudoc/io_out/hub.d new file mode 100644 index 0000000..b68eb0d --- /dev/null +++ b/src/sisudoc/io_out/hub.d @@ -0,0 +1,238 @@ +/+ +- 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 hub<BR> +  check & generate output types requested ++/ +module sisudoc.io_out.hub; +@safe: +template outputHub() { +  import sisudoc.io_out, +    sisudoc.io_out.metadata, +    sisudoc.io_out.xmls, +    sisudoc.io_out.create_zip_file, +    sisudoc.io_out.paths_output; +  @system void outputHub(D,I)( +    const D doc_abstraction, +    I doc_matters +  ) { +    mixin Msg; +    auto msg = Msg!()(doc_matters); +    enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } +    void Scheduled(D,I)(int sched, D doc_abstraction, I doc_matters) { +      auto msg = Msg!()(doc_matters); +      if (sched == outTask.source_or_pod) { +        msg.v("spine (doc reform) source processing... "); +        if (doc_matters.opt.action.pod) { +          msg.v("spine (doc reform) source pod processing... "); +        } +        import sisudoc.io_out.source_pod; +        spinePod!()(doc_matters); +        if (doc_matters.opt.action.source) { +          msg.vv("spine (doc reform) source done"); +        } +        if (doc_matters.opt.action.pod) { +          msg.vv("spine (doc reform) source pod done"); +        } +      } +      if (sched == outTask.epub) { +        msg.v("epub3 processing... "); +        import sisudoc.io_out.epub3; +        doc_abstraction.outputEPub3!()(doc_matters); +        msg.vv("epub3 done"); +      } +      if (sched == outTask.html_stuff) { +        outputMetadata!()(doc_matters); +        msg.vv("html metadata done"); +      } +      if (sched == outTask.html_scroll) { +        msg.v("html scroll processing... "); +        import sisudoc.io_out.html; +        outputHTML!().scroll(doc_abstraction, doc_matters); +        msg.vv("html scroll done"); +      } +      if (sched == outTask.html_seg) { +        msg.v("html seg processing... "); +        import sisudoc.io_out.html; +        outputHTML!().seg(doc_abstraction, doc_matters); +        msg.vv("html seg done"); +      } +      if (sched == outTask.html_stuff) { +        import sisudoc.io_out.html; +        outputHTML!().css(doc_matters); +        outputHTML!().images_cp(doc_matters); +        msg.vv("html css & images done"); +      } +      if (sched == outTask.latex) { +        msg.v("latex processing... (available for downstream processing & pdf output"); +        import sisudoc.io_out.latex; +        import std.file; +        if ((isValidPath(doc_matters.output_path ~ "/latex/sty")) +          && (!(exists(doc_matters.output_path ~ "/latex/sty"))) +        ) { +          outputLaTeXstyInit!()( +            doc_matters.output_path, +            doc_matters.opt.action.generated_by, +            doc_matters.generator_program.name_version_and_compiler, +            doc_matters.generator_program.time_output_generated, +          ); +        } +        outputLaTeX!()(doc_abstraction, doc_matters); +        msg.vv("latex done"); +      } +      if (sched == outTask.odt) { +        msg.v("odf:odt processing... "); +        import sisudoc.io_out.odt; +        outputODT!()(doc_abstraction, doc_matters); +        msg.vv("odf:odt done"); +      } +      if (sched == outTask.sqlite) { +        msg.v("sqlite processing... "); +        import sisudoc.io_out.sqlite; +        doc_abstraction.SQLiteHubDiscreteBuildTablesAndPopulate!()(doc_matters); +        msg.vv("sqlite done"); +      } +    } +    if (doc_matters.opt.action.vox_gt0) { +      writeln(" ", doc_matters.src.filename_base); +    } +    if (!(doc_matters.opt.action.parallelise_subprocesses)) { +      foreach(schedule; doc_matters.opt.action.output_task_scheduler) { +        Scheduled!()(schedule, doc_abstraction, doc_matters); +      } +    } else { +      import std.parallelism; +      foreach(schedule; parallel(doc_matters.opt.action.output_task_scheduler)) { +        Scheduled!()(schedule, doc_abstraction, doc_matters); +      } +    } +    if (doc_matters.opt.action.sqlite_update) { +      msg.v("sqlite update processing..."); +      import sisudoc.io_out.sqlite; +      doc_abstraction.SQLiteHubBuildTablesAndPopulate!()(doc_matters); +      msg.vv("sqlite update done"); +    } else if (doc_matters.opt.action.sqlite_delete) { +      msg.v("sqlite delete processing..."); +      import sisudoc.io_out.sqlite; +      doc_abstraction.SQLiteHubBuildTablesAndPopulate!()(doc_matters); +      msg.vv("sqlite delete done"); +    } +  } +} +template outputHubInitialize() { +  import std.file; +  import sisudoc.io_out, +    sisudoc.io_out.metadata, +    sisudoc.io_out.paths_output; +  string _bespoke_homepage = "./spine-bespoke-output/html/homepage.index.html"; +  @system void outputHubInitialize(O,I)( +    O opt_action, +    I program_info +  ) { +    if ((opt_action.html || opt_action.html_seg || opt_action.html_scroll) +        && opt_action.output_dir_set.length > 0 +        && !(opt_action.output_dir_set ~ "/index.html").exists +    ) { +      writeln(_bespoke_homepage); +      if ((_bespoke_homepage).exists) { +        writeln("copy bespoke html homepage\n", _bespoke_homepage, " -> ", opt_action.output_dir_set, "/index.html"); +        _bespoke_homepage.copy(opt_action.output_dir_set ~ "/index.html"); +      } else { +        writeln("place bespoke homepage in ", _bespoke_homepage); +      } +    } +    if ( +      opt_action.latex_document_header_sty +      || ( +        opt_action.latex +        && opt_action.output_dir_set.length > 0 +        && !(isValidPath(opt_action.output_dir_set ~ "/latex/sty"))) +    ) { // .sty need to be produced only once (if unchanged per output-dir of which there usually will be only one) +      import sisudoc.io_out.latex; +      outputLaTeXstyInit!()( +        opt_action.output_dir_set, +        opt_action.generated_by, +        program_info.name_version_and_compiler, +        program_info.time_output_generated, +      ); +      writeln(opt_action.latex); +    } +  } +} +template outputHubOp() { +  import sisudoc.io_out, +    sisudoc.io_out.metadata, +    sisudoc.io_out.xmls, +    sisudoc.io_out.create_zip_file, +    sisudoc.io_out.paths_output; +  @system void outputHubOp(E,O,C)(E env, O opt_action, C config) { +    if ((opt_action.sqlite_db_drop)) { +      if ((opt_action.vox_gt1)) { +        writeln("sqlite drop db..."); +      } +      import sisudoc.io_out.sqlite; +      SQLiteDbDrop!()(opt_action, config); +      if ((opt_action.vox_gt2)) { +        writeln("sqlite drop db done"); +      } +    } +    if ((opt_action.sqlite_db_create)) { +      if ((opt_action.vox_gt1)) { +        auto pth_sqlite_db = spinePathsSQLite!()(opt_action.cgi_sqlite_search_filename, opt_action.output_dir_set); +        writeln("sqlite create table..."); +      } +      import sisudoc.io_out.sqlite; +      SQLiteTablesCreate!()(env, opt_action, config); +      if ((opt_action.vox_gt2)) { +        writeln("sqlite create table done"); +      } +    } +  } +} diff --git a/src/sisudoc/io_out/latex.d b/src/sisudoc/io_out/latex.d new file mode 100644 index 0000000..a6867cb --- /dev/null +++ b/src/sisudoc/io_out/latex.d @@ -0,0 +1,1771 @@ +/+ +- 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.latex; +@safe: +template paperLaTeX() { +  import +    std.format, +    std.conv : to; +  auto paperLaTeX() { +    string mm(uint mmi) { +      string _mm = format(q"┃%smm┃", mmi.to!string); +      return _mm; +    } +    struct PaperType { +      auto a4() { +        struct A4 { +          auto portrait() { +            struct V { +              string       stylesheet    = "spineA4portrait"; +              string       papersize     = "a4paper"; +              string       orient        = "portrait"; +              string       fontsize      = "11pt"; +              const uint   w             = 170; +              const uint   h             = 257; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 450; +              bool         is_portrait   = true; +            } +            return V(); +          } +          auto landscape() { +            struct H { +              string       stylesheet    = "spineA4landscape"; +              string       papersize     = "a4paper"; +              string       orient        = "landscape"; +              string       fontsize      = "11pt"; +              const uint   w             = 238; +              const uint   h             = 160; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 300; +              bool         is_portrait   = false; +            } +            return H(); +          } +        } +        return A4(); +      } +      auto a5() { +        struct A5 { +          auto portrait() { +            struct V { +              string       stylesheet    = "spineA5portrait"; +              string       papersize     = "a5paper"; +              string       orient        = "portrait"; +              string       fontsize      = "11pt"; +              const uint   w             = 112; +              const uint   h             = 162; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 280; +              bool         is_portrait   = true; +            } +            return V(); +          } +          auto landscape() { +            struct H { +              string       stylesheet    = "spineA5landscape"; +              string       papersize     = "a5paper"; +              string       orient        = "landscape"; +              string       fontsize      = "11pt"; +              const uint   w             = 152; +              const uint   h             = 100; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 190; +              bool         is_portrait   = false; +            } +            return H(); +          } +        } +        return A5(); +      } +      auto b4() { +        struct B4 { +          auto portrait() { +            struct V { +              string       stylesheet    = "spineB4portrait"; +              string       papersize     = "b4paper"; +              string       orient        = "portrait"; +              string       fontsize      = "11pt"; +              const uint   w             = 140; +              const uint   h             = 204; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 356; +              bool         is_portrait   = true; +            } +            return V(); +          } +          auto landscape() { +            struct H { +              string       stylesheet    = "spineB4landsape"; +              string       papersize     = "b4paper"; +              string       orient        = "landscape"; +              string       fontsize      = "11pt"; +              const uint   w             = 200; +              const uint   h             = 130; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 260; +              bool         is_portrait   = false; +            } +            return H(); +          } +        } +        return B4(); +      } +      auto letter() { +        struct Letter { +          auto portrait() { +            struct V { +              string       stylesheet    = "spineLetterPortrait"; +              string       papersize     = "letterpaper"; +              string       orient        = "portrait"; +              string       fontsize      = "11pt"; +              const uint   w             = 166; +              const uint   h             = 212; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 468; +              bool         is_portrait   = true; +            } +            return V(); +          } +          auto landscape() { +            struct H { +              string       stylesheet    = "spineLetterLandscape"; +              string       papersize     = "letterpaper"; +              string       orient        = "landscape"; +              string       fontsize      = "11pt"; +              const uint   w             = 226; +              const uint   h             = 166; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 290; +              bool         is_portrait   = false; +            } +            return H(); +          } +        } +        return Letter(); +      } +      auto legal() { +        struct Legal { +          auto portrait() { +            struct V { +              string       stylesheet    = "spineLegalPortrait"; +              string       papersize     = "legalpaper"; +              string       orient        = "portrait"; +              string       fontsize      = "11pt"; +              const uint   w             = 168; +              const uint   h             = 286; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 474; +              bool         is_portrait   = true; +            } +            return V(); +          } +          auto landscape() { +            struct H { +              string       stylesheet    = "spineLegalLandscape"; +              string       papersize     = "legalpaper"; +              string       orient        = "landscape"; +              string       fontsize      = "11pt"; +              const uint   w             = 296; +              const uint   h             = 166; +              const uint   l             = 30; +              const uint   r             = 20; +              const uint   t             = 30; +              const uint   b             = 30; +              string       width         = mm(w); +              string       height        = mm(h); +              string       margin_left   = mm(l); +              string       margin_right  = mm(r); +              string       margin_top    = mm(t); +              string       margin_bottom = mm(b); +              uint         img_px        = 420; +              bool         is_portrait   = false; +            } +            return H(); +          } +        } +        return Legal(); +      } +    } +    return PaperType(); +  } +} +template outputLaTeX() { +  import +    std.digest.sha, +    std.file, +    std.outbuffer, +    std.uri, +    std.conv : to; +  import +    sisudoc.io_out, +    sisudoc.io_out.rgx, +    sisudoc.io_out.rgx_latex; +  mixin spineRgxOut; +  static auto rgx = RgxO(); +  mixin spineRgxLSC; +  static auto rgx_sc = RgxLSC(); +  mixin spineLanguageCodes; +  auto lang = Lang(); +  auto paper = paperLaTeX; +  string sp_char_ops()( +    string      _txt, +  ) { +    string _unescape_sp_char_esc()(string _txt) { +      _txt = _txt +        .replaceAll(rgx_sc.latex_special_char_escaped, +          format(q"┃%s┃", "$1")) +        .replaceAll(rgx_sc.latex_special_char_escaped_braced, +          format(q"┃%s┃", "$1")); +      return _txt; +    } +    string _unescape_fontface_esc()(string _txt) { +      _txt = _txt.replaceAll(rgx_sc.latex_identify_inline_fontface, +           format(q"┃%s%s┃", "$1", "$2")); +      return _txt; +    } +    _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx_sc.latex_special_char_for_escape); +    _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx_sc.latex_special_char_for_escape_and_braces); +    _txt = replaceAll!(m => "''")(_txt, rgx.quotes_open_and_close); +    _txt = replaceAll!(m => "$\\cdot$")(_txt, rgx.middle_dot); +    _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_link); +    _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx_sc.latex_identify_inline_fontface); +    return _txt; +  } +  string sp_char_esc(O)( +    string      _txt, +    const    O  obj, +  ) { +    if (obj.metainfo.is_a != "code") { +      _txt = _txt.sp_char_ops; +    } +    return _txt; +  } +  string sp_char_esc_txt()( +    string      _txt, +  ) { +    _txt = _txt.sp_char_ops; +    return _txt; +  } +  string marked_linebreaks_newlines()( +    string      _txt, +  ) { +    _txt = _txt.split(rgx.br_linebreaks_newlines).join("\\br\n").strip; +    // _txt = replaceAll!(m => "\\br " ~ m[1])(_txt, rgx.br_linebreaks_newlines); +    return _txt; +  } +  string fontface()( +    string      _txt, +  ) { +  _txt = _txt +    .replaceAll(rgx.inline_emphasis,    format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) +    .replaceAll(rgx.inline_bold,        format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) +    .replaceAll(rgx.inline_italics,     format(q"┃\emph{%s}┃",                        "$1")) +    .replaceAll(rgx.inline_italics,     format(q"┃\uline{%s}┃",                       "$1")) +    .replaceAll(rgx.inline_superscript, format(q"┃$$^{%s}$$┃",           "$1")) +    .replaceAll(rgx.inline_subscript,   format(q"┃$$_{%s}$$┃",           "$1")) +    .replaceAll(rgx.inline_strike,      format(q"┃\sout{%s}┃",                        "$1")) +    .replaceAll(rgx.inline_insert,      format(q"┃\uline{%s}┃",                       "$1")) +    .replaceAll(rgx.inline_mono,        format(q"┃\begin{monosp}%s\end{monosp}┃",     "$1")) +    .replaceAll(rgx.inline_italics,     format(q"┃``%s''┃",                           "$1")); +    return _txt; +  } +  string leading_hardspaces()( +    string      _txt, +  ) { +    string hardspaces(string _spaces) { +      _spaces  = _spaces +        .replaceAll(rgx.space, "{\\s}"); +      return _spaces; +    } +    _txt = replaceAll!(m => hardspaces(m[0]))(_txt, rgx.spaces_line_start); +    return _txt; +  } +  string nbsp_char()(string _txt) { +    if (_txt.match(rgx.nbsp_char)) { +      foreach (m; _txt.matchAll(rgx.nbsp_chars)) { +        int spaces_ = 0; +        foreach (n; m[0].matchAll(rgx.nbsp_char)) { +          spaces_ ++; +        } +        _txt = _txt.replaceFirst(rgx.nbsp_chars, "\\spaces{" ~ spaces_.to!string ~ "}"); +      } +    } +    return _txt; +  } +  string spaces_to_nbsp()(string _txt) { +    if (_txt.match(rgx.spaces_keep)) { +      foreach (m; _txt.matchAll(rgx.spaces_keep)) { +        int spaces_ = 0; +        foreach (n; m[0].matchAll(rgx.space)) { +          spaces_ ++; +        } +        _txt = _txt.replaceFirst(rgx.spaces_keep, "\\spaces{" ~ spaces_.to!string ~ "}"); +      } +    } +    return _txt; +  } +  string nbsp_char_to_space()(string _txt) { +    if (_txt.match(rgx.nbsp_char)) { +      _txt  = _txt.replaceAll(rgx.nbsp_char, " "); +    } +    return _txt; +  } +  string links_and_images(O,M)( +    string      _txt, +    const    O  obj, +             M  doc_matters, +  ) { +    if (obj.has.inline_links) { // TODO some images do not have inline links ... image without link +      string _width_adjust(string _width) { +        if (_width.to!int > 300) { _width = "300"; } // will need to vary max with papersize & orientation +        return _width; +      } +      string _latex_image_path(string _image_path) { +        auto pth_latex = spinePathsLaTeX(doc_matters); +        _image_path = pth_latex.latex_path_stuff ~ "/" ~ _image_path; +        return _image_path; +      } +      string _if_images(string _linked_content) { +        if (_linked_content.match(rgx.inline_image_info)) { +          _linked_content = replaceAll!(m => +              format(q"┃\includegraphics*[width=%spt]{%s}%s┃", +                _width_adjust(m[2]), _latex_image_path(m[1]), " \\br\n") +            )(_linked_content, rgx.inline_image_info); +        } +        return _linked_content; +      } +      string _check_link(string _link) { +        _link = _link +          .replaceFirst(rgx_sc.latex_clean_internal_link, "") +          .replaceAll(rgx_sc.latex_special_char_for_escape_url, "\\$1"); +        return _link; +      } +      if  (obj.metainfo.is_a != "code") { +        _txt = replaceAll!(m => +            m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├" +          )(_txt, rgx.inline_link_number_only); +        _txt = replaceAll!(m => +            ((m[1] == m[2]) && (m[2].match(rgx.uri))) // url link (regular link with url) +            ? format(q"┃\linkurl{%s}{%s}┃", _check_link(m[1]), (_check_link(m[1])).sp_char_esc_txt) +            : ((m[2].match(rgx.uri)) && (m[1].match(rgx.inline_image_info))) // linked image +              ? format(q"┃%s\href{%s}%s{%s}┃", "\\br ", _check_link(m[2]), "\n", _if_images(m[1])) // markup for images +              : (m[2].match(rgx.uri)) // not linked image +                ? format(q"┃%s\linktext{%s}{%s}┃", "\\br ", _check_link(m[2]), m[1]) // regular link with text +                : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1])) // internal links, like book index +          )(_txt, rgx.inline_link); +      } +    } +    return _txt; +  } +  string footnotes()( +    string      _txt, +  ) { +    if (_txt.match(rgx.inline_notes_al_gen)) { +      string _tex_note = q"┃\hypertarget{noteref_%s}{}\footnote[%s]{%% +  \label{note_%s}%s}┃"; +      _txt = _txt.split(rgx.br_linebreaks).join("\\br ").replaceAll(rgx.inline_notes_al_regular_number_note, +        format(_tex_note, +          "$1", "$1", "$1", +          "$2".strip +        ).strip +      ); +    } +    return _txt; +  } +  string remove_footnotes()( +    string      _txt, +  ) { +    if (_txt.match(rgx.inline_notes_al_gen)) { +      _txt = replaceAll!(m => "")(_txt, rgx.inline_notes_al_gen); +    } +    return _txt; +  } +  string para(O)( +    string      _txt, +    O           obj, +  ) { +    if (obj.metainfo.is_of_type == "para") { +      string _tex_para; +      _tex_para = q"┃\ocn{%s}%s┃"; +      _txt  = format(_tex_para, +        obj.metainfo.object_number, +        _txt.footnotes +      ).strip; +    } +    return _txt; +  } +  string bookindex(O)( +    string      _txt, +    O           obj, +  ) { +    if (obj.metainfo.is_of_type == "para" +      && obj.metainfo.is_a == "bookindex" +    ) { +      string _tex_para; +      _tex_para = q"┃%s┃"; +      _txt  = format(_tex_para, +        _txt.replaceAll(rgx_sc.latex_clean_bookindex_linebreak, "\n") ~ "\n\\brln\n" +      ); +    } +    return _txt; +  } +  string heading(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +    string      paper_size_orientation, +    string      _part = "" +  ) { +    struct latexMarks { +      string pg_break = "\\clearpage\n"; +    } +    latexMarks manual_breaks( +      latexMarks _ltx, +      string     test_for_break_level, +    ) { +      if ((!(doc_matters.conf_make_meta.make.breaks.empty) +        && (matchFirst(doc_matters.conf_make_meta.make.breaks, test_for_break_level))) +      ) {                                                                      // manually override defaults +        if ((matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage)) +          && (matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn)) +        ) { +          if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage)) { +            if (matchFirst(m.captures["breakpage"], test_for_break_level)) { +              _ltx.pg_break = "\\clearpage\n"; +            } else if (auto n = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn)) { +              if (matchFirst(n.captures["breakcolumn"], test_for_break_level)) { +                if ((paper_size_orientation == "a4.landscape") +                  || (paper_size_orientation == "b4.landscape") +                  || (paper_size_orientation == "a5.landscape") +                  || (paper_size_orientation == "letter.landscape") +                  || (paper_size_orientation == "legal.landscape") +                ) { +                  _ltx.pg_break = "\\\\ \\columnbreak\n"; // "\\\\ \\newpage\n"; +                } else { // portrait +                  _ltx.pg_break = "\\clearpage\n"; +                } +              } +            } +          } +        } else if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakpage)) { +          if (matchFirst(m.captures["breakpage"], test_for_break_level)) { +            _ltx.pg_break = "\\clearpage\n"; +          } +        } else if (auto m = matchFirst(doc_matters.conf_make_meta.make.breaks, rgx.make_breakcolumn)) { +          if (matchFirst(m.captures["breakcolumn"], test_for_break_level)) { +            if ((paper_size_orientation == "a4.landscape") +              || (paper_size_orientation == "b4.landscape") +              || (paper_size_orientation == "a5.landscape") +              || (paper_size_orientation == "letter.landscape") +              || (paper_size_orientation == "legal.landscape") +            ) { +              _ltx.pg_break = "\\\\ \\columnbreak\n"; // "\\\\ \\newpage\n"; +            } else { // portrait +              _ltx.pg_break = "\\clearpage\n"; +            } +          } +        } +      } else if (!(doc_matters.conf_make_meta.make.breaks.empty)) { +        _ltx.pg_break = ""; +      } +      return _ltx; +    } +    if (obj.metainfo.is_a == "heading") { +      string _tex_para; +      latexMarks _ltx = latexMarks(); +      string _pg_break; +      string _sect; +      string _post; +      string _title_add; +      string _columns = ""; +      switch (obj.metainfo.heading_lev_markup) { +      case 0: // A == TITLE +        _pg_break = "\\begin{document}\n"; +        goto default; +      case 1: // B == part: section heading level +        _pg_break = "\\clearpage\n"; +        goto default; +      case 2: // C == part: section heading level +        _pg_break = "\\clearpage\n"; +        goto default; +      case 3: // D == part: section heading level +        _pg_break = "\\clearpage\n"; +        goto default; +      case 4: // 1 == section +        _columns = (_part != "bookindex") +          ? "" : "\n\\br\n\\begin{multicols}{2}"; +        if (doc_matters.conf_make_meta.make.doc_type == "article") {             // defaults for article +          _ltx.pg_break = ""; +        } else if (doc_matters.conf_make_meta.make.doc_type == "book") {         // defaults for book +          _ltx.pg_break = "\\clearpage\n"; +        } else { +          _ltx.pg_break = "\\clearpage\n"; +        } +        _ltx = manual_breaks(_ltx, "1"); +        _pg_break = _ltx.pg_break; +        _sect = "section"; +        _post = ""; +        _title_add = format(q"┃ +\markboth{%s}{%s}┃", +          doc_matters.conf_make_meta.meta.title_full, +          doc_matters.conf_make_meta.meta.title_full, +        ); +        goto default; +      case 5: // 2 == subsection +        _pg_break = ""; +        // _pg_break = "newpage"; // doubt this is necessary +        _sect = "subsection"; +        _post = " \\br\n"; +        _title_add = ""; +        goto default; +      case 6: // 3 == subsubsection +        _pg_break = ""; +        // _pg_break = "newpage"; // doubt this is necessary +        _sect = "subsubsection"; +        _post = " \\br\n"; +        _title_add = ""; +        goto default; +      case 7: // 4 == paragraph +        _pg_break = ""; +        // _pg_break = "newpage"; // doubt this is necessary +        _sect = "paragraph"; +        _post = " \\br\n"; +        _title_add = ""; +        goto default; +      case 8: // 5 == subparagraph +        _pg_break = ""; +        // _pg_break = "newpage"; // doubt this is necessary +        _sect = "subparagraph"; +        _post = " \\br\n"; +        _title_add = ""; +        goto default; +      default: +        if (obj.metainfo.heading_lev_markup == 0) { +          _tex_para = q"┃ +\begin{document} +\thispagestyle{empty} +\title{%s%s} +\author{ \textnormal{%s}} +\date{\begin{tiny}%s\end{tiny}} +\maketitle +\addcontentsline{toc}{part}{%s} +\newpage +\pagestyle{fancy} +\pagenumbering{alph} +\setcounter{page}{1} +\markboth{%s}{%s} +\br\linebreak Copyright {\begin{small}{\copyright\end{small}} %s \br\linebreak +%s +\clearpage┃"; +          _txt = format(_tex_para, +            (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, +            doc_matters.conf_make_meta.meta.title_subtitle.empty ? "" +            : " \\\\ - \\\\ " ~ (doc_matters.conf_make_meta.meta.title_subtitle).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.date_published).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.rights_copyright).sp_char_esc_txt.marked_linebreaks_newlines, +            (doc_matters.conf_make_meta.meta.rights_license).sp_char_esc_txt.marked_linebreaks_newlines, +          ); +        } else if (obj.metainfo.heading_lev_markup < 4) { +          if (!(_txt.footnotes.strip == "Endnotes")) { +            _tex_para = q"┃%s\part*{\ocn{%s}%s} +\addcontentsline{toc}{part}{%s} +\markboth{%s}┃"; +            _txt = format(_tex_para, +              _pg_break, +              obj.metainfo.object_number, +              _txt.strip.footnotes, +              _txt.strip.remove_footnotes, +              (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, +            ); +          } +        } else if (obj.metainfo.heading_lev_markup > 3) { +          if (obj.metainfo.heading_lev_markup == 4 +          && _txt.match(regex(r"^Table of Contents$"))) { +            _tex_para = q"┃ +\pagenumbering{arabic} +\setcounter{page}{1} +\markboth{ }{ } +\part*{\ocn{1}%s \newline %s} + +\clearpage +\pagenumbering{roman} +\setcounter{page}{1} +\renewcommand{\contentsname}{} +\tableofcontents + +\clearpage +\pagenumbering{arabic} +\setcounter{page}{2} +\clearpage +\markboth{%s}{%s} +%% \null +\clearpage +\setcounter{page}{2}┃"; +            _txt = format(_tex_para, +              (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, +              (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt, +              (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, +              (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, +            ); +          } else if (obj.metainfo.heading_lev_markup == 4 +            && _part == "bookindex" +            && _txt.match(regex(r"^Index$")) +          ) { +            _tex_para = q"┃%s\%s*{\ocn{%s}%s} +\addcontentsline{toc}{%s}{%s%s}%s%s┃"; +            _txt = format(_tex_para, +              _pg_break, +              _sect.strip, +              obj.metainfo.object_number, +              _txt.footnotes.strip, +              _sect, +              _txt.remove_footnotes.strip, +              _post, +              _title_add, +              _columns, +            ); +          } else if (obj.metainfo.dummy_heading +            && obj.metainfo.heading_lev_markup == 4 +          ) { /+ dummy headings completely omitted +/ +            _txt = ""; +          } else { +            _tex_para = q"┃%s\%s*{\ocn{%s}%s} +\addcontentsline{toc}{%s}{%s%s}%s┃"; +            _txt = format(_tex_para, +              _pg_break, +              _sect.strip, +              obj.metainfo.object_number, +              _txt.footnotes.strip, +              _sect, +              _txt.remove_footnotes.strip, +              _post, +              _title_add, +            ); +          } +        } +        break; +      } +    } +    return _txt.strip; +  } +  string group(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +  ) { +    if (obj.metainfo.is_a == "group") { +      string _tex_para; +      _tex_para = q"┃\ocn{%s}\objGroupOpen +%s +\objGroupClose +┃"; +      _txt  = format(_tex_para, +        obj.metainfo.object_number, +        _txt.footnotes.split(rgx.br_line_spaced).join("\\brl{1}").strip // provides more control (more noise, not as tidy) +        // _txt.footnotes.split(rgx.br_line_spaced).join("") // this works using a line-space, looks tidy, keep ref. +      ).strip; +    } +    return _txt; +  } +  string block(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +  ) { +    if (obj.metainfo.is_a == "block") { +      string _tex_para; +      _tex_para = q"┃\ocn{%s}\objBlockOpen +%s +\objBlockClose +┃"; +      _txt = format(_tex_para, +        obj.metainfo.object_number, +        _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip +      ).strip; +    } +    return _txt; +  } +  string verse(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +  ) { +    if (obj.metainfo.is_a == "verse") { +      string _tex_para; +      _tex_para = q"┃\ocn{%s}\objPoemVerseOpen +%s +\objPoemVerseClose +┃"; +      _txt  = format(_tex_para, +        obj.metainfo.object_number, +        _txt.spaces_to_nbsp.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip +      ).strip; +    } +    return _txt; +  } +  string codeblock(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +  ) { +    if (obj.metainfo.is_a == "code") { +      string _tex_para; +      _tex_para = q"┃\ocn{%s}\begin{objCodeBlock}\begin{lstlisting} +%s +\end{lstlisting}\end{objCodeBlock} +┃"; +      _txt  = format(_tex_para, +        obj.metainfo.object_number, +        _txt.nbsp_char_to_space +      ).strip; +    } +    return _txt; +  } +  auto tablarize(O)( +    string            _txt, +    const        O    obj, +  ) { +    string[] _table_rows = (_txt).split(rgx.table_delimiter_row); +    string[] _table_cols; +    string _table; +    string _tablenote; +    foreach(row_idx, row; _table_rows) { +      _table_cols = row.split(rgx.table_delimiter_col); +      _table ~= ""; +      foreach(col_idx, cell; _table_cols) { +        if ((_table_cols.length == 1) +        && (_table_rows.length <= row_idx+2)) { // check row_idx+2 (rather than == ++row_idx) +          _tablenote ~= cell; +        } else { +          // // _table ~= "\\bfseries "; +          // _table ~= cell; +          // _table ~= (_table_cols.length > (col_idx + 1)) ? "&" : ""; +          _table ~= format(q"┃%s%s┃", +            cell, +            (_table_cols.length > (col_idx + 1)) ? "&" : "" +          ); +        } +      } +      _table ~= "\\\\"; +    } +    Tuple!(string, string) t = tuple( +      _table, +      _tablenote, +    ); +    return t; +  } +  string table(O,M)( +    string      _txt, +    O           obj, +    M           doc_matters, +    string      paper_size_orientation, +  ) { +    if (obj.metainfo.is_a == "table") { +      auto _t = _txt.tablarize(obj); +      string _table = _t[0]; +      string _t_n = _t[1]; +      uint pw = 0; +      switch (paper_size_orientation) { +      case "a4.portrait":      pw = (paper.a4.portrait.w      - 20); break; +      case "a4.landscape":     pw = (paper.a4.landscape.w     - 20); break; +      case "b4.portrait":      pw = (paper.b4.portrait.w      - 20); break; +      case "b4.landscape":     pw = (paper.b4.landscape.w     - 20); break; +      case "a5.portrait":      pw = (paper.a5.portrait.w      - 20); break; +      case "a5.landscape":     pw = (paper.a5.landscape.w     - 20); break; +      case "letter.portrait":  pw = (paper.letter.portrait.w  - 20); break; +      case "letter.landscape": pw = (paper.letter.landscape.w - 20); break; +      case "legal.portrait":   pw = (paper.legal.portrait.w   - 20); break; +      case "legal.landscape":  pw = (paper.legal.landscape.w  - 20); break; +      default:                 pw = 0;                               break; +      } +      // auto textwidth = (pw - 24); +      string _colw = ""; +      foreach (w; obj.table.column_widths) { +        _colw ~= format(q"┃p{%.0fmm}┃", +          (w * pw / 100) +          // (w * (pw - 24)/ 100) +          // (w * textwidth / 100) +        ); +      } +      string _tex_para; +      _tex_para = q"┃\ocn{%s}\objTableOpen{%s} +%s +\objTableClose +┃"; +      _txt  = format(_tex_para, +        obj.metainfo.object_number, +        _colw, +        _table, +      ).strip; +    } +    return _txt; +  } +  string bullets_and_indentation(O)( +    string      _txt, +    O           obj, +  ) { +    string _tex_para; +    string _hang; string _indent; +    int _paper_margin = -10; +    int _indent_increment = 8; // 5; 10; +    if (obj.attrib.bullet) { +      int _bullet_space = 5; +      _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin + _bullet_space).to!string; +      _txt  = format(q"┃\begin{Bullet}{%smm}%s\end{Bullet}┃", +        _indent, +        _txt.footnotes +      ).strip; +    } else if ( +      obj.attrib.indent_base != 0 +      && obj.attrib.indent_base == obj.attrib.indent_hang +    ) { +      _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string; +      _tex_para = q"┃\begin{ParagraphIndent}{%smm}%s \end{ParagraphIndent}┃"; +      _txt = format(_tex_para, +        _indent, +        _txt.footnotes +      ).strip; +    } else if ( +      obj.attrib.indent_base != 0 +      || obj.attrib.indent_hang != 0 +    ) { +      _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string; +      _hang = (((obj.attrib.indent_hang - obj.attrib.indent_base) * _indent_increment)).to!string; +      _tex_para = q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃"; +      _txt = format(_tex_para, +        _indent, _hang, +        _txt.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n") +      ).strip; +    } +    return _txt; +  } +  string latex_head(M)( +    M      doc_matters, +    string paper_size_orientation, +  ) { +    struct paperTypeLatex { +      string a4_portrait; +      string a4_landscape; +      string b4_portrait; +      string b4_landscape; +      string a5_portrait; +      string a5_landscape; +      string us_letter_portrait; +      string us_letter_landscape; +      string us_legal_portrait; +      string us_legal_landscape; +    } +    auto paper_type_latex           = paperTypeLatex(); +    string _footer(M)(M doc_matters) { +      string _ft = "\\lfoot[\\textrm{\\thepage}]"; +      string _ft_1 = format(q"┃{\tiny \href{%s}{%s}}┃", "https://sisudoc.org", "SiSU",); +      string _ft_2 = format(q"┃ +    \cfoot{\href{%s}{%s}}┃", "https://git.sisudoc.org", "git",); +      if (doc_matters.conf_make_meta.make.footer.length > 0) { +        if (doc_matters.conf_make_meta.make.footer.length > 0) { +          if (doc_matters.conf_make_meta.make.footer[0].matchAll(rgx.inline_link)) { +            _ft ~= doc_matters.conf_make_meta.make.footer[0] +              .replace(rgx.inline_link, "{\\tiny \\href{$2}{$1}}"); +          } else { +            _ft ~= _ft_1; +          } +        } +        if (doc_matters.conf_make_meta.make.footer.length > 1) { +          if (doc_matters.conf_make_meta.make.footer[1].matchAll(rgx.inline_link)) { +            _ft ~= doc_matters.conf_make_meta.make.footer[1] +              .replace(rgx.inline_link, "\n\\cfoot{\\href{$2}{$1}}"); +          } else { +            _ft ~= _ft_2; +          } +        } +      } else { +        _ft ~= _ft_1; +        _ft ~= _ft_2; +      } +      return _ft; +    } +    struct paperMargins { +      string portrait; +      string landscape; +    } +    auto margins           = paperMargins(); +    struct columnsMulti { +      string portrait; +      string landscape; +    } +    auto multicol           = columnsMulti(); +    multicol.landscape    = ""; +    struct colorLinks { +      string mono; +      string color; +    } +    auto links           = colorLinks(); +    links.mono    = format(q"┃ +  colorlinks=true, +  urlcolor=black, +  filecolor=black, +  linkcolor=black, +  citecolor=black, +┃", +    ); +    links.color    = format(q"┃ +  colorlinks=true, +  urlcolor=myblue,    %% \href{...}{...}   external url +  filecolor=mygreen,  %% \href{...}        local file +  linkcolor=myred,    %% \href{...} and \pageref{...} +  citecolor=black, +┃", +    ); +    string set_paper(P)(P paper_set,) { +      string paper_type_description; +      if (paper_set.is_portrait) { +        paper_type_description = format(q"┃ +\documentclass[%s,%s,titlepage,makeidx]{scrartcl} +\usepackage{%s} +\usepackage[%s,%s]{babel} +\usepackage[autostyle, english = american]{csquotes} +%% \MakeOuterQuote{"} %% not required, using '' as quote delimiter +\selectlanguage{%s} +\hypersetup{ +  pdftitle={%s}, +  pdfauthor={%s}, +  pdfsubject={%s}, +} +\usepackage{fancyhdr} +\lhead[ ]{ } +\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } +\rhead[ ]{ } +%s +\rfoot[\tiny \href{}{}]{\textrm{\thepage}} +        ┃", +          paper_set.fontsize, +          paper_set.papersize, +          "./sty/" ~ paper_set.stylesheet, +          lang.codes[doc_matters.src.language]["xlp"], +          "english", +          lang.codes[doc_matters.src.language]["xlp"], +          doc_matters.conf_make_meta.meta.title_full.strip, +          doc_matters.conf_make_meta.meta.creator_author.strip, +          doc_matters.conf_make_meta.meta.classify_subject.strip, +          _footer(doc_matters), +        ); +      } else { +        paper_type_description = format(q"┃ +\documentclass[%s,%s,landscape,titlepage,twocolumn,makeidx]{scrartcl} +\usepackage{%s} +\usepackage[english]{babel} +%% \usepackage{polyglossia} +\setmainlanguage{%s} +\setotherlanguage{%s} +\selectlanguage{%s} +\hypersetup{ +  pdftitle={%s}, +  pdfauthor={%s}, +  pdfsubject={%s}, +} +\usepackage{fancyhdr} +\lhead[ ]{ } +\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } +\rhead[ ]{ } +%s +\rfoot[\tiny \href{}{}]{\textrm{\thepage}} +        ┃", +          paper_set.fontsize, +          paper_set.papersize, +          "./sty/" ~ paper_set.stylesheet, +          lang.codes[doc_matters.src.language]["xlp"], +          "english", +          lang.codes[doc_matters.src.language]["xlp"], +          doc_matters.conf_make_meta.meta.title_full.strip, +          doc_matters.conf_make_meta.meta.creator_author.strip, +          doc_matters.conf_make_meta.meta.classify_subject.strip, +          _footer(doc_matters), +        ); +      } +      return paper_type_description; +    } +    string paper_size_orientation_latex; +    switch (paper_size_orientation) { +      case "a4.portrait":      paper_size_orientation_latex = set_paper(paper.a4.portrait);      break; +      case "a4.landscape":     paper_size_orientation_latex = set_paper(paper.a4.landscape);     break; +      case "b4.portrait":      paper_size_orientation_latex = set_paper(paper.b4.portrait);      break; +      case "b4.landscape":     paper_size_orientation_latex = set_paper(paper.b4.landscape);     break; +      case "a5.portrait":      paper_size_orientation_latex = set_paper(paper.a5.portrait);      break; +      case "a5.landscape":     paper_size_orientation_latex = set_paper(paper.a5.landscape);     break; +      case "letter.portrait":  paper_size_orientation_latex = set_paper(paper.letter.portrait);  break; +      case "letter.landscape": paper_size_orientation_latex = set_paper(paper.letter.landscape); break; +      case "legal.portrait":   paper_size_orientation_latex = set_paper(paper.legal.portrait);   break; +      case "legal.landscape":  paper_size_orientation_latex = set_paper(paper.legal.landscape);  break; +      default:                 paper_size_orientation_latex = paper_type_latex.a4_portrait; +    } +    string links_mono_or_color_set = links.mono.strip; +    if ( +      (doc_matters.opt.action.latex_color_links) +      || (paper_size_orientation == +        "a4.landscape" || +        "a5.landscape" || +        "b4.landscape" || +        "letter.landscape" || +        "legal.landscape") +    ){ +      links_mono_or_color_set = links.mono.strip; +    } +    string _latex_head = format(q"┃%%%% spine LaTeX output%s%s +%%%% %s %s +%s +%s +    ┃", +      doc_matters.opt.action.generated_by ? " " ~ doc_matters.generator_program.name_version_and_compiler : "", +      doc_matters.opt.action.generated_by ? " (generated " ~  doc_matters.generator_program.time_output_generated ~ ")" : "", +      doc_matters.generator_program.project_name.strip, +      doc_matters.generator_program.url_home.strip, +      paper_size_orientation_latex.strip, +      margins.portrait.strip, +    ); +    return _latex_head.strip; +  } +  string latex_body(D,M)( +    const  D      doc_abstraction, +           M      doc_matters, +           string paper_size_orientation, +  ) { +    string _latex_body = ""; +    bool _multicolumns = false; +    string _txt; +    foreach (part; doc_matters.has.keys_seq.latex) { +      foreach (obj; doc_abstraction[part]) { +        switch (obj.metainfo.is_of_part) { +        case "frontmatter":              assert(part == "head" || "toc"); +          _txt = obj.text +            .sp_char_esc(obj) +            .fontface; +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              _txt = _txt.heading(obj, doc_matters, paper_size_orientation); +              goto default; +            case "toc": +              break; +            default: +              _latex_body ~= _txt ~ "\n\n"; +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "body":                     assert(part == "body" || "head"); // surprise +          _txt = obj.text +            .sp_char_esc(obj) +            .fontface; +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              _txt = _txt.heading(obj, doc_matters, paper_size_orientation); +              goto default; +            case "para": +              _txt = _txt.para(obj) +                .bullets_and_indentation(obj) +                .links_and_images(obj, doc_matters); +              goto default; +            default: +              _latex_body ~= _txt ~ "\n\n"; +              _txt = ""; +              break; +            } +            break; +          case "block": +            switch (obj.metainfo.is_a) { +            case "quote": +              goto default; // TODO +            case "group": /+ (hardspaces not honored) [remove any hardspace marker] +/ +              _txt = _txt.group(obj, doc_matters) +                .links_and_images(obj, doc_matters); +              goto default; +            case "block": /+ (hardspace honored) \hardspace +/ +              _txt = _txt.block(obj, doc_matters) +                .links_and_images(obj, doc_matters); +              goto default; +            case "verse": /+ (hardspace honored) \hardspace +/ +              _txt = _txt.verse(obj, doc_matters) +                .links_and_images(obj, doc_matters); +              goto default; +            case "code": /+ (hardspace honored) \begin{lstlisting} clear hardspace marker +/ +              _txt = _txt.codeblock(obj, doc_matters); +              goto default; +            case "table": +              _txt = _txt.table(obj, doc_matters, paper_size_orientation); +              goto default; // TODO +            default: +              _latex_body ~= _txt ~ "\n\n"; +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "backmatter": +          assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          _txt = obj.text +            .sp_char_esc(obj) +            .fontface; +          switch (obj.metainfo.is_of_type) { +          case "para": +            if (part != "bookindex" && _multicolumns) { +              _multicolumns = false; +              _latex_body ~= "\n\\end{multicols}\n"; +            } +            switch (obj.metainfo.is_a) { +            case "heading": +              if (part == "bookindex") { +                _multicolumns = true; +              } +              _txt = _txt.heading(obj, doc_matters, paper_size_orientation, part); +              goto default; +            case "endnote":              assert(part == "endnotes"); +              /* uncomment code to reinstate endnotes in endnote section */ +              // _txt = _txt.para(obj) +              //   .bullets_and_indentation(obj) +              //   .links_and_images(obj, doc_matters); +              // goto default; +              break; +            case "glossary":             assert(part == "glossary"); +              _txt = _txt.para(obj) +                .bullets_and_indentation(obj) +                .links_and_images(obj, doc_matters); +              goto default; +            case "bibliography":         assert(part == "bibliography"); +              _txt = _txt.para(obj) +                .bullets_and_indentation(obj); +              goto default; +            case "bookindex":            assert(part == "bookindex"); +              /+ two column, special section +/ +              _txt = _txt.bookindex(obj) +                .links_and_images(obj, doc_matters); +              goto default; +            case "blurb":                assert(part == "blurb"); +              _txt = _txt.para(obj) +                .bullets_and_indentation(obj) +                .links_and_images(obj, doc_matters); +              goto default; +            default: +              _latex_body ~= (part == "bookindex" && obj.metainfo.is_a != "heading") +                ? _txt : (_txt ~ "\n\n"); +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "comment": +          break; +        default: +          { /+ debug +/ +            if (doc_matters.opt.action.debug_do_latex +            && doc_matters.opt.action.vox_gt1) { +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +              writeln(__FILE__, ":", __LINE__, ": ", obj.text); +            } +          } +          break; +        } +      } +    } +    if (_multicolumns) { +      _multicolumns = false; +      _latex_body ~= "\n\\end{multicols}\n"; +    } +    return _latex_body; +  } +  string latex_tail(M)( +    M      doc_matters, +    string paper_size_orientation, +  ) { +    string _latex_tail = format(q"┃ + +\end{document} +  ┃", +    // doc_matters.conf_make_meta.meta.title_full, +    // doc_matters.conf_make_meta.meta.creator_author, +  ); +    return _latex_tail; +  } +  void writeOutputLaTeX(T,M)( +    const T      latex_content, +          M      doc_matters, +          string paper_size_orientation, +  ) { +    auto pth_latex = spinePathsLaTeX(doc_matters); +    try { +      { /+ debug +/ +        if (doc_matters.opt.action.debug_do_latex +        && doc_matters.opt.action.vox_gt1) { +          writeln(latex_content.head); +          writeln(latex_content.content); +          writeln(latex_content.tail); +        } +      } +      if (!exists(pth_latex.latex_path_stuff)) { +        (pth_latex.latex_path_stuff).mkdirRecurse; +      } +      if (doc_matters.opt.action.vox_gt0) { +        writeln(" ", pth_latex.latex_file_with_path(paper_size_orientation)); +      } +      { +        auto f = File(pth_latex.latex_file_with_path(paper_size_orientation), "w"); +        f.writeln(latex_content.head); +        f.writeln(latex_content.content); +        f.writeln(latex_content.tail); +        foreach (image; doc_matters.srcs.image_list) { +          string fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; +          string fn_src_out_file = pth_latex.latex_path_stuff ~ "/" ~ image; +          if (exists(fn_src_in)) { +            fn_src_in.copy(fn_src_out_file); +          } +        } +      } +      if (!exists(pth_latex.latex_path_stuff ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_latex.latex_path_stuff ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url +            , +          "../../index.html", +        )); +      } +      // should be in latex init and done just once, doc_matters not passed there though +      if (!exists(pth_latex.base ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_latex.base ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../index.html", +        )); +      } +      if (!exists(pth_latex.base_sty ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_latex.base_sty ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../../index.html", +        )); +      } +    } catch (ErrnoException ex) { +      // handle error +    } +  } +  void outputLaTeX(D,M)( +    const    D   doc_abstraction, +             M   doc_matters, +  ) { +    struct LaTeX { +      string head; +      string content; +      string tail; +    } +    auto latex             = LaTeX(); +    foreach (paper_size_orientation; doc_matters.conf_make_meta.conf.set_papersize) { +      latex.head           = latex_head(doc_matters, paper_size_orientation); +      latex.content        = latex_body(doc_abstraction, doc_matters, paper_size_orientation); +      latex.tail           = latex_tail(doc_matters, paper_size_orientation); +      latex.writeOutputLaTeX(doc_matters, paper_size_orientation); +    } +  } +} +template outputLaTeXstyInit() { +  import sisudoc.io_out; +  auto paper = paperLaTeX; +  void writeOutputLaTeXstyStatic( +    string latex_sty, +    string output_dir, +    string filename, +  ) { +    if ((output_dir.length > 0) +      && isValidPath(output_dir) +    ) { +      auto pth_latex = spinePathsLaTeXsty(output_dir); +      try { +        import std.file; +        if (!exists(pth_latex.base_sty)) { +          (pth_latex.base_sty).mkdirRecurse; +        } +        { +          auto f = File(pth_latex.latex_document_header_sty(filename), "w"); +          f.writeln(latex_sty); +        } +      } catch (ErrnoException ex) { +        // handle error +      } +    } +  } +  void outputLaTeXstyInit()( +    string output_dir, +    bool   generated_by, +    string name_version_and_compiler, +    string time_output_generated, +  ) { +    string latex_sty = outputLaTeXstyStatic!()(generated_by, name_version_and_compiler, time_output_generated); +    latex_sty.writeOutputLaTeXstyStatic(output_dir, "spineShared.sty"); +    auto sty_a4p      = paper.a4.portrait; +    auto latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4p, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4p.stylesheet ~ ".sty"); +    auto sty_a4l      = paper.a4.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4l, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4l.stylesheet ~ ".sty"); +    auto sty_b4p      = paper.b4.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4p, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4p.stylesheet ~ ".sty"); +    auto sty_b4l      = paper.b4.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4l, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4l.stylesheet ~ ".sty"); +    auto sty_a5p      = paper.a5.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5p, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5p.stylesheet ~ ".sty"); +    auto sty_a5l      = paper.a5.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5l, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5l.stylesheet ~ ".sty"); +    auto sty_letter_p  = paper.letter.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_p, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_p.stylesheet ~ ".sty"); +    auto sty_letter_l  = paper.letter.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_l, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_l.stylesheet ~ ".sty"); +    auto sty_legal_p   = paper.legal.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_p, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_p.stylesheet ~ ".sty"); +    auto sty_legal_l   = paper.legal.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_l, generated_by, name_version_and_compiler, time_output_generated); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_l.stylesheet ~ ".sty"); +  } +} +template outputLaTeXstyStatic() { +  import +    std.format, +    std.conv : to; +  string outputLaTeXstyStatic( +    bool   generated_by, +    string name_version_and_compiler, +    string time_output_generated, +  ) { +    string latex_sty = format(q"┃%%%% spine LaTeX output%s%s +%% - called by the .sty containing the paper dimensions (size and orientation) to be used +%% - spineShared.sty used by all spine documents (called indirectly) +\ProvidesPackage{./sty/spineShared} +\usepackage{multicol} +\setlength{\marginparsep}{4mm} +\setlength{\marginparwidth}{8mm} +\usepackage[scaled]{dejavu} +\renewcommand*\familydefault{\sfdefault} +\usepackage{inconsolata} +\usepackage[T1]{fontenc} +\usepackage{newunicodechar} +%% \usepackage[utf8]{inputenc} +\usepackage{alltt} +\usepackage[ +  unicode=true, +	pdfusetitle, +  pdfsubject={}, +  pdfkeywords={},         %% keywords list {} {} {}, +  pdftoolbar=true, +  pdfmenubar=true, +  pdfwindowui=true, +  pdffitwindow=false,     %% window fit to page when opened +  pdfstartview={FitH},    %% fits the width of the page to the window +  pdfnewwindow=true,      %% links in new window +  pdfborder={0 0 1}, +  plainpages=false,       %% was true +  bookmarks=true, +  bookmarksopen=false, +  bookmarksnumbered=false, +  backref=false, +  breaklinks=false, +  colorlinks=true, +  urlcolor=black, +  filecolor=black, +  linkcolor=black, +  citecolor=black,        %% links_mono_or_color_set +]{hyperref} +\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} +\usepackage[usenames]{color} +\definecolor{myblack}{rgb}{0,0,0} +\definecolor{myred}{rgb}{0.75,0,0} +\definecolor{mygreen}{rgb}{0,0.5,0} +\definecolor{myblue}{rgb}{0,0,0.5} +\definecolor{mywhite}{rgb}{1,1,1} +\usepackage{textcomp} +\usepackage[parfill]{parskip} +\usepackage[normalem]{ulem} +\usepackage{soul} +\usepackage{longtable} +\usepackage{graphicx} +\usepackage[tc]{titlepic} +\usepackage{amssymb} +\usepackage{amsmath} +\usepackage[cm]{sfmath} +\usepackage{underscore} +\usepackage{listings} +\setcounter{secnumdepth}{2} +\setcounter{tocdepth}{4} +\usepackage{bookmark} +\usepackage{microtype} +\makeatletter +\usepackage[multiple,ragged]{footmisc} +\setlength\footnotemargin{12pt} +\usepackage[para]{manyfoot} +\DeclareNewFootnote{A} +\makeatother +\chardef\txtbullet="2022 +\chardef\tilde="7E +\def\asterisk{{\rm \char42} } +\definecolor{Light}{gray}{.92} +\definecolor{listinggray}{gray}{0.9} +\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} +\lstset{ +  backgroundcolor=\color{lbcolor}, +  tabsize=4, +  rulecolor=, +  language=, +  basicstyle={\ttfamily\scriptsize}, +  upquote=true, +  columns=fixed, +  showstringspaces=false, +  extendedchars=true, +  breaklines=true, +  prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, +  frame=single, +  showtabs=false, +  showspaces=false, +  showstringspaces=false, +  identifierstyle=\ttfamily, +  keywordstyle=\color[rgb]{0,0,1}, +  commentstyle=\color[rgb]{0.133,0.545,0.133}, +  stringstyle=\color[rgb]{0.627,0.126,0.941}, +} +\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part} +\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection} +\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection} +\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph} +\newenvironment{ParagraphIndent}[1]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +} {\end{list}} +\newenvironment{ParagraphHang}[2]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \itemindent=#2 +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +} {\end{list}} +\newenvironment{Bullet}[1]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \itemindent=-1em +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +  $\txtbullet$\hspace{\enspace} +} {\end{list}} +\newcommand{\monosp}[1]{\normaltext\ttfamily\texbackslash#1} +\newcommand{\br}{\hfill\break} +\newcommand{\brl}[1]{%% +  \ifx&%% +    \hfill\break +  \else +    \vspace{#1ex} +  \fi +} +\newcommand{\brln}{\hspace*{\fill}\linebreak} +\newcommand{\objBlockOpen}{%% +  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}\raggedright +  \begin{footnotesize} +} +\newcommand{\objBlockClose}{%% +  \end{footnotesize} +  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} +} +\newcommand{\objGroupOpen}{%% +  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex} +  \begin{footnotesize} +} +\newcommand{\objGroupClose}{%% +  \end{footnotesize} +} +\newcommand{\objPoemVerseOpen}{%% +  \setlength{\parskip}{0.1ex plus0.1ex minus0.1ex} +  \begin{footnotesize} + +} +\newcommand{\objPoemVerseClose}{%% + +  \end{footnotesize} +  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} +  \linebreak +} +\newcommand{\parasep}{%% +  \smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br +} +\newcommand{\spaces}[1]{{\hspace*{#1ex}}} +\newcommand{\s}{\hspace*{1ex}} +\newcommand{\hardspace}{\hspace*{1ex}} +\newcommand{\-}{\hspace*{1ex}} +\newcommand{\caret}{{\^{~}}} +\newcommand{\pipe}{{\textbar}} +\newcommand{\curlyOpen}{{} +\newcommand{\curlyClose}{}} +\newcommand{\lt}{{UseTextSymbol{OML}{<}}} +\newcommand{\gt}{{UseTextSymbol{OML}{>}}} +\newcommand{\slash}{{/}} +\newcommand{\underscore}{\_} +\newcommand{\exclaim}{\Verbatim{!}} +\newcommand{\linktext}[2]{%% +  {\href{#1} +  {\;\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\linkurl}[2]{%% +  \;{\href{#1} +  {\;\scriptsize\ttfamily\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\link}[2]{%% +  {\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1} +  {\;\ulcorner\,{#2}\,\lrcorner}\end{scriptsize}} +} +\newcommand{\objCodeBlock}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} +\newcommand{\objCodeOpen}{%% +  \normaltext\raggedright\small\ttfamily\texbackslash +  \begin{lstlisting} +} +\newcommand{\objCodeClose}{%% +  \end{lstlisting} +} +\newcommand{\ocn}[1]{%% +  \setlength{\parindent}{0em} +  \ifx&%% #1 is empty +    \hspace{-0.5ex}{\marginpar{\begin{tiny}\end{tiny}}} +  \else%% #1 is nonempty +    \hspace{-0.5ex}{\marginpar{\begin{tiny}\hspace{0em}\hypertarget{#1}{#1}\end{tiny}}} +  \fi +} +\newcommand{\ocnhold}[1]{%% +  \begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}} +} +\newcommand{\objCodeBlockHold}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} +\newcommand{\objTableOpen}[1]{%% +  \setlength{\LTleft}{0pt} +  \setlength{\LTright}{\fill} +  \begin{tiny} +  \begin{longtable}{#1} +} +\newcommand{\objTableClose}{%% +  \end{longtable} +  \end{tiny} +} +%% \tolerance=300 +%% \clubpenalty=300 +%% \widowpenalty=300 +%% \usepackage{atbegshi} %% http://ctan.org/pkg/atbegshi         %% (BUG tmp FIX deal with problem, remove first page which is blank) +%% \AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}} %% (BUG tmp FIX deal with problem, remove first page which is blank) +┃", +  generated_by ? " " ~ name_version_and_compiler : "", +  generated_by ? " (generated " ~  time_output_generated ~ ")" : "", +); +    return latex_sty; +  } +} +template outputLaTeXstyPaperSizeAndOrientation() { +  import +    std.format, +    std.conv : to; +  auto outputLaTeXstyPaperSizeAndOrientation(P)( +    P      doc_sty_info, +    bool   generated_by, +    string name_version_and_compiler, +    string time_output_generated, +  ) { +    string latex_sty = format(q"┃%%%% spine LaTeX output%s%s +%% - called by .tex document to set paper dimensions (size and orientation) +%% - calls spineShared.sty used/shared by all spine documents +\ProvidesPackage{./sty/%s} +\usepackage{geometry} +\geometry{ +  %s, +  %s, +  left=%s, +  right=%s, +  top=%s, +  bottom=%s, +} +\usepackage{./sty/spineShared}┃", +  generated_by ? " " ~ name_version_and_compiler : "", +  generated_by ? " (generated " ~  time_output_generated ~ ")" : "", +  doc_sty_info.stylesheet, +  doc_sty_info.papersize, +  doc_sty_info.orient, +  doc_sty_info.margin_left, +  doc_sty_info.margin_right, +  doc_sty_info.margin_top, +  doc_sty_info.margin_bottom, +); +    return latex_sty; +  } +} diff --git a/src/sisudoc/io_out/metadata.d b/src/sisudoc/io_out/metadata.d new file mode 100644 index 0000000..0210212 --- /dev/null +++ b/src/sisudoc/io_out/metadata.d @@ -0,0 +1,609 @@ +/+ +- 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.metadata; +@safe: +template outputMetadata() { +  void outputMetadata(T)( T  doc_matters) { +    string inline_search_form(M)( +      M  doc_matters, +    ) { +      string o; +      string _form; +      if (doc_matters.opt.action.html_link_search) { +        o = format(q"┃ +        <div class="flex-menu-option"> +          <!-- SiSU Spine Search --> +          <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="searchtxt"> +            <font size="2">%s  +          <input type="text" name="sf" size="24" maxlength="255">%s +          <input type="hidden" name="sml" value="1000"> +          <input type="hidden" name="ec" value="on"> +          <input type="hidden" name="url" value="on"> +          <input type="hidden" name="rt" value="txt"> +          <button type="submit" form="searchtxt" name="fn" value="%s"> • ⚏ </button> +          </font></form> +          <!-- SiSU Spine Search --> +        </div> +    <div class="flex-menu-option"> +    <!-- SiSU Spine Search --> +    <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="search"> +    <font size="2"> +    <input type="text" name="sf" size="24" maxlength="255">%s +    <input type="hidden" name="sml" value="1000"> +    <input type="hidden" name="ec" value="on"> +    <input type="hidden" name="url" value="on"> +    <button type="submit" form="search" name="fn" value="%s">• ፨</button> +    <button type="submit" form="search">㏈ ፨</button> +    </font></form> +    <!-- SiSU Spine Search --> +    </div>┃", +        doc_matters.conf_make_meta.conf.w_srv_cgi_action, +        (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty) +          ? "" +          : "\n    <a href=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_cgi_action +            ~ "\">🔎 </a>", +        (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty) +          ? "" +          : "\n    <input type=\"hidden\" name=\"db\" value=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename +            ~ "\">", +        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    <input type=\"hidden\" name=\"db\" value=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename +            ~ "\">", +        doc_matters.src.filename_base, +        ); +      } else { +        o = ""; +      } +      return o; +    } +    import +      std.file, +      std.format; +    import sisudoc.io_out; +    mixin InternalMarkup; +    string[] metadata_; +string theme_dark_0 = format(q"┃ +  body { +    color                    : #CCCCCC; +    background               : #000000; +    background-color         : #000000; +  } +  a:link { +    color                    : #FFFFFF; +    text-decoration          : none; +  } +  a:visited { +    color                    : #999999; +    text-decoration          : none; +  } +  a:hover { +    color                    : #000000; +    background-color         : #555555; +  } +  a:hover img { +    background-color         : #000000; +  } +  a:active { +    color                    : #888888; +    text-decoration          : underline; +  } +  a.lnkicon:link { +    text-decoration          : none; +  } +  a.lnkicon:visited { +    text-decoration          : none; +  } +  a.lnkicon:hover { +    font-size                : 160%%; +  } +  a:hover img { +    background-color         : #FFFFFF; +  } +  input { +    color                    : #FFFFFF; +    background-color         : #777777; +  } +┃"); +string theme_light_0 = format(q"┃ +  body { +    color                    : #000000; +    background               : #FFFFFF; +    background-color         : #FFFFFF; +  } +  a:link { +    color                    : #003399; +    text-decoration          : none; +  } +  a:visited { +    color                    : #003399; +    text-decoration          : none; +  } +  a:hover { +    color                    : #000000; +    background-color         : #f9f9aa; +  } +  a:hover img { +    background-color         : #FFFFFF; +  } +  a:active { +    color                    : #003399; +    text-decoration          : underline; +  } +  a.lnkicon:link { +    text-decoration          : none; +  } +  a.lnkicon:visited { +    text-decoration          : none; +  } +  a.lnkicon:hover { +    font-size                : 160%%; +  } +  a:hover img { +    background-color         : #FFFFFF; +  } +  input { +    color                    : #000000; +    background-color         : #FFFFFF; +  } +┃"); +string theme_dark_1 = format(q"┃ +  h1 { +    color                    : #FFFFFF; +    background               : #000000; +  } +  p.letter { +    color                    : #FFFFFF; +    background               : #333333; +  } +┃"); +string theme_light_1 = format(q"┃ +  h1 { +    color                    : #FFFFFF; +    background               : #1A3A7A; +  } +  p.letter { +    color                    : #FFFFFF; +    background               : #1A3A7A; +  } +┃"); +      metadata_ ~= format(q"┃<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>⌘ Curated metadata - Topics</title> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="dc.title" content= "metadata curate, Authors & Topics - information Structuring Universe, Structured information Serialised Units" /> +<meta name="dc.subject" content= "document structuring, ebook, publishing, PDF, LaTeX, XML, ODF, SQL, postgresql, sqlite, electronic book, electronic publishing, electronic document, electronic citation, data structure, citation systems, granular search, digital library" /> +<meta name="generator" content="spine" /> +<link rel="generator" href="https://sisudoc.org" /> +<link href="./css/curate.css" rel="stylesheet"> +<style TYPE="text/css"> +/* spine curate css default stylesheet */%s +  .norm, .bold { +    line-height              : 150%%; +    margin-left              : 1em; +    margin-right             : 2em; +    margin-top               : 10px; +    margin-bottom            : 0px; +    text-indent              : 0mm; +  } +  p, h0, h1, h2, h3, h4, h5, h6, h7 { +    display                  : block; +    font-family              : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; +    font-size                : 100%%; +    font-weight              : normal; +    line-height              : 150%%; +    /* text-align            : justify; */ +    margin-left              : 1em; +    text-indent              : 0mm; +    margin-top               : 2px; +    margin-bottom            : 2px; +    margin-right             : 6px; +    text-align               : left; +  } +  h0, h1, h2, h3, h4, h5, h6, h7 { text-shadow: .2em .2em .3em #999999; } +  h1 { +    font-size                : 120%%; +    font-weight              : bold; +    color                    : #FFFFFF; +    background               : #000088; +    margin-left              : 0em; +  } +  p.work { +    font-size                : 80%%; +    margin-left              : 5em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.author { +    font-size                : 100%%; +    margin-left              : 2em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.publication { +    font-size                : 80%%; +    margin-left              : 4em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.letter { +    font-weight              : bold; +    font-size                : 60%%; +    margin-left              : 1em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.icons, .icons_center { +    font-size                : 100%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +  } +  p.icons { +    text-align               : left; +  } +  p.lev0 { +    font-size                : 120%%; +    margin-left              : 1em; +  } +  p.lev1 { +    font-size                : 110%%; +    margin-left              : 2em; +  } +  p.lev2 { +    font-size                : 100%%; +    margin-left              : 3em; +  } +  p.lev3 { +    font-size                : 90%%; +    margin-left              : 4em; +  } +  p.lev4 { +    font-size                : 80%%; +    margin-left              : 5em; +  } +  p.lev5 { +    font-size                : 80%%; +    margin-left              : 6em; +  }%s +  /* flex */ +  .flex-menu-bar { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-flex-wrap        : wrap; +    -webkit-align-items      : center; +    align-items              : center; +    width                    : 100%%; +    margin-left              : 0%%; +    margin-right             : 2%%; +    background-color         : inherited; +  } +  .flex-menu-option { +    background-color         : inherited; +    margin-right             : 4px; +  } +  .flex-list { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-align-items      : center; +    display                  : block; +    align-items              : center; +    width                    : 100%%; +    background-color         : inherited; +  } +  .flex-list-item { +    background-color         : inherited; +    margin                   : 4px; +  } +</style> +<link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> +</head> +┃", +  doc_matters.opt.action.css_theme_default ? theme_light_0 : theme_dark_0, +  doc_matters.opt.action.css_theme_default ? theme_light_1 : theme_dark_1, +) ~ "\n"; +    void metadata_write_output(M)(M doc_matters, string[] metadata_) { +      auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +      try { +        if (!exists(pth_html.base)) { +          pth_html.base.mkdirRecurse; +        } +        { +          auto f = File(pth_html.fn_scroll("metadata." ~ doc_matters.src.filename), "w"); +          foreach (o; metadata_) { +            f.writeln(o); +          } +        } +        if (!exists(pth_html.base ~ "/index.html")) { +          import sisudoc.io_out.html_snippet; +          mixin htmlSnippet; +          auto f = File(pth_html.base ~"/index.html", "w"); +          f.writeln(format_html_blank_page_guide_home( +            "../../css/html_scroll.css", +            (doc_matters.opt.action.webserver_url_doc_root.length > 0) +              ? doc_matters.opt.action.webserver_url_doc_root +              : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +            "../../index.html", +          )); +        } +      } catch (ErrnoException ex) { +        // Handle error +      } +      if (doc_matters.opt.action.vox_gt0) { +        writeln(" ", pth_html.fn_scroll("metadata." ~ doc_matters.src.filename)); +      } +    } +    static auto mkup = InlineMarkup(); +    import sisudoc.io_out.html_snippet; +    mixin htmlSnippet; +    if (doc_matters.opt.action.debug_do) { +      writeln(doc_matters.src.filename_base); +      writeln("Title:       ", doc_matters.conf_make_meta.meta.title_full); +      writeln("  Author:    ", doc_matters.conf_make_meta.meta.creator_author); +      writeln("  Published: ", doc_matters.conf_make_meta.meta.date_published); +      writeln("  Copyright: ", doc_matters.conf_make_meta.meta.rights_copyright); +      writeln("  License:   ", special_characters_text(doc_matters.conf_make_meta.meta.rights_license)); +      if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { +        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) { writeln("  ",         subject_tree[0]); } +          if (subject_tree.length > 1) { writeln("    ",       subject_tree[1]); } +          if (subject_tree.length > 2) { writeln("      ",     subject_tree[2]); } +          if (subject_tree.length > 3) { writeln("        ",   subject_tree[3]); } +          if (subject_tree.length > 4) { writeln("          ", subject_tree[4]); } +        } +      } +    } +    auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); +    auto pth_epub = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); +    auto pth_pdf  = spinePathsPDF!()(doc_matters); +    auto pth_pod =  spinePathsPods!()(doc_matters); +    metadata_ ~= format(q"┃<body lang="en" xml:lang="en"> +    <a name="top" id="top"></a> +    <a name="up" id="up"></a> +    <a name="start" id="start"></a> +    ┃"); +    metadata_ ~= "<div class=\"flex-menu-bar\"><div class=\"flex-menu-option\">"; +    if (doc_matters.opt.action.html_link_curate) { +      metadata_ ~= format(q"┃<p class="icons">[<a href="%s" class="lnkicon"> <b>⟰</b> HOME </a> | <a href="../../index.html" class="lnkicon"> ≅ Collection </a>]  [ +       <a href="../../authors.html" class="lnkicon"> 🖋 Authors </a> | +       <a href="../../topics.html" class="lnkicon"> ⌘ Topics </a>]</p> +    ┃", +    (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, +    ); +    } else { +      metadata_ ~= format(q"┃<p class="icons">[<a href="../../../index.html" class="lnkicon"> ≅ <b>HOME</b> </a> <a href="../../index.html" class="lnkicon"> ≅ Collection </a>] +    ┃"); +    } +    metadata_ ~= "</div>" ~ inline_search_form(doc_matters) ~ "</div><hr />"; +    if (!(doc_matters.conf_make_meta.meta.title_full.empty)) { +      metadata_ ~= "<p class=\"lev0\">Title: <b><a href=\"" ~ doc_matters.src.filename_base ~ "/toc.html\">" ~ doc_matters.conf_make_meta.meta.title_full       ~ "</a></b></p>"; +    } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { +      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_ ~= "<p class=\"lev1\">Author: <b><a href=\"../../authors.html#" ~ doc_matters.conf_make_meta.meta.creator_author_surname.translate([' ' : "_"]) ~ "\">" +                                                   ~ doc_matters.conf_make_meta.meta.creator_author   ~ "</a></b></p>"; +      } else { +        metadata_ ~= "<p class=\"lev1\">Author: <b>" +                                                   ~ doc_matters.conf_make_meta.meta.creator_author   ~ "</b></p>"; +      } +    } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { +      writeln("ERROR no Author information provided in document header ", doc_matters.src.filename_base); +    } +    metadata_ ~= "<p class=\"lev1\">Published: "   ~ doc_matters.conf_make_meta.meta.date_published   ~ "</p>"; +    if (!(doc_matters.conf_make_meta.meta.rights_copyright.empty)) { +      metadata_ ~= "<p class=\"lev1\">Copyright: "   ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright) ~ "</p>"; +    } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { +      writeln("WARNING no Copyright information provided in document header ", doc_matters.src.filename_base); +    } +    if (!(doc_matters.conf_make_meta.meta.rights_license.empty)) { +      metadata_ ~= "<p class=\"lev1\">License:   "   ~ special_characters_text(doc_matters.conf_make_meta.meta.rights_license) ~ "</p>"; +    } else if (doc_matters.opt.action.debug_do || doc_matters.opt.action.vox_gt2) { +      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_ ~= "<hr /><p class=\"lev0\">Summary:</p><p class=\"lev1\">"   ~ special_characters_text(doc_matters.conf_make_meta.meta.notes_summary) ~ "</p>"; +    } else if (doc_matters.opt.action.debug_do) { +      writeln("WARNING no summary of text provided in document header ", doc_matters.src.filename_base); +    } +    metadata_ ~= "<hr /><p class=\"lev1\">source: "      ~ doc_matters.src.filename_base ~ "</p>"; +    if (doc_matters.opt.action.html_link_markup_source) { +      metadata_ ~= "<p class=\"lev1\">●  markup source:  the pod [<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ ".zip\" class=\"lnkicon\">" +                   ~ " 🫛 zipped </a>| " +                   ~ "<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ "/\" class=\"lnkicon\">" +                   ~ " 🫛 tree </a>] "; +    } +    metadata_ ~= "<p class=\"lev1\">●  outputs:  [ html: <a href=\""    ~ doc_matters.src.filename_base ~ ".html\" class=\"lnkicon\">" +                 ~ " ▤ scroll </a> " +                 ~ "|<a href=\""    ~ doc_matters.src.filename_base ~ "/toc.html\" class=\"lnkicon\">" +                 ~ " ※ seg </a>]   " +                 ~ "[<a href=\"../../" ~ pth_epub.internal_base ~ "/" ~ doc_matters.src.filename_base ~ "." ~ doc_matters.src.language ~ ".epub\" class=\"lnkicon\">" +                 ~ " ◆ epub </a>]   "; +    if ((doc_matters.opt.action.html_link_pdf) || (doc_matters.opt.action.html_link_pdf_a4)) { +      metadata_ ~=  "[ pdf: <a href=\"../../pdf/" +                 ~ doc_matters.src.filename_base +                 ~ "." ~ doc_matters.src.language ~ ".a4.portrait.pdf\" class=\"lnkicon\">" +                 ~ " □ a4 </a> " +                 ~ "|<a href=\"../../pdf/" +                 ~ doc_matters.src.filename_base +                 ~ "." ~ doc_matters.src.language ~ ".letter.portrait.pdf\" class=\"lnkicon\">" +                 ~ " □ U.S. letter </a>] "; +    } else if (doc_matters.opt.action.html_link_pdf_a4) { +      metadata_ ~=  "[<a href=\"../../pdf/" +                 ~ doc_matters.src.filename_base +                 ~ "." ~ doc_matters.src.language ~ ".a4.portrait.pdf\" class=\"lnkicon\">" +                 ~ " □ pdf (a4) </a>] "; +    } else if (doc_matters.opt.action.html_link_pdf_letter) { +      metadata_ ~=  "[<a href=\"../../pdf/" +                 ~ doc_matters.src.filename_base +                 ~ "." ~ doc_matters.src.language ~ ".letter.portrait.pdf\" class=\"lnkicon\">" +                 ~ " □ pdf (U.S. letter) </a>] "; +    } +    metadata_ ~=  "</p>"; +    if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { +      metadata_ ~= "<hr /><p class=\"lev0\">Topics:</p>"; +      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_ ~= +                "<p class=\"lev1\"><a href=\"../../topics.html#" +                  ~ subject_tree[0].translate([' ' : "_"]) ~ "\">" +                  ~ subject_tree[0] +                  ~ "</a></p>"; +            } else { +              metadata_ ~= +                "<p class=\"lev1\">"  ~ subject_tree[0] ~ "</p>"; +            } +          } +          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_ ~= +                  "<p class=\"lev2\"><a href=\"../../topics.html#" +                    ~ subject_tree[0].translate([' ' : "_"]) ~ "." +                    ~ subject_tree[1].translate([' ' : "_"]) ~ "\">" +                    ~ subject_tree[1] +                    ~ "</a></p>"; +              } else { +                metadata_ ~= +                  "<p class=\"lev2\">"  ~ subject_tree[1] ~ "</p>"; +              } +            } +            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_ ~= +                    "<p class=\"lev3\"><a href=\"../../topics.html#" +                      ~ subject_tree[0].translate([' ' : "_"]) ~ "." +                      ~ subject_tree[1].translate([' ' : "_"]) ~ "." +                      ~ subject_tree[2].translate([' ' : "_"]) ~ "\">" +                      ~ subject_tree[2] +                      ~ "</a></p>"; +                } else { +                  metadata_ ~= +                    "<p class=\"lev3\">"  ~ subject_tree[2] ~ "</p>"; +                } +              } +              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_ ~= +                      "<p class=\"lev4\"><a href=\"../../topics.html#" +                        ~ subject_tree[0].translate([' ' : "_"]) ~ "." +                        ~ subject_tree[1].translate([' ' : "_"]) ~ "." +                        ~ subject_tree[2].translate([' ' : "_"]) ~ "." +                        ~ subject_tree[3].translate([' ' : "_"]) ~ "\">" +                        ~ subject_tree[3] +                        ~ "</a></p>"; +                  } else { +                    metadata_ ~= +                      "<p class=\"lev4\">"  ~ subject_tree[3] ~ "</p>"; +                  } +                } +                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_ ~= +                        "<p class=\"lev5\"><a href=\"../../topics.html#" +                          ~ subject_tree[0].translate([' ' : "_"]) ~ "." +                          ~ subject_tree[1].translate([' ' : "_"]) ~ "." +                          ~ subject_tree[2].translate([' ' : "_"]) ~ "." +                          ~ subject_tree[3].translate([' ' : "_"]) ~ "." +                          ~ subject_tree[4].translate([' ' : "_"]) ~ "\">" +                          ~ subject_tree[4] +                          ~ "</a></p>"; +                    } else { +                      metadata_ ~= +                        "<p class=\"lev5\">"  ~ subject_tree[4] ~ "</p>"; +                    } +                  } +                } +              } +            } +          } +        } +      } +    } 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"┃<text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +    ┃", +              _special_characters(tag_, obj), +              _special_characters(tag_, obj), +            ); +          } +        } +      } +      return _tags; +    } +    string _xhtml_anchor_tags(O)(O obj) { +      const(string[]) anchor_tags = obj.tags.anchor_tags; +      string tags=""; +      if (anchor_tags.length > 0) { +        foreach (tag; anchor_tags) { +          if (!(tag.empty)) { +            tags ~= "<a name=\"" ~ tag ~ "\"></a>"; +          } +        } +      } +      return tags; +    } +    string obj_num(O)(const O obj) { // TODO +      string _on; +      _on = (obj.metainfo.object_number.empty) +      ? "" +      : (format(q"┃ +      <text:span text:style-name="Span_subscript">「%s」</text:span>┃", +          obj.metainfo.object_number, +        )); +      return _on; +    } +    string _footnotes()(string _txt) { +      static auto rgx = RgxO(); +      static auto rgx_xhtml = RgxXHTML(); +      _txt = _txt.replaceAll( +        rgx.inline_notes_al_regular_number_note, +        format(q"┃<text:note text:id="ftn%s" text:note-class="footnote"> +      <text:note-citation> +        %s +      </text:note-citation> +      <text:note-body> +        <text:p text:style-name="Footnote"> +          %s +        </text:p> +      </text:note-body> +    </text:note>┃", +          "$1", "$1", "$2", +        ) +      ); +      return _txt; +    } +    string _bullet(O)(const O obj) { +      string _b = ""; +      if (obj.attrib.bullet) { +        _b = format(q"┃● ┃",); +      } +      return _b; +    } +    string _indent(O)(string _txt, const O obj) { // TODO +      // if (obj.attrib.indent_base > 0 || +      //   obj.attrib.indent_hang > 0 +      // ) { +      if (obj.metainfo.is_a == "toc") { +        _txt = format(q"┃ +    %s<text:h text:style-name="H_%s" text:outline-level="%s"> +      %s%s%s +    </text:h>┃", +          (obj.attrib.indent_base < 4) +          ? "<text:p text:style-name=\"Standard\"/>\n    " : "", +          obj.attrib.indent_base, +          obj.attrib.indent_base, +          _tags(obj), +          _txt, +          obj_num(obj), +        ); +      } else if (!empty(obj.metainfo.object_number)) { +        if (obj.attrib.indent_base == 0 && obj.attrib.indent_hang == 0) { +          _txt = format(q"┃ +    <text:p text:style-name="P_normal">%s +      <text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +      %s%s%s +    </text:p>┃", +            _bullet(obj), +            obj.metainfo.object_number, +            obj.metainfo.object_number, +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } else if (obj.attrib.indent_base == obj.attrib.indent_hang) { +          _txt = format(q"┃ +    <text:p text:style-name="P_indent_%s">%s +      <text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +      %s%s%s +    </text:p>┃", +            obj.attrib.indent_base, +            _bullet(obj), +            obj.metainfo.object_number, +            obj.metainfo.object_number, +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } else { +          _txt = format(q"┃ +    <text:p text:style-name="P_h%s_i%s">%s +      <text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +      %s%s%s +    </text:p>┃", +            obj.attrib.indent_base, +            obj.attrib.indent_hang, +            _bullet(obj), +            obj.metainfo.object_number, +            obj.metainfo.object_number, +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } +      } else { +        if (obj.attrib.indent_base == 0 && obj.attrib.indent_hang == 0) { /+ can omit and would explicitly set indent base and hang as 0 each below +/ +          _txt = format(q"┃ +    <text:p text:style-name="P_normal">%s +      %s%s%s +    </text:p>┃", +            _bullet(obj), +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } else if (obj.attrib.indent_base == obj.attrib.indent_hang) { +          _txt = format(q"┃ +    <text:p text:style-name="P_indent_%s">%s +      %s%s%s +    </text:p>┃", +            obj.attrib.indent_base, +            _bullet(obj), +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } else { +          _txt = format(q"┃ +    <text:p text:style-name="P_h%s_i%s">%s +      %s%s%s +    </text:p>┃", +            _bullet(obj), +            obj.attrib.indent_base, +            obj.attrib.indent_hang, +            _tags(obj), +            _txt, +            obj_num(obj), +          ); +        } +      } +      return _txt; +    } +    string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO +      string _block = ""; +      foreach (i, _line; _block_lines) { +        _line = _footnotes(_line); +        if (i == 0) { +          _block ~= format(q"┃ +    <text:p text:style-name="P_group">%s +        <text:span text:style-name="Span_subscript"> +          <text:bookmark-start text:name="%s"/> +          <text:bookmark-end text:name="%s"/> +        </text:span> +      %s +    </text:p>┃", +            _bullet(obj), +            obj.metainfo.object_number, +            obj.metainfo.object_number, +            // _tags(obj), +            _line, +          ); +        } else { +          _block ~= format(q"┃ +    <text:p text:style-name="P_group">%s</text:p>┃", +            _line); +        } +      } +      _block ~= format(q"┃ +    <text:p text:style-name="P_group"> +      <text:span text:style-name="Span_subscript">「%s」</text:span> +    </text:p> +    <text:p text:style-name="Standard"/>┃", +        obj_num(obj)); +      return _block; +    } +    string _special_characters(O)(string _txt, const O obj) { +      _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 _preserve_white_spaces(O)(string _txt, const O obj) { +      if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { +        _txt = _txt +          .replaceAll(rgx.space,      " "); +      } +      return _txt; +    } +    string _font_face(string _txt){ +      _txt = _txt +        .replaceAll(rgx.inline_strike,      "<del>$1</del>") +        .replaceAll(rgx.inline_insert,      "<ins>$1</ins>") +        .replaceAll(rgx.inline_cite,        "<cite>$1</cite>") +        .replaceAll(rgx.inline_emphasis,    format(q"┃<text:span text:style-name="Span_bold">%s</text:span>┃",       "$1")) +        .replaceAll(rgx.inline_bold,        format(q"┃<text:span text:style-name="Span_bold">%s</text:span>┃",       "$1")) +        .replaceAll(rgx.inline_italics,     format(q"┃<text:span text:style-name="Span_italic">%s</text:span>┃",     "$1")) +        .replaceAll(rgx.inline_underscore,  format(q"┃<text:span text:style-name="Span_underscore">%s</text:span>┃", "$1")) +        .replaceAll(rgx.inline_superscript, format(q"┃<text:span text:style-name="Span_superscript">%s</text:span>┃","$1")) +        .replaceAll(rgx.inline_subscript,   format(q"┃<text:span text:style-name="Span_subscript">%s</text:span>┃",  "$1")) +        .replaceAll(rgx.inline_mono,        format(q"┃<text:span text:style-name="Span_monospace">%s</text:span>┃",  "$1")); +      return _txt; +    } +    auto _obj_num(O)(O obj) { // NOT USED YET +      struct objNum { +        string reference() { +          return format(q"┃<text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span>┃", +            obj.object_number, +            obj.object_number, +          ); +        } +        string display() { +          return format(q"┃<text:span text:style-name="Span_subscript"> +      %s%s%s +      </text:span>┃", +            on_o, +            obj.object_number, +            on_c, +          ); +        } +      } +      return objNum(); +    } +    string _break_page()() { +      return format(q"┃ +    <text:p text:style-name="P_normal_page_new"/> +    ┃", +      ); +    } +    string _empty_line_break(O)(string _txt, const O obj) { +      if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { +        _txt = _txt +          .replaceAll(rgx.br_empty_line,    "<br />"); +      } +      return _txt; +    } +    string _links(O)(string _txt, const O obj) { +      if (obj.metainfo.is_a != "code") { +        if (obj.metainfo.is_a == "toc") { +          _txt = replaceAll!(m => +             m[1] ~ "┤" +             ~ (replaceAll!(n => +                 n["type"] ~ n["path"] ~ (n["file"].encodeComponent) +               )((obj.stow.link[m["num"].to!ulong]).to!string, rgx.uri_identify_components)) +             ~ "├" +          )(_txt, rgx.inline_link_number_only) +            .replaceAll(rgx.inline_link, +              format(q"┃<text:bookmark-ref text:reference-format="text" text:ref-name="%s">%s</text:bookmark-ref>┃", +                _special_characters("$3", obj), +                _special_characters("$1", obj) +              )); +        } else { +          _txt = replaceAll!(m => +             m[1] ~ "┤" +             ~ (replaceAll!(n => +                 n["type"] ~ n["path"] ~ (n["file"].encodeComponent) +               )((obj.stow.link[m["num"].to!ulong]).to!string, rgx.uri_identify_components)) +             ~ "├" +          )(_txt, rgx.inline_link_number_only) +            .replaceAll(rgx.inline_link, +              format(q"┃<text:a xl:type="simple" xl:href="%s">%s</text:a>┃", +                _special_characters("$2", obj), +                _special_characters("$1", obj) +              )); +        } +      } +      debug(links) { +        if (obj.text.match(rgx.inline_link_number) +          && _txt.match(rgx.inline_link_number_only) +        ) { +            writeln(">>    ", _txt); +            writeln("is_a: ", obj.metainfo.is_a); +        } +      } +      return _txt; +    } +    string _images(O)(string _txt, const O obj) { +      if (_txt.match(rgx.inline_image)) { +        _txt = _txt +          .replaceAll(rgx.inline_image, +            ("$1<draw:frame draw:style-name=\"fr1\" draw:name=\"graphics12\" text:anchor-type=\"as-char\" svg:width=\"$4px\" svg:height=\"$5px\" draw:z-index=\"2\"><draw:image xl:href=\"Pictures/$3\" xl:type=\"simple\" xl:show=\"embed\" xl:actuate=\"onLoad\"/></draw:frame> $6")) +          .replaceAll( +            rgx.inline_link_empty, +            ("$1")); +      } +      return _txt; +    } +    string markup(O)(const O obj) { +      /+ markup TODO +/ +      string _txt = obj.text; +      _txt = _special_characters(_txt, obj);     // TODO & why both obj & obj.text, consider also in output_xmls.org +      if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { +        _txt = replaceAll!(m => _preserve_white_spaces(m[1], obj))(_txt, rgx.spaces_keep); +      } // check that this does what you want, keep: leading spaces (indent) & more than single spaces within text +      // _txt = _preserve_white_spaces(_txt, obj);  // (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") +      _txt = _font_face(_txt); +      _txt = _images(_txt, obj);                  // (obj.metainfo.is_a != "code") +      _txt = _links(_txt, obj);                  // (obj.metainfo.is_a != "code") +      _txt = _empty_line_break(_txt, obj);       // (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") +      return _txt; +    } +    string heading(O,M)( +      const        O  obj, +      const        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          == "heading"); +      string _o_txt_odt = markup(obj); +      if (obj.metainfo.dummy_heading +        && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { +        _o_txt_odt = ""; +      } else if (obj.metainfo.is_a == "toc") { +        _o_txt_odt = format(q"┃%s<text:h text:style-name="H_%s" text:outline-level="%s"> +      %s%s%s +    </text:h>┃", +          _break_page, +          obj.metainfo.heading_lev_markup, +          obj.metainfo.heading_lev_markup, +          _tags(obj), +          _o_txt_odt, +          obj_num(obj), +        ); +      } else { +        _o_txt_odt = _footnotes(_o_txt_odt); +        _o_txt_odt = format(q"┃%s<text:h text:style-name="H_%s" text:outline-level="%s"> +      <text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +      %s%s%s +    </text:h>┃", +          _break_page, +          obj.metainfo.heading_lev_markup, +          obj.metainfo.heading_lev_markup, +          obj.metainfo.object_number, +          obj.metainfo.object_number, +          _tags(obj), +          _o_txt_odt, +          obj_num(obj), +        ); +      } +      return _o_txt_odt; +    } +    string para(O,M)( +      const        O  obj, +      const        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 _o_txt_odt; +      if (obj.metainfo.dummy_heading +        && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { +        _o_txt_odt = ""; +      } else { +        _o_txt_odt = markup(obj); +        _o_txt_odt = _footnotes(_o_txt_odt); +        _o_txt_odt = _indent(_o_txt_odt, obj); // final setting? +      } +      return _o_txt_odt; +    } +    string quote(O,M)( +      const        O  obj, +      const        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"); +      string _o_txt_odt = markup(obj); +      _o_txt_odt = _footnotes(_o_txt_odt); // decide +      return _o_txt_odt; +    } +    string group(O,M)( +      const        O  obj, +      const        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"); +      string _o_txt_odt = markup(obj); +      /+ TODO +        - split lines +          - only double newlines (paragraph delimiter), (not line breaks, single new lines) +        - no hard space indentation +      +/ +      string[] _block_lines = (_o_txt_odt).split(rgx.br_linebreaks_newlines); +      _o_txt_odt = _block_type_delimiters(_block_lines, obj); +      return _o_txt_odt; +    } +    string block(O,M)( +      const        O  obj, +      const        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"); +      string _o_txt_odt = markup(obj); +      string[] _block_lines = (_o_txt_odt).split(rgx.br_linebreaks_newlines); +      _o_txt_odt = _block_type_delimiters(_block_lines, obj); +      return _o_txt_odt; +    } +    string verse(O,M)( +      const        O  obj, +      const        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"); +      string _o_txt_odt = markup(obj); +      string[] _block_lines = (_o_txt_odt).split(rgx.br_linebreaks_newlines); +      _o_txt_odt = _block_type_delimiters(_block_lines, obj); +      return _o_txt_odt; +    } +    string code(O,M)( +      const        O  obj, +      const        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_txt_odt = markup(obj); +      /+ TODO +        - split lines +          - each line including empty lines +        - hard space indentation +          - "^[ ]"   +          - count number only at beginning of line and replace each +      +/ +      string[] _block_lines = (_o_txt_odt).split(rgx.br_linebreaks_newlines); +      string _block = ""; +      foreach (i, _line; _block_lines) { +        if (i == 1) { +          _block ~= format(q"┃ +    <text:p text:style-name="P_code"> +    <text:span text:style-name="Span_subscript"> +      <text:bookmark-start text:name="%s"/> +      <text:bookmark-end text:name="%s"/> +    </text:span> +    %s +    </text:p>┃", +            obj.metainfo.object_number, +            obj.metainfo.object_number, +            _line, +          ); +        } else { +          _block ~= format(q"┃ +    <text:p text:style-name="P_code">%s</text:p>┃", +            _line); +        } +      } +      _block ~= format(q"┃ +    <text:p text:style-name="P_group"> +      <text:span text:style-name="Span_subscript">「%s」</text:span> +    </text:p> +    <text:p text:style-name="Standard"/>┃", +         obj_num(obj)); +      _o_txt_odt = _block; +      return _o_txt_odt; +    } +    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 ~= "<table:table-row>"; +          foreach(col_idx, cell; _table_cols) { +            if ((_table_cols.length == 1) +            && (_table_rows.length <= row_idx+2)) { // check row_idx+2 (rather than == ++row_idx) +              _tablenote ~= cell; +            } else { +              _table ~= format(q"┃<table:table-cell office:value-type="string"> +    <text:p text:style-name="%s"> +    %s +    </text:p> +    </table:table-cell>┃", +                (row_idx == 0 && obj.table.heading) ? "Table_Heading" : "P_table_cell", +                cell, +              ); +            } +          } +          _table ~= "</table:table-row>"; +        } +      Tuple!(string, string) t = tuple( +        _table, +        _tablenote, +      ); +      return t; +    } +    int _table_number = 0; +    string table(O,M)( +      const        O  obj, +      const        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 _o_txt_odt = markup(obj); +      Tuple!(string, string) t = tablarize(obj, _o_txt_odt); +      string _note = t[1]; +      _o_txt_odt = format(q"┃ +    <table:table table:name="Table%s" table:style-name="Table1"> +      <text:span text:style-name="Span_subscript"> +        <text:bookmark-start text:name="%s"/> +        <text:bookmark-end text:name="%s"/> +      </text:span> +      <table:table-column table:style-name="Table1.D" table:number-columns-repeated="%s"/> +          %s +        </table:table> +        <text:p text:style-name="P_group"> +      <text:span text:style-name="Span_subscript">「%s」</text:span> +    </text:p>┃", +        _table_number++, +        obj.metainfo.object_number, +        obj.metainfo.object_number, +        obj.table.number_of_columns, +        t[0], +        obj.metainfo.object_number, +        // _note, +      ); +      return _o_txt_odt; +    } +  } +} +template outputODT() { +  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 InternalMarkup; +  mixin spineRgxOut; +  mixin spineRgxXHTML; +  static auto rgx = RgxO(); +  static auto rgx_xhtml = RgxXHTML(); +  // mixin outputXmlODT; +  string odt_head(I)(I doc_matters) { +    string _has_tables = format(q"┃ +    <style:style style:name="Table1" style:family="table"> +      <style:table-properties style:width="16.999cm" table:align="margins"/> +    </style:style> +    <style:style style:name="Table1.A" style:family="table-column"> +      <style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/> +    </style:style> +    <style:style style:name="Table1.B" style:family="table-column"> +      <style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/> +    </style:style> +    <style:style style:name="Table1.C" style:family="table-column"> +      <style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/> +    </style:style> +    <style:style style:name="Table1.D" style:family="table-column"> +      <style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/> +    </style:style> +    <style:style style:name="Table1.E" style:family="table-column"> +      <style:table-column-properties style:column-width="3.399cm" style:rel-column-width="13107*"/> +    </style:style> +    <style:style style:name="Table1.F" style:family="table-column"> +      <style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/> +    </style:style> +    <style:style style:name="Table1.G" style:family="table-column"> +      <style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/> +    </style:style> +    <style:style style:name="Table1.H" style:family="table-column"> +      <style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/> +    </style:style> +    <style:style style:name="Table2" style:family="table"> +      <style:table-properties style:width="16.999cm" table:align="margins"/> +    </style:style> +    <style:style style:name="Table2.A" style:family="table-column"> +      <style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/> +    </style:style> +    <style:style style:name="Table2.B" style:family="table-column"> +      <style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/> +    </style:style> +    <style:style style:name="Table2.C" style:family="table-column"> +      <style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/> +    </style:style> +    <style:style style:name="Table2.D" style:family="table-column"> +      <style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/> +    </style:style> +    <style:style style:name="Table2.E" style:family="table-column"> +      <style:table-column-properties style:column-width="3.999cm" style:rel-column-width="13107*"/> +    </style:style> +    <style:style style:name="Table2.F" style:family="table-column"> +      <style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/> +    </style:style> +    <style:style style:name="Table2.G" style:family="table-column"> +      <style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/> +    </style:style> +    <style:style style:name="Table2.H" style:family="table-column"> +      <style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/> +    </style:style> +    <style:style style:name="Table2.I" style:family="table-column"> +      <style:table-column-properties style:column-width="1.8887cm" style:rel-column-width="7281*"/> +    </style:style> +    <style:style style:name="Table2.J" style:family="table-column"> +      <style:table-column-properties style:column-width="1.6999cm" style:rel-column-width="6553*"/> +    </style:style> +    <style:style style:name="Table2.K" style:family="table-column"> +      <style:table-column-properties style:column-width="1.5453cm" style:rel-column-width="5957*"/> +    </style:style> +    <style:style style:name="Table2.L" style:family="table-column"> +      <style:table-column-properties style:column-width="1.416cm" style:rel-column-width="5461*"/> +    </style:style> +    <style:style style:name="Table2.M" style:family="table-column"> +      <style:table-column-properties style:column-width="1.307" style:rel-column-width="5041*"/> +    </style:style> +    <style:style style:name="Table2.N" style:family="table-column"> +      <style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/> +    </style:style> +  ┃",); +    string _odt_head = format(q"┃<?xml version="1.0" encoding="UTF-8"?> +  <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="https://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="https://openoffice.org/2004/office" xmlns:ooow="https://openoffice.org/2004/writer" xmlns:oooc="https://openoffice.org/2004/calc" xmlns:dom="https://www.w3.org/2001/xml-events" xmlns:xforms="https://www.w3.org/2002/xforms" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="https://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="https://www.w3.org/1999/xhtml" xmlns:grddl="https://www.w3.org/2003/g/data-view#" xmlns:tableooo="https://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="https://www.w3.org/TR/css3-text/" office:version="1.2"> +  <office:scripts/> +  <office:font-face-decls> +  <style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/> +  <style:font-face style:name="Inconsolata" svg:font-family="Inconsolata" style:font-adornments="Regular" style:font-pitch="fixed"/> +  <style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-adornments="Regular" style:font-family-generic="modern" style:font-pitch="fixed"/> +  <style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-adornments="ExtraLight" style:font-family-generic="swiss" style:font-pitch="variable"/> +  <style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/> +  <style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, 'Lucida Sans', 'Arial Unicode MS'" style:font-pitch="variable"/> +  <style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/> +  <style:font-face style:name="Bitstream Vera Sans" svg:font-family="'Bitstream Vera Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> +  </office:font-face-decls> +  <office:automatic-styles> +    %s +    <style:style style:name="P_table_cell" style:family="paragraph" style:parent-style-name="Table_Contents"> +      <style:paragraph-properties fo:text-align="justify" style:justify-single-word="false"/> +    </style:style> +  </office:automatic-styles> +  <office:body> +    <office:text text:use-soft-page-breaks="true"> +      <office:forms form:automatic-focus="false" form:apply-design-mode="false"/> +      <text:sequence-decls> +        <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> +        <text:sequence-decl text:display-outline-level="0" text:name="Table"/> +        <text:sequence-decl text:display-outline-level="0" text:name="Text"/> +        <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> +      </text:sequence-decls> +  ┃", +    (doc_matters.has.tables > 0) ? _has_tables : "", +  ); +    return _odt_head; +  } +  string odt_body(D,I)( +    const D    doc_abstraction, +          I    doc_matters, +  ) { +    mixin formatODT; +    auto odt_format = formatODT(); +    string delimit = ""; +    string doc_odt = ""; +    string _txt = ""; +    foreach (part; doc_matters.has.keys_seq.scroll) { +      foreach (obj; doc_abstraction[part]) { +        switch (obj.metainfo.is_of_part) { +        case "frontmatter":              assert(part == "head" || "toc"); +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              _txt = delimit ~ odt_format.heading(obj, doc_matters); +              goto default; +            case "toc": +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            default: +              doc_odt ~= _txt; +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "body":                     assert(part == "body" || "head"); // surprise +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              _txt = delimit ~ odt_format.heading(obj, doc_matters); +              goto default; +            case "para": +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            default: +              doc_odt ~= _txt; +              _txt = ""; +              break; +            } +            break; +          case "block": +            switch (obj.metainfo.is_a) { +            case "quote": +              _txt = odt_format.quote(obj, doc_matters); +              goto default; +            case "group": +              _txt = odt_format.group(obj, doc_matters); +              goto default; +            case "block": +              _txt = odt_format.block(obj, doc_matters); +              goto default; +            case "verse": +              _txt = odt_format.verse(obj, doc_matters); +              goto default; +            case "code": +              _txt = odt_format.code(obj, doc_matters); +              goto default; +            case "table": +              _txt = odt_format.table(obj, doc_matters); +              goto default; +            default: +              doc_odt ~= _txt; +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "backmatter": +          assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); +          switch (obj.metainfo.is_of_type) { +          case "para": +            switch (obj.metainfo.is_a) { +            case "heading": +              _txt = delimit ~ odt_format.heading(obj, doc_matters); +              goto default; +            case "endnote":              assert(part == "endnotes"); +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            case "glossary":             assert(part == "glossary"); +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            case "bibliography":         assert(part == "bibliography"); +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            case "bookindex":            assert(part == "bookindex"); +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            case "blurb":                assert(part == "blurb"); +              _txt = odt_format.para(obj, doc_matters); +              goto default; +            default: +              doc_odt ~= _txt; +              _txt = ""; +              break; +            } +            break; +          default: break; +          } +          break; +        case "comment": +          break; +        default: +          { /+ debug +/ +            if (doc_matters.opt.action.debug_do +            && doc_matters.opt.action.vox_gt1) { +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); +              writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); +              writeln(__FILE__, ":", __LINE__, ": ", obj.text); +            } +          } +          break; +        } +      } +    } +    return doc_odt; +  } +   +  string odt_tail() { +    string _odt_tail = format(q"┃<text:p text:style-name="P_normal">spine: <<text:a xl:type="simple" xl:href="https://www.sisudoc.org">www.sisudoc.org</text:a>> and <<text:a xl:type="simple" xl:href="https://www.sisudoc.org">www.sisudoc.org</text:a>></text:p> +  </office:text></office:body></office:document-content>┃",); +    return _odt_tail; +  } +  string content_xml(D,I)( +    const D    doc_abstraction, +          I    doc_matters, +  ) { +    string _content_xml; +    string break_line = (doc_matters.opt.action.debug_do) ? "\n" : ""; +    string odt_break_page = format(q"┃<text:p text:style-name="P_normal_page_new"/>┃",); +    string br_pg          = format(q"┃<text:p text:style-name="P_normal_page_new"/>┃",); +    _content_xml ~= odt_head(doc_matters); +    _content_xml ~= odt_body(doc_abstraction, doc_matters); +    _content_xml ~= odt_tail; +    return _content_xml; +  } +  string manifest_xml(M)( +    auto ref              M    doc_matters, +  ) { +    string _bullet = format(q"┃<manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/bullet_09.png"/>┃"); +    string[] _images = [ _bullet ]; +    foreach (image; doc_matters.srcs.image_list) { +      _images ~= format(q"┃    <manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/%s"/>┃", image); +    } +    string _manifest_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?> +  <manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"> +    <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.text" manifest:version="1.2" manifest:full-path="/"/> +    <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/> +    <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/> +    %s +    <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/> +    <manifest:file-entry manifest:media-type="application/rdf+xml" manifest:full-path="manifest.rdf"/> +    <manifest:file-entry manifest:media-type="application/binary" manifest:full-path="layout-cache"/> +    <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="settings.xml"/> +  </manifest:manifest> +  ┃", +  _images.join("\n"), +  ); +    return _manifest_xml; +  } +  void images_cp(M)( +    auto ref              M    doc_matters, +  ) { +    { /+ (copy odt images) +/ +      import sisudoc.io_out.paths_output; +      auto pth_odt = spinePathsODT!()(doc_matters); +      foreach (image; doc_matters.srcs.image_list) { +        auto fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; +        auto fn_src_out_file = pth_odt.image_dir("fs") ~ "/" ~ image; +        auto fn_src_out_zip = pth_odt.image_dir("zip") ~ "/" ~ image; +        if (exists(fn_src_in)) { +          if (doc_matters.opt.action.debug_do) { +            if (doc_matters.opt.action.debug_do) { +              fn_src_in.copy(fn_src_out_file); +            } +          } +        } +      } +    } +    // return 0; +  } +  string meta_xml(M)( +    auto ref              M    doc_matters, +  ) { +    /+ (meta_xml includes output time-stamp) +/ +    string _meta_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?> +  <office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="https://openoffice.org/2004/office" xmlns:grddl="https://www.w3.org/2003/g/data-view#" office:version="1.2"> +    <office:meta> +      <meta:generator>%s</meta:generator> +      <meta:creation-date>%s</meta:creation-date> +      <dc:date>%s</dc:date> +      <dc:language>en-US</dc:language> +    </office:meta> +  </office:document-meta> +  ┃", +  doc_matters.generator_program.name_and_version, +  doc_matters.generated_time, +  doc_matters.generated_time, +  ); +    return _meta_xml; +  } +  void dirtree(I)( +    I   doc_matters, +  ) { +    import sisudoc.io_out.paths_output; +    auto pth_odt = spinePathsODT!()(doc_matters); +    if (doc_matters.opt.action.debug_do) { /+ (dir tree) +/ +      if (!exists(pth_odt.meta_inf_dir("fs"))) { +        pth_odt.meta_inf_dir("fs").mkdirRecurse; +      } +      if (!exists(pth_odt.image_dir("fs"))) { +        pth_odt.image_dir("fs").mkdirRecurse; +      } +    } +    if (!exists(pth_odt.base_pth)) { +      pth_odt.base_pth.mkdirRecurse; +    } +    if (!exists(pth_odt.base_pth ~ "/index.html")) { +      import sisudoc.io_out.html_snippet; +      mixin htmlSnippet; +      auto f = File(pth_odt.base_pth ~"/index.html", "w"); +      f.writeln(format_html_blank_page_guide_home( +        "../../css/html_scroll.css", +        "https://sisudoc.org", +        "../../index.html", +      )); +    } +    // return 0; +  } +  string mimetype() { +    string mimetype_ = format(q"┃application/vnd.oasis.opendocument.text┃"); +    return mimetype_; +  } +  string manifest_rdf() { +    string _manifest_rdf = format(q"┃<?xml version="1.0" encoding="utf-8"?> +  <rdf:RDF xmlns:rdf="https://www.w3.org/1999/02/22-rdf-syntax-ns#"> +    <rdf:Description rdf:about="styles.xml"> +      <rdf:type rdf:resource="https://docs.oasis-open.org/ns/office/1.2/meta/odf#StylesFile"/> +    </rdf:Description> +    <rdf:Description rdf:about=""> +      <ns0:hasPart xmlns:ns0="https://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="styles.xml"/> +    </rdf:Description> +    <rdf:Description rdf:about="content.xml"> +      <rdf:type rdf:resource="https://docs.oasis-open.org/ns/office/1.2/meta/odf#ContentFile"/> +    </rdf:Description> +    <rdf:Description rdf:about=""> +      <ns0:hasPart xmlns:ns0="https://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="content.xml"/> +    </rdf:Description> +    <rdf:Description rdf:about=""> +      <rdf:type rdf:resource="https://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document"/> +    </rdf:Description> +  </rdf:RDF> +  ┃"); +    return _manifest_rdf; +  } +  string settings_xml() { +    string _settings_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?> +  <office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="https://openoffice.org/2004/office" office:version="1.2"> +    <office:settings> +      <config:config-item-set config:name="ooo:view-settings"> +        <config:config-item config:name="ViewAreaTop" config:type="int">0</config:config-item> +        <config:config-item config:name="ViewAreaLeft" config:type="int">0</config:config-item> +        <config:config-item config:name="ViewAreaWidth" config:type="int">0</config:config-item> +        <config:config-item config:name="ViewAreaHeight" config:type="int">0</config:config-item> +        <config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item> +        <config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item> +        <config:config-item-map-indexed config:name="Views"> +          <config:config-item-map-entry> +            <config:config-item config:name="ViewId" config:type="string">view2</config:config-item> +            <config:config-item config:name="ViewLeft" config:type="int">0</config:config-item> +            <config:config-item config:name="ViewTop" config:type="int">0</config:config-item> +            <config:config-item config:name="VisibleLeft" config:type="int">0</config:config-item> +            <config:config-item config:name="VisibleTop" config:type="int">0</config:config-item> +            <config:config-item config:name="VisibleRight" config:type="int">0</config:config-item> +            <config:config-item config:name="VisibleBottom" config:type="int">0</config:config-item> +            <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> +            <config:config-item config:name="ViewLayoutColumns" config:type="short">2</config:config-item> +            <config:config-item config:name="ViewLayoutBookMode" config:type="boolean">true</config:config-item> +            <config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item> +            <config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item> +          </config:config-item-map-entry> +        </config:config-item-map-indexed> +      </config:config-item-set> +      <config:config-item-set config:name="ooo:configuration-settings"> +        <config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item> +        <config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item> +        <config:config-item config:name="MathBaselineAlignment" config:type="boolean">false</config:config-item> +        <config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item> +        <config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">false</config:config-item> +        <config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item> +        <config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item> +        <config:config-item config:name="CurrentDatabaseCommand" config:type="string"/> +        <config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item> +        <config:config-item config:name="SmallCapsPercentage66" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item> +        <config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item> +        <config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item> +        <config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item> +        <config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintEmptyPages" config:type="boolean">true</config:config-item> +        <config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item> +        <config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">false</config:config-item> +        <config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item> +        <config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item> +        <config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item> +        <config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">true</config:config-item> +        <config:config-item config:name="UpdateFromTemplate" config:type="boolean">false</config:config-item> +        <config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintSingleJobs" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item> +        <config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item> +        <config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item> +        <config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">true</config:config-item> +        <config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/> +        <config:config-item config:name="PrinterSetup" config:type="base64Binary"/> +        <config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item> +        <config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrinterName" config:type="string"/> +        <config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item> +        <config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item> +        <config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item> +        <config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item> +        <config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">true</config:config-item> +        <config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintFaxName" config:type="string"/> +        <config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item> +        <config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item> +        <config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item> +        <config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item> +        <config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item> +        <config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item> +        <config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item> +        <config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/> +        <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item> +        <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item> +        <config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item> +        <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item> +        <config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item> +        <config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item> +      </config:config-item-set> +    </office:settings> +  </office:document-settings> +  ┃"); +    return _settings_xml; +  } +  string styles_xml() { +    string _styles_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?> +  <office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="https://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="https://openoffice.org/2004/office" xmlns:ooow="https://openoffice.org/2004/writer" xmlns:oooc="https://openoffice.org/2004/calc" xmlns:dom="https://www.w3.org/2001/xml-events" xmlns:rpt="https://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="https://www.w3.org/1999/xhtml" xmlns:grddl="https://www.w3.org/2003/g/data-view#" xmlns:tableooo="https://openoffice.org/2009/table" xmlns:css3t="https://www.w3.org/TR/css3-text/" office:version="1.2"> +    <office:font-face-decls> +      <style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/> +      <style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/> +      <style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, 'Lucida Sans', 'Arial Unicode MS'" style:font-pitch="variable"/> +      <style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/> +      <style:font-face style:name="Bitstream Vera Sans" svg:font-family="'Bitstream Vera Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> +    </office:font-face-decls> +    <office:styles> +      <style:default-style style:family="graphic"> +        <style:graphic-properties fo:wrap-option="wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> +        <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> +          <style:tab-stops/> +        </style:paragraph-properties> +        <style:text-properties style:use-window-font-color="true" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/> +      </style:default-style> +      <style:default-style style:family="paragraph"> +        <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> +        <style:text-properties style:use-window-font-color="true" style:font-name="Nimbus Roman No9 L" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-name-asian="Nimbus Sans L" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Nimbus Sans L" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> +      </style:default-style> +      <style:default-style style:family="table"> +        <style:table-properties table:border-model="collapsing"/> +      </style:default-style> +      <style:default-style style:family="table-row"> +        <style:table-row-properties fo:keep-together="auto"/> +      </style:default-style> +      <style:style style:name="Standard" style:family="paragraph" style:class="text"/> +      <style:style style:name="Text_body" style:display-name="Text body" style:family="paragraph" style:class="text"> +        <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm"/> +      </style:style> +      <style:style style:name="P_page_break" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:break-before="page"/> +      </style:style> +      <style:style style:name="P_normal" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:text-align="justify" style:justify-single-word="false"/> +      </style:style> +      <style:style style:name="P_normal_page_new" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:break-after="page"/> +      </style:style> +      <style:style style:name="P_indent_0" style:display-name="Paragraph indent 0" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:text-align="justify" style:justify-single-word="false"/> +      </style:style> +      <style:style style:name="P_indent_1" style:display-name="Paragraph indent 1" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="1cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_2" style:display-name="Paragraph indent 2" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="2cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_3" style:display-name="Paragraph indent 3" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="3cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_4" style:display-name="Paragraph indent 4" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="4cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_5" style:display-name="Paragraph indent 5" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="5cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_6" style:display-name="Paragraph indent 6" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="6cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_7" style:display-name="Paragraph indent 7" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="7cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_8" style:display-name="Paragraph indent 8" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="8cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_indent_9" style:display-name="Paragraph indent 9" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%%" fo:margin-left="9cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/> +      </style:style> +      <style:style style:name="P_h0_i0" style:display-name="Hang 0 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i1" style:display-name="Hang 0 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i2" style:display-name="Hang 0 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i3" style:display-name="Hang 0 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i4" style:display-name="Hang 0 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i5" style:display-name="Hang 0 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i6" style:display-name="Hang 0 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i7" style:display-name="Hang 0 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i8" style:display-name="Hang 0 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-8cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h0_i9" style:display-name="Hang 0 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-9cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i0" style:display-name="Hang 1 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i1" style:display-name="Hang 1 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i2" style:display-name="Hang 1 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i3" style:display-name="Hang 1 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i4" style:display-name="Hang 1 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i5" style:display-name="Hang 1 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i6" style:display-name="Hang 1 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i7" style:display-name="Hang 1 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i8" style:display-name="Hang 1 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h1_i9" style:display-name="Hang 1 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-8cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i0" style:display-name="Hang 2 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i1" style:display-name="Hang 2 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i2" style:display-name="Hang 2 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i3" style:display-name="Hang 2 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i4" style:display-name="Hang 2 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i5" style:display-name="Hang 2 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i6" style:display-name="Hang 2 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i7" style:display-name="Hang 2 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i8" style:display-name="Hang 2 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h2_i9" style:display-name="Hang 2 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i0" style:display-name="Hang 3 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i1" style:display-name="Hang 3 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i2" style:display-name="Hang 3 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i3" style:display-name="Hang 3 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i4" style:display-name="Hang 3 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i5" style:display-name="Hang 3 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i6" style:display-name="Hang 3 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i7" style:display-name="Hang 3 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i8" style:display-name="Hang 3 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h3_i9" style:display-name="Hang 3 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i0" style:display-name="Hang 4 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i1" style:display-name="Hang 4 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i2" style:display-name="Hang 4 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i3" style:display-name="Hang 4 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i4" style:display-name="Hang 4 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i5" style:display-name="Hang 4 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i6" style:display-name="Hang 4 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i7" style:display-name="Hang 4 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i8" style:display-name="Hang 4 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h4_i9" style:display-name="Hang 4 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i0" style:display-name="Hang 5 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i1" style:display-name="Hang 5 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i2" style:display-name="Hang 5 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i3" style:display-name="Hang 5 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i4" style:display-name="Hang 5 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i5" style:display-name="Hang 5 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i6" style:display-name="Hang 5 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i7" style:display-name="Hang 5 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i8" style:display-name="Hang 5 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h5_i9" style:display-name="Hang 5 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i0" style:display-name="Hang 6 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i1" style:display-name="Hang 6 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i2" style:display-name="Hang 6 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i3" style:display-name="Hang 6 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i4" style:display-name="Hang 6 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i5" style:display-name="Hang 6 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i6" style:display-name="Hang 6 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i7" style:display-name="Hang 6 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i8" style:display-name="Hang 6 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h6_i9" style:display-name="Hang 6 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i0" style:display-name="Hang 7 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i1" style:display-name="Hang 7 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i2" style:display-name="Hang 7 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i3" style:display-name="Hang 7 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i4" style:display-name="Hang 7 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i5" style:display-name="Hang 7 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i6" style:display-name="Hang 7 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i7" style:display-name="Hang 7 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i8" style:display-name="Hang 7 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h7_i9" style:display-name="Hang 7 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i0" style:display-name="Hang 8 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="8cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i1" style:display-name="Hang 8 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i2" style:display-name="Hang 8 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i3" style:display-name="Hang 8 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i4" style:display-name="Hang 8 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i5" style:display-name="Hang 8 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i6" style:display-name="Hang 8 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i7" style:display-name="Hang 8 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i8" style:display-name="Hang 8 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h8_i9" style:display-name="Hang 8 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="-1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i0" style:display-name="Hang 9 Indent 0" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="9cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i1" style:display-name="Hang 9 Indent 1" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="8cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i2" style:display-name="Hang 9 Indent 2" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="7cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i3" style:display-name="Hang 9 Indent 3" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="3cm" fo:margin-right="0cm" fo:text-indent="6cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i4" style:display-name="Hang 9 Indent 4" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="4cm" fo:margin-right="0cm" fo:text-indent="5cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i5" style:display-name="Hang 9 Indent 5" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="5cm" fo:margin-right="0cm" fo:text-indent="4cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i6" style:display-name="Hang 9 Indent 6" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="6cm" fo:margin-right="0cm" fo:text-indent="3cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i7" style:display-name="Hang 9 Indent 7" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="7cm" fo:margin-right="0cm" fo:text-indent="2cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i8" style:display-name="Hang 9 Indent 8" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="8cm" fo:margin-right="0cm" fo:text-indent="1cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="P_h9_i9" style:display-name="Hang 9 Indent 9" style:family="paragraph" style:parent-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-left="9cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"> +        <style:tab-stops> +        <style:tab-stop style:position="0cm"/> +        </style:tab-stops> +        </style:paragraph-properties> +      </style:style> +      <style:style style:name="Span_bold" style:family="text"> +        <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="Span_italic" style:family="text"> +        <style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/> +      </style:style> +      <style:style style:name="Span_underscore" style:family="text"> +        <style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color"/> +      </style:style> +      <style:style style:name="Span_superscript" style:family="text"> +        <style:text-properties style:text-position="super 58%%"/> +      </style:style> +      <style:style style:name="Span_subscript" style:family="text"> +        <style:text-properties style:text-position="sub 58%%"/> +      </style:style> +      <style:style style:name="Span_monospace" style:family="text"> +        <style:text-properties style:font-name="DejaVu Sans Mono" fo:font-size="10pt" fo:font-weight="normal" fo:background-color="#e6e6e6"/> +      </style:style> +      <style:style style:name="Heading" style:family="paragraph" style:next-style-name="Text_body" style:class="text"> +        <style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/> +        <style:text-properties style:font-name="Bitstream Vera Sans" fo:font-size="14pt" style:font-size-asian="14pt" style:font-name-complex="Tahoma" style:font-size-complex="14pt"/> +      </style:style> +      <style:style style:name="H_1" style:display-name="Heading 1" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="1" style:class="text"> +        <style:text-properties fo:font-size="120%%" fo:font-weight="bold" style:font-size-asian="120%%" style:font-weight-asian="bold" style:font-size-complex="115%%" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="H_2" style:display-name="Heading 2" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="2" style:class="text"> +        <style:text-properties fo:font-size="115%%" fo:font-weight="bold" style:font-size-asian="115%%" style:font-weight-asian="bold" style:font-size-complex="115%%" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="H_3" style:display-name="Heading 3" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="3" style:class="text"> +        <style:text-properties fo:font-size="110%%" fo:font-weight="bold" style:font-size-asian="110%%" style:font-weight-asian="bold" style:font-size-complex="115%%" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="H_4" style:display-name="Heading 4" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="4" style:class="text"> +        <style:text-properties fo:font-size="12pt" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="12pt" style:font-style-complex="italic" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="H_5" style:display-name="Heading 5" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="5" style:class="text"> +        <style:text-properties fo:font-size="90%%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="90%%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="90%%" style:font-style-complex="italic" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="H_6" style:display-name="Heading 6" style:family="paragraph" style:next-style-name="Text_body" style:default-outline-level="6" style:class="text"> +        <style:text-properties fo:font-size="80%%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="80%%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="80%%" style:font-style-complex="italic" style:font-weight-complex="bold"/> +      </style:style> +      <style:style style:name="P_group" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%%" fo:text-align="justify" style:justify-single-word="false"/> +      </style:style> +      <style:style style:name="P_code" style:family="paragraph" style:parent-style-name="Standard"> +        <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%%" fo:text-align="start" style:justify-single-word="false"/> +        <style:text-properties style:font-name="DejaVu Sans Mono" fo:font-size="9pt" fo:font-weight="normal" fo:background-color="#e6e6e6"/> +      </style:style> +      <style:style style:name="Footnote" style:family="paragraph" style:class="extra"> +        <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/> +        <style:text-properties fo:font-size="10pt" style:font-size-asian="10pt" style:font-size-complex="10pt"/> +      </style:style> +      <style:style style:name="Table_Contents" style:display-name="Table Contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"> +        <style:paragraph-properties text:number-lines="false" text:line-number="0"/> +      </style:style> +      <style:style style:name="Footnote_symbol" style:display-name="Footnote Symbol" style:family="text"/> +      <style:style style:name="Footnote_anchor" style:display-name="Footnote Anchor" style:family="text"> +        <style:text-properties style:text-position="super 58%%"/> +      </style:style> +      <style:style style:name="Internet_link" style:display-name="Internet link" style:family="text"> +        <style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/> +      </style:style> +      <style:style style:name="Graphics" style:family="graphic"> +        <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/> +      </style:style> +      <text:outline-style style:name="Outline"> +        <text:outline-level-style text:level="1" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="2" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="3" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="4" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="5" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="6" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="7" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="8" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="9" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      <text:outline-level-style text:level="10" style:num-format=""> +        <style:list-level-properties text:min-label-distance="0.381cm"/> +      </text:outline-level-style> +      </text:outline-style> +      <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_symbol" text:citation-body-style-name="Footnote_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> +      <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> +      <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> +      <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"> +        <style:graphic-properties style:wrap="none" style:horizontal-pos="left" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:luminance="0%%" draw:contrast="0%%" draw:red="0%%" draw:green="0%%" draw:blue="0%%" draw:gamma="100%%" draw:color-inversion="false" draw:image-opacity="100%%" draw:color-mode="standard"/> +      </style:style> +      <style:style style:name="gr1" style:family="graphic"> +        <style:graphic-properties draw:stroke="none" draw:fill="none" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" draw:color-mode="standard" draw:luminance="0%%" draw:contrast="0%%" draw:gamma="100%%" draw:red="0%%" draw:green="0%%" draw:blue="0%%" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:image-opacity="100%%" style:mirror="none" style:run-through="background" style:wrap="none" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" style:flow-with-text="false"/> +      </style:style> +      <style:style style:name="gr2" style:family="graphic"> +        <style:graphic-properties draw:stroke="none" draw:fill="none" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" draw:color-mode="standard" draw:luminance="0%%" draw:contrast="0%%" draw:gamma="100%%" draw:red="0%%" draw:green="0%%" draw:blue="0%%" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:image-opacity="100%%" style:mirror="none" style:run-through="background" style:wrap="none" style:vertical-pos="middle" style:vertical-rel="baseline" style:horizontal-pos="left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" style:flow-with-text="false"/> +      </style:style> +      </office:styles> +      <office:automatic-styles> +      <style:page-layout style:name="Mpm1"> +      <style:page-layout-properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm"> +      <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%%" style:color="#000000"/> +      </style:page-layout-properties> +      <style:header-style/> +      <style:footer-style/> +      </style:page-layout> +    </office:automatic-styles> +    <office:master-styles> +      <style:master-page style:name="Standard" style:page-layout-name="Mpm1"/> +    </office:master-styles> +  </office:document-styles> +  ┃"); +    return _styles_xml; +  } +  @trusted void writeOutputODT(W,I)( +    const W    odt_content, +          I    doc_matters, +  ) { +    auto pth_odt = spinePathsODT!()(doc_matters); +    auto fn_odt = pth_odt.odt_file; +    auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive(); +    void ODTzip()(string contents, string fn) { +      auto zip_arc_member_file = new ArchiveMember(); +      zip_arc_member_file.name = fn; +      auto zip_data = new OutBuffer(); +      (doc_matters.opt.action.debug_do) +      ? zip_data.write(contents.dup) +      : zip_data.write(contents.dup +        .replaceAll(rgx.spaces_line_start, "") +        .replaceAll(rgx.newline, "") +        .strip +      ); +      zip_arc_member_file.expandedData = zip_data.toBytes(); +      zip.addMember(zip_arc_member_file); +      createZipFile!()(fn_odt, zip.build()); +    } +    try { +      if (!exists(pth_odt.base_pth)) { // check +        pth_odt.base_pth.mkdirRecurse; +      } +      { +        string fn; +        File f; +        { fn = pth_odt.mimetype("zip"); +          ODTzip(odt_content.mimetype, fn); +        } +        { fn = pth_odt.manifest_rdf("zip"); +          ODTzip(odt_content.manifest_rdf, fn); +        } +        { fn = pth_odt.settings_xml("zip"); +          ODTzip(odt_content.settings_xml, fn); +        } +        { fn = pth_odt.styles_xml("zip"); +          ODTzip(odt_content.styles_xml, fn); +        } +        { fn = pth_odt.content_xml("zip"); +          ODTzip(odt_content.content_xml, fn); +        } +        { fn = pth_odt.manifest_xml("zip"); +          ODTzip(odt_content.manifest_xml, fn); +        } +        { fn = pth_odt.meta_xml("zip"); +          ODTzip(odt_content.meta_xml, fn); +        } +        { /+ (images) +/ +          foreach (image; doc_matters.srcs.image_list) { +            auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; +            auto fn_out = pth_odt.image_dir("zip") ~ "/" ~ image; +            if (exists(fn_src)) { +              { +                auto zip_arc_member_file = new ArchiveMember(); +                zip_arc_member_file.name = fn_out; +                auto zip_data = new OutBuffer(); +                zip_data.write(cast(char[]) ((fn_src).read)); // trusted? +                zip_arc_member_file.expandedData = zip_data.toBytes(); +                zip.addMember(zip_arc_member_file); +                createZipFile!()(fn_odt, zip.build()); +              } +            } +          } +        } +        if (doc_matters.opt.action.vox_gt0) { +          writeln(" ", pth_odt.odt_file); +        } +      } +      if (!exists(pth_odt.base_pth ~ "/index.html")) { +        import sisudoc.io_out.html_snippet; +        mixin htmlSnippet; +        auto f = File(pth_odt.base_pth ~"/index.html", "w"); +        f.writeln(format_html_blank_page_guide_home( +          "../../css/html_scroll.css", +          (doc_matters.opt.action.webserver_url_doc_root.length > 0) +            ? doc_matters.opt.action.webserver_url_doc_root +            : doc_matters.conf_make_meta.conf.w_srv_data_root_url, +          "../../index.html", +        )); +      } +    } catch (ErrnoException ex) { +      // Handle error +    } +    if (doc_matters.opt.action.debug_do) { +      pth_odt.mimetype("fs");     /+ (mimetype) +/ +      pth_odt.manifest_rdf("fs"); /+ (manifest.rdf) +/ +      pth_odt.settings_xml("fs"); /+ (settings.xml) +/ +      pth_odt.styles_xml("fs");   /+ (styles_xml) +/ +   +      pth_odt.content_xml("fs"); +      pth_odt.manifest_xml("fs"); +      pth_odt.meta_xml("fs"); +    } +  } +  void outputODT(D,I)( +    const    D   doc_abstraction, +             I   doc_matters, +  ) { +    struct ODT { +    /+ fixed output +/ +      string mimetype; +      string manifest_rdf; +      string settings_xml; +      string styles_xml; +    /+ variable output +/ +      string content_xml;    // substantive content +      string manifest_xml;   // image list changes +      string meta_xml;       // time stamp +    } +    // auto pth_odt          = spinePathsODT!()(doc_matters); +    auto odt         = ODT(); +    odt.mimetype     = mimetype; +    odt.manifest_rdf = manifest_rdf; +    odt.settings_xml = settings_xml; +    odt.styles_xml   = styles_xml; +    odt.content_xml  = content_xml(doc_abstraction, doc_matters); +    odt.manifest_xml = manifest_xml(doc_matters); +    odt.meta_xml     = meta_xml(doc_matters); +    odt.writeOutputODT(doc_matters); +    dirtree(doc_matters); +    images_cp(doc_matters);                       // copy images +  } +} diff --git a/src/sisudoc/io_out/package.d b/src/sisudoc/io_out/package.d new file mode 100644 index 0000000..5c73cb9 --- /dev/null +++ b/src/sisudoc/io_out/package.d @@ -0,0 +1,69 @@ +/+ +- 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; +public import +  std.algorithm, +  std.array, +  std.container, +  std.exception, +  std.path, +  std.process, +  std.range, +  std.regex, +  std.stdio, +  std.string, +  std.typecons, +  // std.uni, +  std.utf; +public import +  sisudoc.share.defaults, +  sisudoc.io_in.paths_source, +  sisudoc.io_out.defaults, +  sisudoc.io_out.paths_output; diff --git a/src/sisudoc/io_out/paths_output.d b/src/sisudoc/io_out/paths_output.d new file mode 100644 index 0000000..f134f41 --- /dev/null +++ b/src/sisudoc/io_out/paths_output.d @@ -0,0 +1,672 @@ +/+ +- 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.io_out.paths_output; +@safe: +import +  std.array, +  std.path, +  std.regex, +  std.stdio; +import +  sisudoc.meta.rgx_files; +template spineOutPaths() { +  auto spineOutPaths()( +    string output_pth_root, +    string lng = "", +  ) { +    struct _PathsStruct { +      string output_root() { +        return (output_pth_root.length > 0) +        ? output_pth_root : ""; +      } +      string output_base() { +        return ((output_root.chainPath(lng)).asNormalizedPath).array; +      } +      string internal_base() { +        return lng.asNormalizedPath.array; +      } +    } +    return _PathsStruct(); +  } +} +template spineOutPathSQLite() { +  auto spineOutPathSQLite(Po)( +    Po  output_pth_root, +  ) { +    struct _PathsStruct { +      string output_root() { +        return (output_pth_root.length > 0) +        ? output_pth_root : ""; +      } +      string output_base() { +        return ((output_root).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spineOutPathSQLiteCGI() { +  auto spineOutPathSQLiteCGI(Po)( +    Po  output_pth_root, +  ) { +    struct _PathsStruct { +      string output_root() { +        return (output_pth_root.length > 0) +        ? output_pth_root : ""; +      } +      string output_base() { +        return ((output_root).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spineOutPathsFnPd() { +  /+ TODO stuff to work out here +/ +  auto spineOutPathsFnPd(Fn,Pn)( +    Fn  fn_src_pth, +    Pn  pod_name_with_path +  ) { +    struct _PathsStruct { +      string base_filename() { +        return fn_src_pth.baseName.stripExtension; +      } +      string base_pod_and_filename() { // TODO +        /+ +          - if pod, +            - pod_name +            - file_name +            - if pod_name == file_name +              - file_name +            - else if pod_name != file_name +              - pod_name.file_name +        +/ +        string _fn_src = fn_src_pth.baseName.stripExtension; +        string _output_base_name; +        if (!(pod_name_with_path.empty)) { +          if (pod_name_with_path == _fn_src) { +            _output_base_name = _fn_src; +          } else { +            _output_base_name = pod_name_with_path ~ "." ~ _fn_src; +          } +        } else { +          _output_base_name = _fn_src; +        } +        return _output_base_name; +      } +    } +    return _PathsStruct(); +  } +} + +template spineDocRootTreeHTML() { +  auto spineDocRootTreeHTML()(string lng) { +    auto lng_pth = spineOutPaths!()("", lng); +    string base_dir = "html"; +    string suffix = ".html"; +    struct _PathsStruct { +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      string base_filename_scroll(string fn_src) { +        return base_filename(fn_src); +      } +      string base_filename_seg(string fn_src) { +        return base_filename(fn_src); +      } +      string doc_root() { +        return ((lng_pth.output_root).asNormalizedPath).array; +      } +      string base() { +        return (((lng).chainPath(base_dir)).asNormalizedPath).array; +      } +      string image() { +        return (("image").asNormalizedPath).array; +      } +      string css() { +        return (("css").asNormalizedPath).array; +      } +      string fn_seg_css() { +        return ((css.chainPath("html_seg.css")).asNormalizedPath).array; +      } +      string fn_scroll_css() { +        return ((css.chainPath("html_scroll.css")).asNormalizedPath).array; +      } +      string seg(string fn_src) { +        return ((base.chainPath(base_filename_seg(fn_src))).asNormalizedPath).array; +      } +      string fn_metadata(string fn_src) { +        return ((base.chainPath("metadata." ~ base_filename_scroll(fn_src) ~ suffix)).asNormalizedPath).array; +      } +      string fn_scroll(string fn_src) { +        return ((base.chainPath(base_filename_scroll(fn_src) ~ suffix)).asNormalizedPath).array; +      } +      string fn_seg(string fn_src, string seg_filename) { +        return ((seg(fn_src).chainPath(seg_filename ~ suffix)).asNormalizedPath).array; +      } +      string tail_seg(string fn_src) { +        return lng ~ "/html/" ~ base_filename_seg(fn_src); +      } +      string tail_fn_scroll(string fn_src) { +        return lng ~ "/html/" ~ base_filename_scroll(fn_src) ~ suffix; +      } +      string tail_fn_seg(string fn_src, string seg_filename) { +        return lng ~ "/html/" ~ seg(fn_src) ~ "/" ~ seg_filename ~ suffix; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsHTML() { +  auto spinePathsHTML()( +    string output_path_root, +    string lng, +  ) { +    auto doc_tree = spineDocRootTreeHTML!()(lng); +    string base_dir = "html"; +    string suffix = ".html"; +    struct _PathsStruct { +      string doc_root() { +        return ((output_path_root.chainPath(doc_tree.doc_root)).asNormalizedPath).array; +      } +      string curate(string fn_curate) { +        return doc_root ~ "/" ~ fn_curate; +      } +      string internal_base() { +        return ((doc_tree.base).asNormalizedPath).array; +      } +      string base() { +        return ((output_path_root.chainPath(doc_tree.base)).asNormalizedPath).array; +      } +      string image() { +        return ((output_path_root.chainPath(doc_tree.image)).asNormalizedPath).array; +      } +      string css() { +        return ((output_path_root.chainPath(doc_tree.css)).asNormalizedPath).array; +      } +      string fn_seg_css() { +        return ((output_path_root.chainPath(doc_tree.fn_seg_css)).asNormalizedPath).array; +      } +      string fn_scroll_css() { +        return ((output_path_root.chainPath(doc_tree.fn_scroll_css)).asNormalizedPath).array; +      } +      string seg(string fn_src) { +        return ((output_path_root.chainPath(doc_tree.seg(fn_src))).asNormalizedPath).array; +      } +      string fn_metadata(string fn_src) { +        return ((output_path_root.chainPath(doc_tree.fn_metadata(fn_src))).asNormalizedPath).array; +      } +      string fn_scroll(string fn_src) { +        return ((output_path_root.chainPath(doc_tree.fn_scroll(fn_src))).asNormalizedPath).array; +      } +      string fn_seg(string fn_src, string seg_filename) { +        return ((output_path_root.chainPath(doc_tree.fn_seg(fn_src, seg_filename))).asNormalizedPath).array; +      } +      string tail_seg(string fn_src) { +        return doc_tree.tail_seg(fn_src); +      } +      string tail_fn_scroll(string fn_src) { +        return doc_tree.tail_fn_scroll(fn_src); +      } +      string tail_fn_seg(string fn_src, string seg_filename) { +        return doc_tree.tail_fn_seg(fn_src, seg_filename); +      } +    } +    return _PathsStruct(); +  } +} +template spineUrlsHTML() { +  import std.format; +  auto spineUrlsHTML()( +    string url_doc_root, +    string lng, +  ) { +    auto doc_tree = spineDocRootTreeHTML!()(lng); +    string base_dir = "html"; +    string suffix = ".html"; +    struct _PathsStruct { +      string doc_root() { +        return url_doc_root ~ ((doc_tree.doc_root).asNormalizedPath).array; +      } +      string curate(string fn_curate) { +        return format(q"┃%s/%s┃", +          doc_root, +          fn_curate, +        ); +      } +      string base() { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.base).asNormalizedPath).array, +        ); +      } +      string image() { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.image).asNormalizedPath).array, +        ); +      } +      string css() { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.css).asNormalizedPath).array, +        ); +      } +      string fn_seg_css() { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.fn_seg_css).asNormalizedPath).array, +        ); +      } +      string fn_scroll_css() { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.fn_scroll_css).asNormalizedPath).array, +        ); +      } +      string seg(string fn_src) { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.seg(fn_src)).asNormalizedPath).array, +        ); +      } +      string fn_metadata(string fn_src) { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.fn_metadata(fn_src)).asNormalizedPath).array, +        ); +      } +      string fn_scroll(string fn_src) { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.fn_scroll(fn_src)).asNormalizedPath).array, +        ); +      } +      string fn_seg(string fn_src, string seg_filename) { +        return format(q"┃%s/%s┃", +          url_doc_root, +          ((doc_tree.fn_seg(fn_src, seg_filename)).asNormalizedPath).array, +        ); +      } +      string fn_scroll_obj_num(string fn_src, string obj_num) { +        return format(q"┃%s/%s#%s┃", +          url_doc_root, +          ((doc_tree.fn_scroll(fn_src)).asNormalizedPath).array, +          obj_num, +        ); +      } +      string fn_seg_obj_num(string fn_src, string seg_filename, string obj_num) { +        return format(q"┃%s/%s#%s┃", +          url_doc_root, +          ((doc_tree.fn_seg(fn_src, seg_filename)).asNormalizedPath).array, +          obj_num, +        ); +      } +      string tail_seg(string fn_src) { +        return doc_tree.tail_seg(fn_src); +      } +      string tail_fn_scroll(string fn_src) { +        return doc_tree.tail_fn_scroll(fn_src); +      } +      string tail_fn_seg(string fn_src, string seg_filename) { +        return doc_tree.tail_fn_seg(fn_src, seg_filename); +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsEPUB() { +  auto spinePathsEPUB()( +    string output_pth_root, +    string lng, +  ) { +    auto out_pth = spineOutPaths!()(output_pth_root, lng); +    string base_dir = "epub"; +    struct _PathsStruct { +      string internal_base() { +        return (((out_pth.internal_base).chainPath(base_dir)).asNormalizedPath).array; +      } +      string base() { +        return (((out_pth.output_base).chainPath(base_dir)).asNormalizedPath).array; +      } +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      string base_filename_epub(string fn_src) { +        return base_filename(fn_src) ~ "." ~ lng; +      } +      string doc_meta_inf() { +        return (("META-INF").asNormalizedPath).array; +      } +      string doc_oebps() { +        return (("OEBPS").asNormalizedPath).array; +      } +      string doc_oebps_css() { +        return ((doc_oebps.chainPath("Styles")).asNormalizedPath).array; +      } +      string doc_oebps_image() { +        return ((doc_oebps.chainPath("image")).asNormalizedPath).array; +      } +      string epub_file(string fn_src) { +        return ((base.chainPath(base_filename_epub(fn_src) ~ ".epub")).asNormalizedPath).array; +      } +      string dirtop() { +        return "".chainPath("").array; +      } +      string fn_mimetypes() { +        return ((dirtop.chainPath("mimetype")).asNormalizedPath).array; +      } +      string fn_dmi_container_xml() { +        return ((doc_meta_inf.chainPath("container.xml")).asNormalizedPath).array; +      } +      string fn_oebps_toc_nav_xhtml() { +        return ((doc_oebps.chainPath("toc_nav.xhtml")).asNormalizedPath).array; +      } +      string fn_oebps_toc_ncx() { +        return ((doc_oebps.chainPath("toc.ncx")).asNormalizedPath).array; +      } +      string fn_oebps_content_opf() { +        return ((doc_oebps.chainPath("content.opf")).asNormalizedPath).array; +      } +      string fn_oebps_content_xhtml(string seg_filename) { +        return ((doc_oebps.chainPath(seg_filename ~ ".xhtml")).asNormalizedPath).array; +      } +      string fn_oebps_css() { +        return ((doc_oebps_css.chainPath("epub.css")).asNormalizedPath).array; +      } +      /+ debug +/ +      string dbg_docdir(string fn_src) { +        return base.chainPath(base_filename(fn_src)).array; +      } +      string dbg_docdir_oebps(string fn_src) { +        return dbg_docdir(fn_src).chainPath("OEBPS").array; +      } +      string dbg_doc_meta_inf(string fn_src) { +        return dbg_docdir(fn_src).chainPath("META-INF").array; +      } +      string dbg_doc_oebps(string fn_src) { +        return dbg_docdir(fn_src).chainPath("OEBPS").array; +      } +      string dbg_doc_oebps_css(string fn_src) { +        return dbg_doc_oebps(fn_src).chainPath("Styles").array; +      } +      string dbg_doc_oebps_image(string fn_src) { +        return dbg_doc_oebps(fn_src).chainPath("image").array; +      } +      string dbg_fn_mimetypes(string fn_src) { +        return dbg_docdir(fn_src).chainPath("mimetype").array; +      } +      string dbg_fn_dmi_container_xml(string fn_src) { +        return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; +      } +      string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { +        return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; +      } +      string dbg_fn_oebps_toc_ncx(string fn_src) { +        return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; +      } +      string dbg_fn_oebps_content_opf(string fn_src) { +        return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; +      } +      string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { +        return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; +      } +      string dbg_fn_oebps_css(string fn_src) { +        return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsODT() { +  import std.conv; +  auto spinePathsODT(M)( +    M  doc_matters, +  ) { +    auto out_pth = spineOutPaths!()( doc_matters.output_path, doc_matters.src.language); +    string base_dir = "odf"; +    struct _PathsStruct { +      string base_pth() { // dir will contain odt document file (also debug file tree) +        return (((out_pth.output_base).chainPath(base_dir)).asNormalizedPath).array; +      } +      string odt_file() { +        return ((base_pth.chainPath(doc_matters.src.doc_uid_out ~ ".odt")).asNormalizedPath).array; +      } +      string dirtop(string type) { +        return (type == "zip") +        ? "" // ".chainPath("").array +        : ((base_pth.chainPath(doc_matters.src.doc_uid_out)).asNormalizedPath).array.to!string; +      } +      string mimetype(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("mimetype")).asNormalizedPath).array; +      } +      string manifest_rdf(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("manifest.rdf")).asNormalizedPath).array; +      } +      string settings_xml(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("settings.xml")).asNormalizedPath).array; +      } +      string styles_xml(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("styles.xml")).asNormalizedPath).array; +      } +      string image_dir(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("Pictures")).asNormalizedPath).array; +      } +      string image(string image_fn_src, string type="fs") { +        assert(type == "zip" || "fs"); +        return ((image_dir(type).chainPath(image_fn_src)).asNormalizedPath).array; +      } +      string content_xml(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("content.xml")).asNormalizedPath).array; +      } +      string meta_inf_dir(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("META-INF")).asNormalizedPath).array; +      } +      string manifest_xml(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((meta_inf_dir(type).chainPath("manifest.xml")).asNormalizedPath).array; +      } +      string meta_xml(string type="fs") { +        assert(type == "zip" || "fs"); +        return ((dirtop(type).chainPath("meta.xml")).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsPDF() { +  auto spinePathsPDF(M)( +    M  doc_matters, +  ) { +    struct _PathsStruct { +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      auto out_pth() { +        string output_dir = doc_matters.output_path ~ "/pdf"; +        return spineOutPaths!()(output_dir); +      } +      string base() { +        return (((out_pth.output_root).chainPath("pdf")).asNormalizedPath).array; +      } +      string pdf_path_stuff() { +        return ((base.chainPath(base_filename(doc_matters.src.filename))).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsLaTeX() { +  auto spinePathsLaTeX(M)( +    M  doc_matters, +  ) { +    struct _PathsStruct { +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      auto out_pth() { +        return spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); +      } +      string base() { +        return (((out_pth.output_root).chainPath("latex")).asNormalizedPath).array; +      } +      string base_sty() { +        return (((out_pth.output_root).chainPath("latex").chainPath("sty")).asNormalizedPath).array; +      } +      string latex_path_stuff() { +        return ((base.chainPath(base_filename(doc_matters.src.filename))).asNormalizedPath).array; +      } +      string latex_file_with_path(string paper_size_orientation) { +        return ((base.chainPath(base_filename(doc_matters.src.filename) +             ~ "." ~ doc_matters.src.language +             ~ "."  ~ paper_size_orientation +             ~ ".tex") +          ).asNormalizedPath).array; +      } +      string latex_sty_with_path(string paper_size_orientation) { // spineA4portrait.sty +        return ((base_sty.chainPath("spine" +             ~ paper_size_orientation +             ~ ".sty") +          ).asNormalizedPath).array; +      } +      string latex_sty_with_path_static() { // spineShared.sty +        return ((base_sty.chainPath("spineShared.sty")).asNormalizedPath).array; +      } +      string images() { +        string image_dir = "image"; +        return (((base).chainPath(image_dir)).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsLaTeXsty() { +  auto spinePathsLaTeXsty(string output_dir) { +    struct _PathsStruct { +      auto out_pth() { +        return spineOutPaths!()(output_dir); +      } +      string base() { +        return (((out_pth.output_root).chainPath("latex")).asNormalizedPath).array; +      } +      string base_sty() { +        return (((out_pth.output_root).chainPath("latex").chainPath("sty")).asNormalizedPath).array; +      } +      string latex_sty_with_path(string paper_size_orientation) { // spineA4portrait.sty +        return ((base_sty.chainPath("spine" +             ~ paper_size_orientation +             ~ ".sty") +          ).asNormalizedPath).array; +      } +      string latex_sty_with_path_static() { // spineShared.sty +        return ((base_sty.chainPath("spineShared.sty")).asNormalizedPath).array; +      } +      string latex_document_header_sty(string filename) { // spineShared.sty +        return ((base_sty.chainPath(filename)).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsSQLiteDiscrete() { +  auto spinePathsSQLiteDiscrete()( +    string output_pth_root, +    string lng, +  ) { +    struct _PathsStruct { +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      string base() { +        auto out_pth = spineOutPaths!()(output_pth_root, lng); +        string base_dir = "sqlite"; +        return (((out_pth.output_base).chainPath(base_dir)).asNormalizedPath).array; +      } +      string seg(string fn_src) { +        return ((base.chainPath(base_filename(fn_src))).asNormalizedPath).array; +      } +      string sqlite_file(string fn_src) { +        return ((base.chainPath(base_filename(fn_src) ~ ".sql.db")).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} +template spinePathsSQLite() { +  auto spinePathsSQLite()( +    string db_name, +    string output_pth_root, +  ) { +    struct _PathsStruct { +      string base_filename(string fn_src) { +        return fn_src.baseName.stripExtension; +      } +      string base() { +        auto out_pth = spineOutPathSQLite!()(output_pth_root); // decide whether to have separate files for each language +        string base_dir = ""; +        return (((out_pth.output_root).chainPath(base_dir)).asNormalizedPath).array; +      } +      string sqlite_file() { +        return (base.chainPath(db_name).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +} diff --git a/src/sisudoc/io_out/rgx.d b/src/sisudoc/io_out/rgx.d new file mode 100644 index 0000000..474a120 --- /dev/null +++ b/src/sisudoc/io_out/rgx.d @@ -0,0 +1,157 @@ +/+ +- 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; +@safe: +static template spineRgxOut() { +  static struct RgxO { +    static make_breakpage                           = ctRegex!(`new=(?P<breakpage>.+?)(?:;|$)`); +    static make_breakcolumn                         = ctRegex!(`break=(?P<breakcolumn>.+?)(?:;|$)`,); +    static newline                                  = ctRegex!("\n", "mg"); +    static space                                    = ctRegex!(`[ ]`, "mg"); +    static spaces_keep                              = ctRegex!(`(?P<keep_spaces>^[ ]+|[ ]{2,})`, "mg"); // code, verse, block +    static spaces_line_start                        = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg"); +    static nbsp_char                                = ctRegex!(`░`, "mg"); +    static nbsp_chars                               = ctRegex!(`[░]+`, "mg"); +    static middle_dot                               = ctRegex!(`·`, "mg"); +    static src_pth_sst_or_ssm                       = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`); +    static src_pth_pod_sst_or_ssm                   = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`); +    static src_pth_contents                         = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`); +    static src_pth_zip                              = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); +    static src_pth_types                            = ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/pod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); +    static src_fn                                   = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); +    static src_fn_master                            = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); +    static src_fn_find_inserts                      = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); +    static insert_src_fn_ssi_or_sst                 = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); +    static src_base_parent_dir_name                 = ctRegex!(`[/](?P<dir>(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure +    static src_formalised_file_path_parts           = ctRegex!(`(?P<pth>(?:[/a-zA-Z0-9._-]+?)(?P<dir>[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"); +    /+ quotation marks +/ +    static quotes_open_and_close                    = 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<text>.+?)】`, "m"); +    static inline_notes_al_all_note                 = ctRegex!(`【(?P<num>\d+|(?:[*]|[+])+)\s+(?P<note>.+?)\s*】`, "mg"); +    static inline_notes_al_regular_number_note      = ctRegex!(`【(?P<num>\d+)\s+(?P<note>.+?)\s*】`, "mg"); +    static inline_notes_al_special_char_note        = ctRegex!(`【(?P<char>(?:[*]|[+])+)\s+(?P<note>.+?)】`, "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<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +    static inline_image_without_dimensions          = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +    static inline_image_info                        = ctRegex!(`☼?(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+)`, "mg"); +    static inline_link_anchor                       = ctRegex!(`┃(?P<anchor>\S+?)┃`, "mg"); // TODO *~text_link_anchor +    static inline_link                              = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#?(\S+?))├`, "mg"); +    static inline_link_empty                        = ctRegex!(`┥(?P<text>.+?)┝┤├`, "mg"); +    static inline_link_number                       = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used +    static inline_link_number_only                  = ctRegex!(`(?P<linked_text>┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); +    static inline_link_stow_uri                     = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links +    static inline_link_hash                         = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<hash>\S+?))├`, "mg"); +    static inline_link_seg_and_hash                 = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); +    static inline_link_clean                        = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); +    static inline_link_toc_to_backmatter            = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); +    static url                                      = ctRegex!(`https?://`, "mg"); +    static uri                                      = ctRegex!(`(?:https?|git)://`, "mg"); +    static uri_identify_components                  = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); +    static inline_link_subtoc                       = ctRegex!(`^(?P<level>[5-7])~ ┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "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<text>.+?)┣[*]`, "mg"); +    static inline_bold                              = ctRegex!(`⑆[!]┨(?P<text>.+?)┣[!]`, "mg"); +    static inline_underscore                        = ctRegex!(`⑆[_]┨(?P<text>.+?)┣[_]`, "mg"); +    static inline_italics                           = ctRegex!(`⑆[/]┨(?P<text>.+?)┣[/]`, "mg"); +    static inline_superscript                       = ctRegex!(`⑆\^┨(?P<text>.+?)┣\^`, "mg"); +    static inline_subscript                         = ctRegex!(`⑆[,]┨(?P<text>.+?)┣[,]`, "mg"); +    static inline_strike                            = ctRegex!(`⑆[-]┨(?P<text>.+?)┣[-]`, "mg"); +    static inline_insert                            = ctRegex!(`⑆[+]┨(?P<text>.+?)┣[+]`, "mg"); +    static inline_mono                              = ctRegex!(`⑆[■]┨(?P<text>.+?)┣[■]`, "mg"); +    static inline_cite                              = ctRegex!(`⑆[‖]┨(?P<text>.+?)┣[‖]`, "mg"); +    /+ 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<indent>[1-9])[*] `, "m"); +    static grouped_para_indent_hang                 = ctRegex!(`^_(?P<hang>[0-9])_(?P<indent>[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"); // <br /> +  } +} 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<path_to_pod>\S+?)(?P<podname>[a-z_-]+)/(?P<from_root>media/text/)(?P<language>\S+?)/(?P<filename>\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<path_to_pod>\S+?)(?P<podname>[a-z_-]+)/(?P<from_root>media/text/)(?P<language>\S+?)/(?P<filename>\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,     "<br />") +            .replaceAll(rgx.br_line,            "<br />") +            .replaceAll(rgx.br_line_spaced,     "<br /><br />") +            .replaceAll(rgx_xhtml.line_break,   "<br />"); +          return _txt; +        } +        string _html_font_face(string _txt){ +          _txt = _txt +            .replaceAll(rgx.inline_emphasis,    "<em>$1</em>") +            .replaceAll(rgx.inline_bold,        "<b>$1</b>") +            .replaceAll(rgx.inline_underscore,  "<u>$1</u>") +            .replaceAll(rgx.inline_italics,     "<i>$1</i>") +            .replaceAll(rgx.inline_superscript, "<sup>$1</sup>") +            .replaceAll(rgx.inline_subscript,   "<sub>$1</sub>") +            .replaceAll(rgx.inline_strike,      "<del>$1</del>") +            .replaceAll(rgx.inline_insert,      "<ins>$1</ins>") +            .replaceAll(rgx.inline_mono,        "<tt>$1</tt>") +            .replaceAll(rgx.inline_cite,        "<cite>$1</cite>"); +          return _txt; +        } +        string _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,     "<br />") +          .replaceAll(rgx.br_line,            "<br />") +          .replaceAll(rgx.br_line_spaced,     "<br /><br />") +          .replaceAll(rgx_xhtml.line_break,   "<br />"); +        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,    "<em>$1</em>") +          .replaceAll(rgx.inline_bold,        "<b>$1</b>") +          .replaceAll(rgx.inline_underscore,  "<u>$1</u>") +          .replaceAll(rgx.inline_italics,     "<i>$1</i>") +          .replaceAll(rgx.inline_superscript, "<sup>$1</sup>") +          .replaceAll(rgx.inline_subscript,   "<sub>$1</sub>") +          .replaceAll(rgx.inline_strike,      "<del>$1</del>") +          .replaceAll(rgx.inline_insert,      "<ins>$1</ins>") +          .replaceAll(rgx.inline_mono,        "<tt>$1</tt>") +          .replaceAll(rgx.inline_cite,        "<cite>$1</cite>"); +        return _txt; +      } +      string 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<img src=\"" +                ~ _img_pth +                ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $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, +              ("<a href=\"$2\">$1</a>")) +            .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"<a href"))) { +          //     writeln(__LINE__, " ", +          //       doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, +          //       "/", +          //       doc_matters.src.filename_base, +          //       "\n", +          //       _txt +          //     ); +          //   } +          // } +        } +        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(M,O)( +                     M   doc_matters, +        const        O   obj, +        string           _txt, +      ) { +        if (obj.has.inline_notes_reg) { +          string[] _endnotes; +          foreach(m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { +            _endnotes ~= "<p class=\"endnote\">" +            ~ "<sup>" ~ m.captures["num"] ~ ".</sup>" +            ~ m.captures["note"] +            ~ "</p>"; +          } +          _txt = replaceAll!(m => +            (" " ~ "<sup>" ~ m["num"] ~ "</sup>")) +              (_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"┃<p class="%s"><b> +            %s +          </b></p>┃", +            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"┃<p class="%s" indent="h%si%s"> +          %s +        </p>┃", +            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"┃<p class="%s"> +          %s +        </p>┃", +            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"┃<p class="%s"> +          %s +        </p>┃", +            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"┃ +        <p class="%s">%s</p>┃", +            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"┃<p class="%s">%s</p>┃", +            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"┃<p class="%s">%s</p>┃", +            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 ~= "<tr>"; +              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 ~= "</tr>"; +            } +          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"┃<p class="%s"> +          <table summary="normal text css" width="95%%" border="0" cellpadding="2" align="center"> +            %s +          </table> +          %s +        </p>┃", +          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<div class=\"doc_title\">\n" ; +          break; +        case "toc": +          delimit_ ~= "\n<div class=\"doc_toc\">\n" ; +          break; +        case "bookindex": +          delimit_ ~= "\n<div class=\"doc_bookindex\">\n" ; +          break; +        default: +          delimit_ ~= "\n<div class=\"doc_" ~ section ~ "\">\n" ; +          break; +        } +        if (previous_section.length > 0) { +          delimit ~= "\n</div>"; +        } +        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,            "<br />") +        .replaceAll(rgx.br_line_inline,     "<br />") +        .replaceAll(rgx.br_line_spaced,     "<br />\n<br />") +        .replaceAll(rgx.nbsp_char,          " "); +      return _txt; +    } +    string special_characters_date(string _txt) { +      _txt = _txt +        .replaceAll(regex(r"(?:-00)+"),     "") +        .replaceAll(rgx.br_line,            "<br />") +        .replaceAll(rgx.br_line_inline,     "<br />") +        .replaceAll(rgx.br_line_spaced,     "<br />\n<br />") +        .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,   "<br />"); +      } +      return _txt; +    } +    string font_face(string _txt) { +      _txt = _txt +        .replaceAll(rgx.inline_emphasis,    ("<em>$1</em>")) +        .replaceAll(rgx.inline_bold,        ("<b>$1</b>")) +        .replaceAll(rgx.inline_underscore,  ("<u>$1</u>")) +        .replaceAll(rgx.inline_italics,     ("<i>$1</i>")) +        .replaceAll(rgx.inline_superscript, ("<sup>$1</sup>")) +        .replaceAll(rgx.inline_subscript,   ("<sub>$1</sub>")) +        .replaceAll(rgx.inline_strike,      ("<del>$1</del>")) +        .replaceAll(rgx.inline_insert,      ("<ins>$1</ins>")) +        .replaceAll(rgx.inline_mono,        ("<tt>$1</tt>")) +        .replaceAll(rgx.inline_cite,        ("<cite>$1</cite>")); +      return _txt; +    } +    string _xhtml_anchor_tags(O)(O obj) { +      string tags=""; +      if (obj.tags.anchor_tags.length > 0) { +        foreach (tag; obj.tags.anchor_tags) { +          if (!(tag.empty)) { +            tags ~= "<a name=\"" ~ special_characters_text(tag) ~ "\"></a>"; +          } +        } +      } +      return tags; +    } +    string header_metadata(M)( +      M  doc_matters, +    ) { +      string _publisher="Publisher"; // TODO +      string o; +      o = format(q"┃<!-- spine DocReform header metadata --> +    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +    <meta name="dc.title" content="%s" /> +    <meta name="dc.author" content="%s" /> +    <meta name="dc.publisher" content="%s" /> +    <meta name="dc.date" content="%s" /> +    <meta name="dc.date.created" content="%s" /> +    <meta name="dc.date.issued" content="%syear" /> +    <meta name="dc.date.available" content="%syear" /> +    <meta name="dc.date.valid" content="%syear" /> +    <meta name="dc.date.modified" content="%syear" /> +    <meta name="dc.language" content="%s" /> +    <meta name="dc.rights" content="%s" /> +    <meta name="generator" content="%s" /> +    <link rel="generator" href="%s" /> +    <!-- spine DocReform header metadata -->┃", +        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, +            ("<p class=\"tiny_left\"><a href=\"$2\" class=\"lnkicon\">$1</a></p>")) +          .replaceAll( +            rgx.br_line, "") +          .replaceAll( +            rgx.br_line_inline, ""); +      } else { +         _locations = "<p class=\"icons\"><a href=\"https://www.doc-reform.org\" class=\"lnkicon\">spine</a></p>\n<p class=\"icons\"><a href=\"https://git.sisudoc.org/software/spine/\" class=\"lnkicon\">sources / git</a></p>\n<p class=\"icons\"><a href=\"https://www.sisudoc.org\" class=\"lnkicon\">www.sisudoc.org</a></p>"; +      } +      string o; +      o = format(q"┃<div class="flex-menu-option"> +          %s +        </div>┃", +        _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"┃ +        <div class="flex-menu-option"> +          <!-- SiSU Spine Search --> +          <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="searchtxt"> +            <font size="2">%s +          <input type="text" name="sf" size="24" maxlength="255">%s +          <input type="hidden" name="sml" value="1000"> +          <input type="hidden" name="ec" value="on"> +          <input type="hidden" name="url" value="on"> +          <input type="hidden" name="rt" value="txt"> +          <button type="submit" form="searchtxt" name="fn" value="%s"> • ⚏ </button> +          </font></form> +          <!-- SiSU Spine Search --> +        </div> +        <div class="flex-menu-option"> +          <!-- SiSU Spine Search --> +          <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="searchidx"> +            <font size="2"> +          <input type="text" name="sf" size="24" maxlength="255">%s +          <input type="hidden" name="sml" value="1000"> +          <input type="hidden" name="ec" value="on"> +          <input type="hidden" name="url" value="on"> +          <input type="hidden" name="rt" value="idx"> +          <button type="submit" form="searchidx" name="fn" value="%s"> • ፨ </button> +          <button type="submit" form="searchidx"> ㏈ ፨</button> +          </font></form> +          <!-- SiSU Spine Search --> +        </div>┃", +        doc_matters.conf_make_meta.conf.w_srv_cgi_action, +        (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty) +          ? "" +          : "\n    <a href=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_cgi_action +            ~ "\">🔎 </a>", +        (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty) +          ? "" +          : "\n    <input type=\"hidden\" name=\"db\" value=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename +            ~ "\">", +        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    <input type=\"hidden\" name=\"db\" value=\"" +            ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename +            ~ "\">", +        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"┃<p class="icons"><a href="%s" class="lnkicon">⟰ </a> [<a href="%s" class="lnkicon"> %s </a><a href="%sepub/%s.%s.epub" class="lnkicon"> ◆ </a>%s%s<a href="%smetadata.%s.html" class="lnkicon"> ℹ </a>]  <a href="%s../../index.html" class="lnkicon"> ≅ </a>|<a href="%s../../authors.html" class="lnkicon"> 🖋 </a>|<a href="%s../../topics.html" class="lnkicon"> ⌘ </a>|</p>┃", +            (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) +            ? ("<a href=\"" +              ~ ((type == "seg") ? "../../../" : "../../") +              ~ "pdf/" +              ~ doc_matters.src.filename_base +              ~  "." +              ~ doc_matters.src.lng +              ~ ".a4.portrait.pdf\" class=\"lnkicon\"> □ </a>") +            : "", +            (doc_matters.opt.action.html_link_pdf || doc_matters.opt.action.html_link_pdf_letter) +            ? ("<a href=\"" +              ~ ((type == "seg") ? "../../../" : "../../") +              ~ "pdf/" +              ~ doc_matters.src.filename_base +              ~  "." +              ~ doc_matters.src.lng +              ~ ".letter.portrait.pdf\" class=\"lnkicon\"> □ </a>") +            : "", +            (type == "seg") ? "../" : "", +            doc_matters.src.filename_base, +            (type == "seg") ? "../" : "", +            (type == "seg") ? "../" : "", +            (type == "seg") ? "../" : "", +          ) +        : ""); +      o = format(q"┃<!DOCTYPE html> +    <html> +    <head> +      <meta http-equiv="Content-Type" content="text/plain; charset=UTF-8" /> +      <title> +        %s%s +      </title> +      <!-- metadata --> +      %s +      <!-- metadata --> +      <link rel="generator" href="https://www.sisudoc.org/" /> +      <link rel="shortcut icon" href="%s../../image/dr.ico" /> +      <link href="%s" rel="stylesheet" /> +    </head> +    <body lang="%s"> +    <a name="top" id="top"></a> +    <div class='delimit headband'> +      <div class="flex-menu-bar"> +        %s +        <div class="flex-menu-option"> +          %s +        </div>%s +      </div> +    </div>┃", +        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"┃<!DOCTYPE html> +    <html>┃", +    ); +      string html_simple = format(q"┃<!DOCTYPE html> +    <html +      xmlns="https://www.w3.org/1999/xhtml" +      xmlns:epub="http://www.idpf.org/2007/ops" +      lang="%s" xml:lang="%s">┃", +        doc_matters.src.language, +        doc_matters.src.language, +      ); +      string html_strict = format(q"┃<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" +         "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +    <html xmlns="https://www.w3.org/1999/xhtml" +      xmlns:epub="http://www.idpf.org/2007/ops" +      lang="%s" xml:lang="%s">┃", +        doc_matters.src.language, +        doc_matters.src.language, +      ); +      string o; +      o = format(q"┃%s +    <head> +      <title> +        %s%s +      </title> +      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +      <meta name="dc.title" content="%s" /> +      <meta name="dc.author" content="%s" /> +      <meta name="dc.publisher" content="FIX" /> +      <meta name="dc.date" content="%s" /> +      <meta name="dc.date.created" content="%s" /> +      <meta name="dc.date.issued" content="%s" /> +      <meta name="dc.date.available" content="%s" /> +      <meta name="dc.date.valid" content="%s" /> +      <meta name="dc.date.modified" content="%s" /> +      <meta name="dc.language" content="%s" /> +      <meta name="dc.rights" content="%s" /> +      <meta name="generator" content="%s" /> +      <link rel="generator" href="%s" /> +      <link rel="shortcut icon" href="../_dr/image/dr.ico" /> +      <link rel="stylesheet" href="Styles/epub.css" type="text/css" id="main-css" /> +    </head> +    <body lang="%s"> +    <a name="top" id="top"></a>┃", +        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"┃</div>┃"); +  return o; +} +string tail(M)(M doc_matters) { +  string o; +  o = format(q"┃<hr /> +  <div class="rights"> +    <p class="small" id="copyright"><a name="copyright"></a> +      <b>Copyright:</b> %s +    </p> +  </div> +  %s +  <div class="rights"> +    <p class="small" id="rights"><a name="rights"></a> +      %s +    </p> +  </div> +  <hr /> +  <div class="generator"> +    <p class="small_center" id="sisu_spine"><a name="sisu_spine"></a> +      <a href="https://sisudoc.org" class="lnkicon">≅ SiSU Spine ፨</a> (object numbering & object search) +    </p> +    <p class="small_center" id="sisu_spine"><a name="sisu_spine"></a> +      (web 1993, object numbering 1997, object search 2002 ...) 2024 +    </p> +  </div> +  <a name="bottom" id="bottom"></a> +  <a name="end" id="end"></a> +</body> +</html> +┃", +    special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), +    ((doc_matters.conf_make_meta.meta.rights_license).empty) ? "" : "<br />", +    ((doc_matters.conf_make_meta.meta.rights_license).empty) ? "" +      : "<b>License:</b> " ~ 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<img src=\"" +              ~ _img_pth +              ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $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, +            ("<a href=\"$2\">$1</a>")) +          .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, +          ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") +        ); +      } +      if (obj.has.inline_notes_star) { +        _txt = font_face(_txt); +        _txt = _txt.replaceAll( +          rgx.inline_notes_al_special_char_note, +          ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") +        ); +      } +      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", +            "<p class=\"endnote\">", +            "<a href=\"#noteref_", +            m.captures[1], +            "\">", +            "<note id=\"note_", +            m.captures[1], +            "\"> <sup>", +            m.captures[1], +            ".</sup></note></a>", +            m.captures[2], +            "</p>" +          ); +        } +        _txt = _txt.replaceAll( +          rgx.inline_notes_al_special_char_note, +          ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") +        ); +      } +      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", +            "<p class=\"endnote\">", +            "<a href=\"#noteref_", +            m.captures[1], +            "\">", +            "<note id=\"note_", +            m.captures[1], +            "\"> <sup>", +            m.captures[1], +            ".</sup></note></a>", +            m.captures[2], +            "</p>" +          ); +        } +        _txt = _txt.replaceAll( +          rgx.inline_notes_al_regular_number_note, +          ("<a href=\"#note_$1\"><note id=\"noteref_$1\"> <sup>$1</sup> </note></a>") +        ); +      } 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 ~= "  <div class=\"nav\">\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"┃    <p class="minitoc" indent="h%si%s"> +          ۰ <a href="%s">%s</a> +        </p> +    ┃", +              indent, +              indent, +              link, +              text, +          )); +        } +      } +      lev4_subtoc ~= "  </div>\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"┃<a href="toc.html" target="_top"> +              <div class="toc-button menu"> +                <svg viewbox="0 0 100 100"> +                  <path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2  s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2  S29.104,22,28,22z" /> +                </svg> +              </div> +            </a>┃", +        ); +      } +      if (obj.tags.segname_prev == "") { +        prev = ""; +      } else { +        prev = format(q"┃<a href="%s.html" target="_top"> +              <div class="prev-next-button previous"> +                <svg viewbox="0 0 100 100"> +                  <path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z" transform=" translate(15,0)" /> +                </svg> +              </div> +            </a>┃", +          obj.tags.segname_prev, +        ); +      } +      if (obj.tags.segname_next == "") { +        next = ""; +      } else { +        next = format(q"┃<a href="%s.html" target="_top"> +              <div class="prev-next-button next"> +                <svg viewbox="0 0 100 100"> +                  <path class="arrow" d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z" transform="translate(85,100) rotate(180)" /> +                </svg> +              </div> +            </a>┃", +          obj.tags.segname_next, +        ); +      } +      string _toc_pre_next = format(q"┃    <div class="nav-bar"> +      %s +      %s +      %s +    </div>┃", +        toc, +        prev, +        next, +      ); +      string _pre_next = format(q"┃    <div class="nav-bar"> +      %s +      %s +    </div>┃", +        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 = "<hr />"; +      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) +        ? "" +        : "<a name=\"" ~ obj.tags.heading_lev_anchor_tag ~ "\"></a>"; +      if (_txt.empty) { +        o = format(q"┃%s +      ┃", +        _horizontal_rule, +        ); +      } else { +        o = ""; +        if (obj.metainfo.is_of_section == "toc") { +          o ~= format(q"┃ +      <div class="substance"> +        <p class="small" id="copyright"><a name="copyright"></a> +          Copyright: %s +        </p> +        <!-- <p class="small" id="rights"><a name="rights"></a> +          %s +        </p> --> +      </div>┃", +            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 +      <div class="substance"> +        <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +        <h%s class="%s" id="%s"><a name="%s"></a>%s%s +          %s +        </h%s> +      </div>┃", +            _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 +      <div class="substance"> +        <h%s class="%s">%s%s +          %s +        </h%s> +      </div>┃", +            _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, +         "<a name=\"$1\"></a>"); +      if (!(obj.metainfo.identifier.empty)) { +        o = format(q"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" indent="h%si%s" id="%s">%s +        %s +      </p> +    </div>┃", +          obj.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"┃  <div class="substance"> +      <p class="%s" indent="h%si%s">%s +        %s +      </p> +    </div>┃", +          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"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" id="%s"> +        %s +      </p> +    </div>┃", +          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"┃  <div class="substance"> +      <p class="%s"> +        %s +      </p> +    </div>┃", +          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"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" id="%s"> +        %s +      </p> +    </div>┃", +          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"┃  <div class="substance"> +      <p class="%s"> +        %s +      </p> +    </div>┃", +          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"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" id="%s">%s</p> +    </div>┃", +          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"┃  <div class="substance"> +      <p class="%s">%s</p> +    </div>┃", +          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"┃  <div class="substance"> +          <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +          <p class="%s" id="%s">%s</p> +        </div>┃", +          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"┃  <div class="substance"> +          <p class="%s">%s</p> +        </div>┃", +          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 ~= "<tr>"; +        foreach(col_idx, cell; _table_cols) { +          if ((_table_cols.length == 1) +          && (_table_rows.length <= row_idx+2)) { +            _tablenote ~= cell; +          } else { +            string _col_is = (row_idx == 0 && obj.table.heading) ? "th" : "td"; +            string _align = ("style=\"text-align:" +            ~ ((obj.table.column_aligns[col_idx] == "l") +            ? "left\"" : "right\"")); +            _table ~= "<" ~ _col_is ~ " width=\"" ~ obj.table.column_widths[col_idx].to!string ~ "%\" " ~ _align ~ ">"; +            _table ~= cell; +            _table ~= "</" ~ _col_is ~ ">"; +          } +        } +        _table ~= "</tr>"; +      } +      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"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" id="%s">%s +        <table summary="normal text css" width="95%%" border="0" cellpadding="2" align="center"> +          %s +        </table> +        %s +      </p> +    </div>┃", +        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 = "  <pre class=\"codeline\">\n"; +          foreach (k, _line; _block_lines) { +            if (k == 1) { +              _codelines ~= format(q"┃    <span class="tr first-row"><span class="th"></span><codeline>%s</codeline></span> +    ┃", +                _line, +              ); +            } else { +              _codelines ~= format(q"┃    <span class="tr"><span class="th"></span><codeline>%s</codeline></span> +    ┃", +                _line, +              ); +            } +          } +          _codelines ~= "  </pre>"; +        } else { +          _codelines = "  <pre class=\"codeline\">\n"; +          _codelines ~= _txt; +          _codelines ~= "  </pre>"; +        } +        return _codelines; +      } +      if (!(obj.metainfo.identifier.empty)) { +        o = format(q"┃  <div class="substance"> +      <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> +      <p class="%s" id="%s">%s</p> +    </div>┃", +          obj.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"┃  <div class="substance"> +      <p class="%s">%s</p> +    </div>┃", +          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<BR> +  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}*", "<b>$1</b>"]; +    } +    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}!", "<em>$1</em>" ]; +    } +    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}/", "<i>$1</i>" ]; +    } +    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<BR> +  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"┃ +      <div class="flex-menu-option"> +      <!-- SiSU Spine Search --> +      <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="search"> +      <font size="2"> +      <input type="text" name="sf" size="24" maxlength="255">%s +      <input type="hidden" name="sml" value="1000"> +      <input type="hidden" name="ec" value="on"> +      <input type="hidden" name="url" value="on"> +      <button type="submit" form="search">㏈ ፨</button> +      </font></form> +      <!-- SiSU Spine Search --> +      </div>┃", +          _make_and_meta_struct.conf.w_srv_cgi_action, +          (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) +            ? "" +            : "\n    <input type=\"hidden\" name=\"db\" value=\"" +              ~ _make_and_meta_struct.conf.w_srv_db_sqlite_filename +              ~ "\">", +          ); +        } 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"┃ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>⌘ Curated metadata - 🖋 Authors</title> +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta name="dc.title" content= "metadata curate, Authors & Topics - information Structuring Universe, Structured information Serialised Units" /> +<meta name="dc.subject" content= "document structuring, ebook, publishing, PDF, LaTeX, XML, ODF, SQL, postgresql, sqlite, electronic book, electronic publishing, electronic document, electronic citation, data structure, citation systems, granular search, digital library" /> +<meta name="generator" content="spine" /> +<link rel="generator" href="https://sisudoc.org" /> +<link href="./css/curate.css" rel="stylesheet"> +<style TYPE="text/css"> +/* spine curate css default stylesheet */%s +  .norm, .bold { +    line-height              : 150%%; +    margin-left              : 1em; +    margin-right             : 2em; +    margin-top               : 10px; +    margin-bottom            : 0px; +    text-indent              : 0mm; +  } +  p, h0, h1, h2, h3, h4, h5, h6, h7 { +    display                  : block; +    font-family              : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; +    font-size                : 100%%; +    font-weight              : normal; +    line-height              : 150%%; +    /* text-align            : justify; */ +    margin-left              : 1em; +    text-indent              : 0mm; +    margin-top               : 2px; +    margin-bottom            : 2px; +    margin-right             : 6px; +    text-align               : left; +  } +  h0, h1, h2, h3, h4, h5, h6, h7 { text-shadow: .2em .2em .3em #999999; } +  h1 { +    font-size                : 120%%; +    font-weight              : bold; +    color                    : #FFFFFF; +    background               : #000088; +    margin-left              : 0em; +  } +  p.work { +    font-size                : 80%%; +    margin-left              : 5em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.author { +    font-size                : 100%%; +    margin-left              : 2em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.publication { +    font-size                : 90%%; +    margin-left              : 4em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.letter { +    font-weight              : bold; +    font-size                : 80%%; +    margin-left              : 1em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.icons, .icons_center { +    font-size                : 100%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +  } +  p.icons { +    text-align               : left; +  } +  p.lev0 { +    font-size                : 120%%; +    margin-left              : 1em; +  } +  p.lev1 { +    font-size                : 115%%; +    margin-left              : 2em; +  } +  p.lev2 { +    font-size                : 110%%; +    margin-left              : 3em; +  } +  p.lev3 { +    font-size                : 105%%; +    margin-left              : 4em; +  } +  p.lev4 { +    font-size                : 100%%; +    margin-left              : 5em; +  } +  p.lev5 { +    font-size                : 95%%; +    margin-left              : 6em; +  }%s +  /* flex */ +  .flex-menu-bar { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-flex-wrap        : wrap; +    -webkit-align-items      : center; +    align-items              : center; +    width                    : 100%%; +    margin-left              : 0%%; +    margin-right             : 2%%; +    background-color         : inherited; +  } +  .flex-menu-option { +    background-color         : inherited; +    margin-right             : 4px; +  } +  .flex-list { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-align-items      : center; +    display                  : block; +    align-items              : center; +    width                    : 100%%; +    background-color         : inherited; +  } +  .flex-list-item { +    background-color         : inherited; +    margin                   : 4px; +  } +</style> +<link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> +</head> +<body lang="en" xml:lang="en"> +<a name="top" id="top"></a> +<a name="up" id="up"></a> +<a name="start" id="start"></a> +<h1>⌘ Curated metadata - 🖋 Authors (output organised by language & filetype)</h1> +<div class="flex-menu-bar"> +<div class="flex-menu-option"> +<p class="icons">[<a href="../../index.html" class="lnkicon"> ⟰ HOME </a> | <a href="../index.html" class="lnkicon"> ≅ Collection </a>] + [<a href="topics.html" class="lnkicon"> ⌘ Curated metadata - ⌘ Topics </a>] </p> +</div> +%s +</div> +<p></p> +<hr /> +<p><a href="#A" class="lnkicon">A</a>, <a href="#B" class="lnkicon">B</a>, <a href="#C" class="lnkicon">C</a>, <a href="#D" class="lnkicon">D</a>, <a href="#E" class="lnkicon">E</a>, <a href="#F" class="lnkicon">F</a>, <a href="#G" class="lnkicon">G</a>, <a href="#H" class="lnkicon">H</a>, <a href="#I" class="lnkicon">I</a>, <a href="#J" class="lnkicon">J</a>, <a href="#K" class="lnkicon">K</a>, <a href="#L" class="lnkicon">L</a>, <a href="#M" class="lnkicon">M</a>, <a href="#N" class="lnkicon">N</a>, <a href="#O" class="lnkicon">O</a>, <a href="#P" class="lnkicon">P</a>, <a href="#Q" class="lnkicon">Q</a>, <a href="#R" class="lnkicon">R</a>, <a href="#S" class="lnkicon">S</a>, <a href="#T" class="lnkicon">T</a>, <a href="#U" class="lnkicon">U</a>, <a href="#V" class="lnkicon">V</a>, <a href="#W" class="lnkicon">W</a>, <a href="#X" class="lnkicon">X</a>, <a href="#Y" class="lnkicon">Y</a>, <a href="#Z" class="lnkicon">Z</a>,  +┃", +  _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"┃<p class="author"><a name="%s" class="lev0">%s</a></p> <p class="publication">%s "<a href="%s">%s</a>" [<a href="%s"> %s </a>]</p>┃", +            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"┃<p class="publication">%s "<a href="%s">%s</a>" [<a href="%s"> %s </a>]</p>┃", +            (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" [<a href="%s"> %s </a>]%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"┃<p class="letter"><a name="%s">%s</a></p><p class="book_index_lev1"><a name="a"></a></p>┃", +            k.toUpper.to!(char[])[0], +            k.toUpper.to!(char[])[0], +          ); +          _prev_k = k.toUpper.to!(char[])[0]; +        } +        authors ~= _au[k]; +      } +      authors +      ~= format(q"┃ +<hr /> +<a name="bottom" id="bottom"></a> +<a name="down" id="down"></a> +<a name="end" id="end"></a> +<a name="finish" id="finish"></a> +<a name="stop" id="stop"></a> +<a name="credits"></a> +</body> +</html> +┃") ~ "\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"┃ +      <div class="flex-menu-option"> +      <!-- SiSU Spine Search --> +      <form action="%s" target="_top" method="POST" accept-charset="UTF-8" id="search"> +      <font size="2"> +      <input type="text" name="sf" size="24" maxlength="255">%s +      <input type="hidden" name="sml" value="1000"> +      <input type="hidden" name="ec" value="on"> +      <input type="hidden" name="url" value="on"> +      <button type="submit" form="search">㏈ ፨</button> +      </font></form> +      <!-- SiSU Spine Search --> +      </div>┃", +          _make_and_meta_struct.conf.w_srv_cgi_action, +          (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty) +            ? "" +            : "\n    <input type=\"hidden\" name=\"db\" value=\"" +              ~ _make_and_meta_struct.conf.w_srv_db_sqlite_filename +              ~ "\">", +          ); +        } 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"┃<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>⌘ Curated metadata - ⌘ Topics</title> +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta name="dc.title" content= "metadata curate, Authors & Topics - information Structuring Universe, Structured information Serialised Units" /> +<meta name="dc.subject" content= "document structuring, ebook, publishing, PDF, LaTeX, XML, ODF, SQL, postgresql, sqlite, electronic book, electronic publishing, electronic document, electronic citation, data structure, citation systems, granular search, digital library" /> +<meta name="generator" content="spine" /> +<link rel="generator" href="https://sisudoc.org" /> +<link href="./css/curate.css" rel="stylesheet"> +<style TYPE="text/css"> +/* spine curate css default stylesheet */%s +  .norm, .bold { +    line-height              : 150%%; +    margin-left              : 1em; +    margin-right             : 2em; +    margin-top               : 10px; +    margin-bottom            : 0px; +    text-indent              : 0mm; +  } +  p, h0, h1, h2, h3, h4, h5, h6, h7 { +    display                  : block; +    font-family              : verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; +    font-size                : 100%%; +    font-weight              : normal; +    line-height              : 150%%; +    /* text-align            : justify; */ +    margin-left              : 1em; +    text-indent              : 0mm; +    margin-top               : 2px; +    margin-bottom            : 2px; +    margin-right             : 6px; +    text-align               : left; +  } +  h0, h1, h2, h3, h4, h5, h6, h7 { text-shadow: .2em .2em .3em #999999; } +  h1 { +    font-size                : 120%%; +    font-weight              : bold; +    color                    : #FFFFFF; +    background               : #000088; +    margin-left              : 0em; +  } +  p.work { +    font-size                : 80%%; +    margin-left              : 5em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.author { +    font-size                : 100%%; +    margin-left              : 2em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.publication { +    font-size                : 90%%; +    margin-left              : 4em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.letter { +    font-weight              : bold; +    font-size                : 80%%; +    margin-left              : 1em; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +    text-align               : left; +  } +  p.icons, .icons_center { +    font-size                : 100%%; +    margin-top               : 0px; +    margin-bottom            : 0px; +    margin-right             : 6px; +  } +  p.icons { +    text-align               : left; +  } +  p.lev0 { +    font-size                : 120%%; +    margin-left              : 1em; +  } +  p.lev1 { +    font-size                : 115%%; +    margin-left              : 2em; +  } +  p.lev2 { +    font-size                : 110%%; +    margin-left              : 3em; +  } +  p.lev3 { +    font-size                : 105%%; +    margin-left              : 4em; +  } +  p.lev4 { +    font-size                : 100%%; +    margin-left              : 5em; +  } +  p.lev5 { +    font-size                : 95%%; +    margin-left              : 6em; +  }%s +  /* flex */ +  .flex-menu-bar { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-flex-wrap        : wrap; +    -webkit-align-items      : center; +    align-items              : center; +    width                    : 100%%; +    margin-left              : 0%%; +    margin-right             : 2%%; +    background-color         : inherited; +  } +  .flex-menu-option { +    background-color         : inherited; +    margin-right             : 4px; +  } +  .flex-list { +    display                  : -webkit-flex; +    display                  : flex; +    -webkit-align-items      : center; +    display                  : block; +    align-items              : center; +    width                    : 100%%; +    background-color         : inherited; +  } +  .flex-list-item { +    background-color         : inherited; +    margin                   : 4px; +  } +</style> +<link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> +</head> +<body lang="en" xml:lang="en"> +<a name="top" id="top"></a> +<a name="up" id="up"></a> +<a name="start" id="start"></a> +<h1>⌘ Curated metadata - ⌘ Topics (output organised by language & filetype)</h1> +<div class="flex-menu-bar"> +<div class="flex-menu-option"> +<p class="icons">[<a href="../../index.html" class="lnkicon"> ⟰ HOME </a> | <a href="../index.html" class="lnkicon"> ≅ Collection </a>] + [<a href="authors.html" class="lnkicon"> ⌘ Curated metadata - 🖋 Authors </a>] +</p> +</div> + %s +</div> +<p><a href="#A" class="lnkicon">A</a>, <a href="#B" class="lnkicon">B</a>, <a href="#C" class="lnkicon">C</a>, <a href="#D" class="lnkicon">D</a>, <a href="#E" class="lnkicon">E</a>, <a href="#F" class="lnkicon">F</a>, <a href="#G" class="lnkicon">G</a>, <a href="#H" class="lnkicon">H</a>, <a href="#I" class="lnkicon">I</a>, <a href="#J" class="lnkicon">J</a>, <a href="#K" class="lnkicon">K</a>, <a href="#L" class="lnkicon">L</a>, <a href="#M" class="lnkicon">M</a>, <a href="#N" class="lnkicon">N</a>, <a href="#O" class="lnkicon">O</a>, <a href="#P" class="lnkicon">P</a>, <a href="#Q" class="lnkicon">Q</a>, <a href="#R" class="lnkicon">R</a>, <a href="#S" class="lnkicon">S</a>, <a href="#T" class="lnkicon">T</a>, <a href="#U" class="lnkicon">U</a>, <a href="#V" class="lnkicon">V</a>, <a href="#W" class="lnkicon">W</a>, <a href="#X" class="lnkicon">X</a>, <a href="#Y" class="lnkicon" class="lnkicon">Y</a>, <a href="#Z" class="lnkicon">Z</a>,  +<p></p> +<hr /> +┃", +  _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"┃<p class="letter"><a name="%s">%s</a></p><p class="book_index_lev1"><a name="a"></a></p>┃", +            k0.toUpper.to!(char[])[0], +            k0.toUpper.to!(char[])[0], +          ); +          _prev_k = k0.toUpper.to!(char[])[0]; +        } +        if (k0 != "_a") { +          topics ~= format(q"┃<p class="lev0"><a name="%s" class="lev0">%s</a></p>┃", +            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"┃ <a href="authors.html#%s">%s</a>┃", +                  t_a_.author_surname.translate([' ' : "_"]), +                  t_a_.author, +                ); +              } else { +                foreach (a; t_a_.author_arr) { +                  _auth ~= format(q"┃ <a href="authors.html#%s">%s</a>,┃", +                    t_a_.author_surname.translate([' ' : "_"]), +                    a, +                  ); +                } +              } +              topics ~= format(q"┃<p class="work"><a href="%s">"%s"</a> - %s [<a href="%s"> %s </a>]┃", +                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"┃<p class="lev1"><a name="%s.%s" class="lev1">%s</a></p>┃", +                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"┃ <a href="authors.html#%s">%s</a>┃", +                      t_a_.author_surname.translate([' ' : "_"]), +                      t_a_.author, +                    ); +                  } else { +                    foreach (a; t_a_.author_arr) { +                      _auth ~= format(q"┃ <a href="authors.html#%s">%s</a>,┃", +                        t_a_.author_surname.translate([' ' : "_"]), +                        a, +                      ); +                    } +                  } +                  topics ~= format(q"┃<p class="work"><a href="%s">%s</a> - %s [<a href="%s"> %s </a>]┃", +                    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"┃<p class="lev2"><a name="%s.%s.%s" class="lev2">%s</a></p>┃", +                  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"┃ <a href="authors.html#%s">%s</a>┃", +                        t_a_.author_surname.translate([' ' : "_"]), +                        t_a_.author, +                      ); +                    } else { +                      foreach (a; t_a_.author_arr) { +                        _auth ~= format(q"┃ <a href="authors.html#%s">%s</a>,┃", +                          t_a_.author_surname.translate([' ' : "_"]), +                          a, +                        ); +                      } +                    } +                    topics ~= format(q"┃<p class="work"><a href="%s">%s</a> - %s [<a href="%s"> %s </a>]┃", +                      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"┃<p class="lev3"><a name="%s.%s.%s.%s" class="lev3">%s</a></p>┃", +                    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"┃<a href="authors.html#%s">%s</a>┃", +                          t_a_.author_surname.translate([' ' : "_"]), +                          t_a_.author, +                        ); +                      } else { +                        foreach (a; t_a_.author_arr) { +                          _auth ~= format(q"┃ <a href="authors.html#%s">%s</a>,┃", +                            t_a_.author_surname.translate([' ' : "_"]), +                            a, +                          ); +                        } +                      } +                      topics ~= format(q"┃ <p class="work"><a href="%s">%s</a> - %s [<a href="%s"> %s </a>]┃", +                        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"┃ +<hr /> +<a name="bottom" id="bottom"></a> +<a name="down" id="down"></a> +<a name="end" id="end"></a> +<a name="finish" id="finish"></a> +<a name="stop" id="stop"></a> +<a name="credits"></a> +</body> +</html> +┃") ~ "\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<link>(?P<ocn>[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<last>\S.+?),\s+(?P<first>.+)`,"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<level>[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<anchor>[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<indent>[1-9])[*] `); +    static para_indent                              = ctRegex!(`^_(?P<indent>[1-9])[ ]`); +    static para_indent_hang                         = ctRegex!(`^_(?P<hang>[0-9])_(?P<indent>[0-9])[ ]`); +    static para_attribs                             = ctRegex!(`^_(?:(?:[0-9])(?:_([0-9]))?|(?:[1-9])?[*]) `); +    static para_inline_link_anchor                  = ctRegex!(`\*[~](?P<anchor>[a-z0-9_.-]+)(?= |$)`,"i"); +    /+ blocked markup +/ +    static block_open                               = ctRegex!("^((code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|^`{3} (code(?:[.][a-z][0-9a-z#+_]+)?|(?:poem|group|block|quote)(?:[.][a-z][0-9a-z_]+)?|table)(?:[(][ a-zA-Z0-9;:,]*[)])?|^[{]table[(](?:h;)?(?P<columns>(?:[ ,]+[0-9]+)+)[)][}]"); +    static block_poem_open                          = ctRegex!("^((poem(?:[(][ a-zA-Z0-9;:,]*[)])?[{][ ]*$)|`{3} poem(?:[(][ a-zA-Z0-9;:,]*[)])?)"); +    /+ blocked markup tics +/ +    static block_tic_code_open                      = ctRegex!("^`{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); +    static block_tic_poem_open                      = ctRegex!("^`{3} poem(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); +    static block_tic_group_open                     = ctRegex!("^`{3} group(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); +    static block_tic_block_open                     = ctRegex!("^`{3} block(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); +    static block_tic_quote_open                     = ctRegex!("^`{3} quote(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); +    static block_tic_table_open                     = ctRegex!("^`{3} table(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?"); // ctRegex!("^`{3} table(?:\(.*?\))?"); +    static block_tic_close                          = ctRegex!("^(`{3})$","m"); +    /+ blocked markup curly +/ +    static block_curly_code_open                    = ctRegex!(`^(?:code(?:[.](?P<syntax>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +    static block_curly_code_close                   = ctRegex!(`^([}]code)`); +    static block_curly_poem_open                    = ctRegex!(`^(poem(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +    static block_curly_poem_close                   = ctRegex!(`^([}]poem)`); +    static block_curly_group_open                   = ctRegex!(`^(group(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +    static block_curly_group_close                  = ctRegex!(`^([}]group)`); +    static block_curly_block_open                   = ctRegex!(`^(block(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +    static block_curly_block_close                  = ctRegex!(`^([}]block)`); +    static block_curly_quote_open                   = ctRegex!(`^(quote(?:[.](?P<lang>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +    static block_curly_quote_close                  = ctRegex!(`^([}]quote)`); +    static block_curly_table_open                   = ctRegex!(`^table(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$`); +    static block_curly_table_close                  = ctRegex!(`^([}]table)`); +    static block_curly_table_special_markup         = ctRegex!(`^[{]table[(](?P<attrib>(?:(h);)?(?P<columns>(?:[, ]+[0-9]+)+))[)][}]`, "mg"); +    static code_numbering                           = ctRegex!(`(?P<number>\blinenumber\b|\bnumber\b|\blnr\b)`); +    static table_head_instructions                  = ctRegex!(`(?:(?P<c_heading>h);)?(?:[ ]+c(?P<c_num>[0-9]):)?(?P<c_widths>(?:[, ]+[0-9]+[lr]?)+)`); +    static table_col_widths_and_alignment           = ctRegex!(`(?P<width>[0-9]+)(?P<align>[lr]?)`); +    static table_col_widths                         = ctRegex!(`(?P<widths>[0-9]+)`); +    static table_col_align_match                    = ctRegex!(`(?P<align>[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<ref>[0-9]+)`, "mg");     // {^{73.}^}#noteref_73 +    static smid_inline_url_generic                        = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); +    static smid_inline_url                                = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); +    static smid_inline_link_naked_url                     = ctRegex!(`(?P<pre>^|[ (\[])(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?=[.,;:?!'"]?([ )\]]|$))`, "mg"); +    static smid_inline_link_markup_regular                = ctRegex!(`(?P<pre>^|[ (\[])\{\s*(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); +    static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); +    static smid_inline_link_endnote_url_helper            = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); +    static image                                    = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); +    static smid_image                               = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); +    static smid_image_generic                       = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); +    static smid_image_with_dimensions               = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.*?)\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<pre>^|[ ])\{\s*(?P<text>.+?)\s*\}(?:image)(?=[;:!,?.]?([ )\]]|$))`, "mg"); +    /+ inline markup book index +/ +    static book_index_item                          = ctRegex!(`^=\{\s*(?P<bookindex>.+?)\}$`, "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<keep_spaces>^[ ]+|[ ]{2,})`, "mg"); // code, verse, block +    static spaces_line_start                        = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg"); +    static nbsp_char                                = ctRegex!(`░`, "mg"); +    static nbsp_chars                               = ctRegex!(`[░]+`, "mg"); +    static middle_dot                               = ctRegex!(`·`, "mg"); +    static src_pth_sst_or_ssm                       = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`); +    static src_pth_pod_sst_or_ssm                   = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`); +    static src_pth_contents                         = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`); +    static src_pth_zip                              = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); +    static src_pth_types                            = ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/pod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); +    static src_fn                                   = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); +    static src_fn_master                            = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); +    static src_fn_find_inserts                      = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); +    static insert_src_fn_ssi_or_sst                 = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); +    static src_base_parent_dir_name                 = ctRegex!(`[/](?P<dir>(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure +    static src_formalised_file_path_parts           = ctRegex!(`(?P<pth>(?:[/a-zA-Z0-9._-]+?)(?P<dir>[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<text>.+?)】`, "m"); +    static inline_notes_al_all_note                 = ctRegex!(`【(?P<num>\d+|(?:[*]|[+])+)\s+(?P<note>.+?)\s*】`, "mg"); +    static inline_notes_al_regular_number_note      = ctRegex!(`【(?P<num>\d+)\s+(?P<note>.+?)\s*】`, "mg"); +    static inline_notes_al_special_char_note        = ctRegex!(`【(?P<char>(?:[*]|[+])+)\s+(?P<note>.+?)】`, "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<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +    static inline_image_without_dimensions          = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +    static inline_image_info                        = ctRegex!(`☼?(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+)`, "mg"); +    static inline_link_anchor                       = ctRegex!(`┃(?P<anchor>\S+?)┃`, "mg"); // TODO *~text_link_anchor +    static inline_link                              = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#?(\S+?))├`, "mg"); +    static inline_link_empty                        = ctRegex!(`┥(?P<text>.+?)┝┤├`, "mg"); +    static inline_link_number                       = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used +    static inline_link_number_only                  = ctRegex!(`(?P<linked_text>┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); +    static inline_link_stow_uri                     = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links +    static inline_link_hash                         = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<hash>\S+?))├`, "mg"); +    static inline_link_seg_and_hash                 = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); +    static inline_link_clean                        = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); +    static inline_link_toc_to_backmatter            = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); +    static url                                      = ctRegex!(`https?://`, "mg"); +    static uri                                      = ctRegex!(`(?:https?|git)://`, "mg"); +    static uri_identify_components                  = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); +    static inline_link_subtoc                       = ctRegex!(`^(?P<level>[5-7])~ ┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "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<mark>[*])\{(?P<text>.+?)\}[*]`, "mg"); +    static inline_mark_bold                         = ctRegex!(`(?P<mark>[!])\{(?P<text>.+?)\}[!]`, "mg"); +    static inline_mark_underscore                   = ctRegex!(`(?P<mark>[_])\{(?P<text>.+?)\}[_]`, "mg"); +    static inline_mark_italics                      = ctRegex!(`(?P<mark>[/])\{(?P<text>.+?)\}[/]`, "mg"); +    static inline_mark_superscript                  = ctRegex!(`(?P<mark>\^)\{(?P<text>.+?)\}\^`, "mg"); +    static inline_mark_subscript                    = ctRegex!(`(?P<mark>[,])\{(?P<text>.+?)\}[,]`, "mg"); +    static inline_mark_strike                       = ctRegex!(`(?P<mark>[-])\{(?P<text>.+?)\}[-]`, "mg"); +    static inline_mark_insert                       = ctRegex!(`(?P<mark>[+])\{(?P<text>.+?)\}[+]`, "mg"); +    static inline_mark_mono                         = ctRegex!(`(?P<mark>[#])\{(?P<text>.+?)\}[#]`, "mg"); +    static inline_mark_cite                         = ctRegex!(`(?P<mark>["])\{(?P<text>.+?)\}["]`, "mg"); +    static inline_faces_line                        = ctRegex!(`^[*!/_]_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); +    static inline_emphasis_line                     = ctRegex!(`^\*_ (?P<text>.+?)(?P<tail>(?: [\\]{2}|[~]#){0,2}$)`); +    static inline_bold_line                         = ctRegex!(`^!_ (?P<text>.+?)(?P<tail>(?: [\\]{2}|[~]#){0,2}$)`); +    static inline_italics_line                      = ctRegex!(`^/_ (?P<text>.+?)(?P<tail>(?: [\\]{2}|[~]#){0,2}$)`); +    static inline_underscore_line                   = ctRegex!(`^__ (?P<text>.+?)(?P<tail>(?: [\\]{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<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`); +    static src_pth_pod_sst_or_ssm                   = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`); +    static src_pth_contents                         = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`); +    static src_pth_zip                              = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); +    static src_pth_types                            = ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/pod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); +    static src_fn                                   = ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); +    static src_fn_master                            = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); +    static src_fn_find_inserts                      = ctRegex!(`^(?P<path>/?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); +    static insert_src_fn_ssi_or_sst                 = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); +    static src_base_parent_dir_name                 = ctRegex!(`[/](?P<dir>(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure +    static src_formalised_file_path_parts           = ctRegex!(`(?P<pth>(?:[/a-zA-Z0-9._-]+?)(?P<dir>[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure +    /+ language codes +/ +    auto language_code_and_filename                                    = +       ctRegex!("(?:^|[/])(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$"); +  } +} diff --git a/src/sisudoc/meta/rgx_yaml_tags.d b/src/sisudoc/meta/rgx_yaml_tags.d new file mode 100644 index 0000000..6266bac --- /dev/null +++ b/src/sisudoc/meta/rgx_yaml_tags.d @@ -0,0 +1,62 @@ +/+ +- Name: SisuDoc Spine, Doc Reform [a part of] +  - Description: documents, structuring, processing, publishing, search +    - static content generator + +  - Author: Ralph Amissah +    [ralph.amissah@gmail.com] + +  - Copyright: (C) 2015 - 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_yaml; +@safe: +static template spineRgxYamlTags() { +  static struct RgxYaml { +    static yaml_tag_is_str                          = ctRegex!(`:str$`); +    static yaml_tag_is_int                          = ctRegex!(`:int$`); +    static yaml_tag_is_map                          = ctRegex!(`:map$`); +    static yaml_tag_is_seq                          = ctRegex!(`:seq$`); +  } +} diff --git a/src/sisudoc/share/defaults.d b/src/sisudoc/share/defaults.d new file mode 100644 index 0000000..f6303c8 --- /dev/null +++ b/src/sisudoc/share/defaults.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/] + ++/ +/++ +  shared default settings ++/ +module sisudoc.share.defaults; +@safe: +template Msg() { +  import std.stdio; +  auto Msg(I)(I doc_matters) { +    struct Msg_ { +      void v()(string message) { +        if (doc_matters.opt.action.vox_gt1) { +          writeln(message); +        } +      } +      void vv()(string message) { +        if (doc_matters.opt.action.vox_gt2) { +          writeln(message); +        } +      } +    } +    return Msg_(); +  } +} diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d new file mode 100755 index 0000000..b79bc54 --- /dev/null +++ b/src/sisudoc/spine.d @@ -0,0 +1,1272 @@ +#!/usr/bin/env rdmd +/+ +- 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.sisu_document_parser; +/++ +name        "spine" +description "A SiSU inspired document parser written in D." +homepage    "https://sisudoc.org" ++/ +@safe: +import +  std.algorithm, +  std.datetime, +  std.getopt, +  std.file, +  std.path, +  std.process; +import +  sisudoc.conf.compile_time_info, +  sisudoc.meta, +  sisudoc.meta.metadoc, +  sisudoc.meta.metadoc_curate, +  sisudoc.meta.metadoc_curate_authors, +  sisudoc.meta.metadoc_curate_topics, +  sisudoc.meta.metadoc_from_src, +  sisudoc.meta.conf_make_meta_structs, +  sisudoc.meta.conf_make_meta_json, +  sisudoc.meta.defaults, +  sisudoc.meta.doc_debugs, +  sisudoc.meta.rgx, +  sisudoc.meta.rgx_yaml, +  sisudoc.meta.rgx_files, +  sisudoc.io_in.paths_source, +  sisudoc.io_in.read_config_files, +  sisudoc.io_in.read_source_files, +  sisudoc.io_out.hub; +mixin(import("version.txt")); +mixin(import("configuration.txt")); +mixin CompileTimeInfo; +string project_name = "spine"; +string program_name = "spine"; +@system void main(string[] args) { +  mixin spineRgxIn; +  mixin spineRgxYamlTags; +  mixin spineRgxFiles; +  mixin spineBiblio; +  mixin outputHub; +  auto hvst = spineCurateMetadata!(); +  string flag_action; +  string arg_unrecognized; +  enum dAM { abstraction, matters } +  static auto rgx = RgxI(); +  static auto rgx_y = RgxYaml(); +  static auto rgx_files = RgxFiles(); +  scope(success) { +    writefln( +      "~ run complete, ok ~ (%s-%s.%s.%s, %s D:%s, %s %s)", +      program_name, +      _ver.major, _ver.minor, _ver.patch, +      __VENDOR__, __VERSION__, +      bits, os, +    ); +  } +  scope(failure) { +    debug(checkdoc) { +      stderr.writefln( +        "run failure", +      ); +    } +  } +  bool[string] opts = [ +    "abstraction"                 : false, +    "allow-downloads"             : false, +    "assertions"                  : false, +    "concordance"                 : false, +    "dark"                        : false, +    "debug"                       : false, +    "debug-curate"                : false, +    "debug-curate-authors"        : false, +    "debug-curate-topics"         : false, +    "debug-epub"                  : false, +    "debug-harvest"               : false, +    "debug-html"                  : false, +    "debug-latex"                 : false, +    "debug-manifest"              : false, +    "debug-metadata"              : false, +    "debug-pod"                   : false, +    "debug-sqlite"                : false, +    "debug-stages"                : false, +    "digest"                      : false, +    "epub"                        : false, +    "generated-by"                : false, +    "curate"                      : false, +    "curate-authors"              : false, +    "curate-topics"               : false, +    "html"                        : false, +    "html-link-curate"            : false, +    "html-link-markup"            : false, +    "html-link-pdf"               : false, +    "html-link-pdf-a4"            : false, +    "html-link-pdf-letter"        : false, +    "html-link-search"            : false, +    "html-seg"                    : false, +    "html-scroll"                 : false, +    "latex"                       : false, +    "latex-color-links"           : false, +    "latex-init"                  : false, +    "latex-header-sty"            : false, +    "light"                       : false, +    "manifest"                    : false, +    "hide-ocn"                    : false, +    "ocn-off"                     : false, +    "odf"                         : false, +    "odt"                         : false, +    "parallel"                    : false, +    "parallel-subprocesses"       : false, +    "pdf"                         : false, +    "pdf-color-links"             : false, +    "pdf-init"                    : false, +    "pod"                         : false, +    "serial"                      : false, +    "show-config"                 : false, +    "show-curate"                 : false, +    "show-curate-authors"         : false, +    "show-curate-topics"          : false, +    "show-epub"                   : false, +    "show-html"                   : false, +    "show-latex"                  : false, +    "show-make"                   : false, +    "show-manifest"               : false, +    "show-metadata"               : false, +    "show-pod"                    : false, +    "show-sqlite"                 : false, +    "show-summary"                : false, +    "source"                      : false, +    "sqlite-discrete"             : false, +    "sqlite-db-create"            : false, +    "sqlite-db-drop"              : false, +    "sqlite-db-recreate"          : false, +    "sqlite-delete"               : false, +    "sqlite-insert"               : false, +    "sqlite-update"               : false, +    "text"                        : false, +    "vox_is0"                     : false, +    "vox_gt1"                     : false, +    "vox_gt2"                     : false, +    "xhtml"                       : false, +    "section_toc"                 : true, +    "section_body"                : true, +    "section_endnotes"            : true, +    "section_glossary"            : true, +    "section_biblio"              : true, +    "section_bookindex"           : true, +    "section_blurb"               : true, +    "backmatter"                  : true, +    "skip-output"                 : false, +    "theme-dark"                  : false, +    "theme-light"                 : false, +    "workon"                      : false, +  ]; +  string[string] settings = [ +    "output"                      : "", +    "www-http"                    : "", +    "www-host"                    : "", +    "www-host-doc-root"           : "", +    "www-url-doc-root"            : "", +    "cgi-http"                    : "", +    "cgi-host"                    : "", +    "cgi-bin-root"                : "", +    "cgi-sqlite-search-filename"  : "", +    "cgi-url-root"                : "", +    "cgi-url-action"              : "", +    "cgi-search-title"            : "", +    "config"                      : "", +    "lang"                        : "all", +    "set-papersize"               : "", +    "set-textwrap"                : "", +    "set-digest"                  : "", +    "sqlite-db-path"              : "", +    "sqlite-db-filename"          : "", +  ]; +  auto helpInfo = getopt(args, +    std.getopt.config.passThrough, +    "abstraction",                "document abstraction",                                           &opts["abstraction"], +    "allow-downloads",            "allow downloads (includes cgi.d from github)",                   &opts["allow-downloads"], +    "assert",                     "set optional assertions on",                                     &opts["assertions"], +    "cgi-bin-root",               "path to cgi-bin directory",                                      &settings["cgi-bin-root"], +    "cgi-url-root",               "url to cgi-bin (to find cgi-bin)",                               &settings["cgi-url-root"], +    "cgi-url-action",             "url to post to cgi-bin search form",                             &settings["cgi-url-action"], +    "cgi-search-title",           "if generating a cgi search form the title to use for it",        &settings["cgi-search-title"], +    "cgi-sqlite-search-filename", "=[filename] default is spine-search",                            &settings["cgi-sqlite-search-filename"], +    "concordance",                "file for document",                                              &opts["concordance"], +    "curate",                     "extract info on authors & topics from document header metadata", &opts["curate"], +    "curate-authors",             "extract info on authors from document header metadata",          &opts["curate-authors"], +    "curate-topics",              "extract info on topics from document header metadata",           &opts["curate-topics"], +    "dark",                       "alternative dark theme",                                         &opts["dark"], +    "digest",                     "hash digest for each object",                                    &opts["digest"], +    "epub",                       "process epub output",                                            &opts["epub"], +    "generated-by",               "generated by headers (software version & time)",                 &opts["generated-by"], +    "hide-ocn",                   "object cite numbers",                                            &opts["hide-ocn"], +    "html",                       "process html output",                                            &opts["html"], +    "html-link-curate",           "place links back to curate in segmented html",                   &opts["html-link-curate"], +    "html-link-markup",           "provide html link to markup source, shared optionally",          &opts["html-link-markup"], +    "html-link-pdf",              "provide html link to pdf a4 & letter output",                    &opts["html-link-pdf"], +    "html-link-pdf-a4",           "provide html link to pdf a4 output",                             &opts["html-link-pdf-a4"], +    "html-link-pdf-letter",       "provide html link to pdf letter size output",                    &opts["html-link-pdf-letter"], +    "html-link-search",           "html embedded search submission",                                &opts["html-link-search"], +    "html-seg",                   "process html output",                                            &opts["html-seg"], +    "html-scroll",                "process html output",                                            &opts["html-scroll"], +    "lang",                       "=[lang code e.g. =en or =en,es]",                                &settings["lang"], +    "latex",                      "latex output (for pdfs)",                                        &opts["latex"], +    "latex-color-links",          "mono or color links for pdfs",                                   &opts["latex-color-links"], +    "latex-init",                 "initialise latex shared files (see latex-header-sty)",           &opts["latex-init"], +    "latex-header-sty",           "latex document header sty files",                                &opts["latex-header-sty"], +    "light",                      "default light theme",                                            &opts["light"], +    "manifest",                   "process manifest output",                                        &opts["manifest"], +    "ocn-off",                    "object cite numbers",                                            &opts["ocn-off"], +    "odf",                        "open document format text (--odt)",                              &opts["odf"], +    "odt",                        "open document format text",                                      &opts["odt"], +    "output",                     "=/path/to/output/dir specify where to place output",             &settings["output"], +    "parallel",                   "parallelisation",                                                &opts["parallel"], +    "parallel-subprocesses",      "nested parallelisation",                                         &opts["parallel-subprocesses"], +    "pdf",                        "latex output for pdfs",                                          &opts["pdf"], +    "pdf-color-links",            "mono or color links for pdfs",                                   &opts["pdf-color-links"], +    "pdf-init",                   "initialise latex shared files (see latex-header-sty)",           &opts["pdf-init"], +    "pod",                        "spine (doc reform) pod source content bundled",                  &opts["pod"], +    "quiet|q",                    "output to terminal",                                             &opts["vox_is0"], +    "section-backmatter",         "document backmatter (default)" ,                                 &opts["backmatter"], +    "section-biblio",             "document biblio (default)",                                      &opts["section_biblio"], +    "section-blurb",              "document blurb (default)",                                       &opts["section_blurb"], +    "section-body",               "document body (default)",                                        &opts["section_body"], +    "section-bookindex",          "document bookindex (default)",                                   &opts["section_bookindex"], +    "section-endnotes",           "document endnotes (default)",                                    &opts["section_endnotes"], +    "section-glossary",           "document glossary (default)",                                    &opts["section_glossary"], +    "section-toc",                "table of contents (default)",                                    &opts["section_toc"], +    "serial",                     "serial processing",                                              &opts["serial"], +    "skip-output",                "skip output",                                                    &opts["skip-output"], +    "show-config",                "show config",                                                    &opts["show-config"], +    "show-curate",                "show curate",                                                    &opts["show-curate"], +    "show-curate-authors",        "show curate authors",                                            &opts["show-curate-authors"], +    "show-curate-topics",         "show curate topics",                                             &opts["show-curate-topics"], +    "show-epub",                  "show epub",                                                      &opts["show-epub"], +    "show-html",                  "show html",                                                      &opts["show-html"], +    "show-latex",                 "show latex",                                                     &opts["show-latex"], +    "show-make",                  "show make",                                                      &opts["show-make"], +    "show-manifest",              "show manifest",                                                  &opts["show-manifest"], +    "show-metadata",              "show metadata",                                                  &opts["show-metadata"], +    "show-pod",                   "show pod",                                                       &opts["show-pod"], +    "show-sqlite",                "show sqlite",                                                    &opts["show-sqlite"], +    "show-summary",               "show summary",                                                   &opts["show-summary"], +    "source",                     "document markup source",                                         &opts["source"], +    "set-digest",                 "default hash digest type (e.g. sha256)",                         &settings["set-digest"], +    "set-papersize",              "default papersize (latex pdf eg. a4 or a5 or b4 or letter)",     &settings["set-papersize"], +    "set-textwrap",               "default textwrap (e.g. 80 (characters)",                         &settings["set-textwrap"], +    "sqlite-discrete",            "process discrete sqlite output",                                 &opts["sqlite-discrete"], +    "sqlite-db-create",           "create db, create tables",                                       &opts["sqlite-db-create"], +    "sqlite-db-drop",             "drop tables & db",                                               &opts["sqlite-db-drop"], +    "sqlite-db-filename",         "sqlite db to create, populate & make available for search",      &settings["sqlite-db-filename"], +    "sqlite-db-path",             "sqlite db path",                                                 &settings["sqlite-db-path"], +    "sqlite-db-recreate",         "create db, create tables",                                       &opts["sqlite-db-recreate"], +    "sqlite-delete",              "sqlite output",                                                  &opts["sqlite-delete"], +    "sqlite-insert",              "sqlite output",                                                  &opts["sqlite-insert"], +    "sqlite-update",              "sqlite output",                                                  &opts["sqlite-update"], +    "www-http",                   "http or https",                                                  &settings["www-http"], +    "www-host",                   "web server host (domain) name",                                  &settings["www-host"], +    "www-host-doc-root",          "web host host (domain) name with path to doc root",              &settings["www-host-doc-root"], +    "www-url-doc-root",           "e.g. http://localhost",                                          &settings["www-url-doc-root"], +    "text",                       "text output",                                                    &opts["text"], +    "theme-dark",                 "alternative dark theme",                                         &opts["theme-dark"], +    "theme-light",                "default light theme",                                            &opts["theme-light"], +    "txt",                        "text output",                                                    &opts["text"], +    "verbose|v",                  "output to terminal",                                             &opts["vox_gt1"], +    "very-verbose",               "output to terminal",                                             &opts["vox_gt2"], +    "workon",                     "(reserved for some matters under development & testing)",        &opts["workon"], +    "xhtml",                      "xhtml output",                                                   &opts["xhtml"], +    "config",                     "=/path/to/config/file/including/filename",                       &settings["config"], +    "debug",                      "debug",                                                          &opts["debug"], +    "debug-curate",               "debug curate",                                                   &opts["debug-curate"], +    "debug-curate-authors",       "debug curate authors",                                           &opts["debug-curate-authors"], +    "debug-curate-topics",        "debug curate topics",                                            &opts["debug-curate-topics"], +    "debug-epub",                 "debug epub",                                                     &opts["debug-epub"], +    "debug-harvest",              "debug harvest",                                                  &opts["debug-harvest"], +    "debug-html",                 "debug html",                                                     &opts["debug-html"], +    "debug-latex",                "debug latex",                                                    &opts["debug-latex"], +    "debug-manifest",             "debug manifest",                                                 &opts["debug-manifest"], +    "debug-metadata",             "debug metadata",                                                 &opts["debug-metadata"], +    "debug-pod",                  "debug pod",                                                      &opts["debug-pod"], +    "debug-sqlite",               "debug sqlite",                                                   &opts["debug-sqlite"], +    "debug-stages",               "debug stages",                                                   &opts["debug-stages"], +    // "sqlite-db-filename",         "=[filename].sql.db",                                             &settings["sqlite-db-filename"], +  ); +  if (helpInfo.helpWanted) { +    defaultGetoptPrinter("Some information about the program.", helpInfo.options); +  } +  enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } +  struct OptActions { +    @trusted bool allow_downloads() { +      return opts["allow-downloads"]; +    } +    @trusted bool assertions() { +      return opts["assertions"]; +    } +    @trusted bool concordance() { +      return opts["concordance"]; +    } +    @trusted string config_path_set() { +      return settings["config"]; +    } +    @trusted bool css_theme_default() { +      bool _is_light; +      if (opts["light"] || opts["theme-light"]) { +        _is_light = true; +      } else if (opts["dark"] || opts["theme-dark"]) { +        _is_light = false; +      } else { +        _is_light = true; +      } +      return _is_light; +    } +    @trusted bool debug_do() { +      bool _dbg; +      if (opts["debug"]) { +        _dbg = true; +      } else { _dbg = false; } +      return _dbg; +    } +    @trusted bool debug_do_curate() { +      return (opts["debug"] || opts["debug-curate"]) ? true : false; +    } +    @trusted bool debug_do_curate_authors() { +      return (opts["debug"] || opts["debug-curate"] || opts["debug-curate-authors"]) ? true : false; +    } +    @trusted bool debug_do_curate_topics() { +      return (opts["debug"] || opts["debug-curate"] || opts["debug-curate-topics"]) ? true : false; +    } +    @trusted bool debug_do_epub() { +      return (opts["debug"] || opts["debug-epub"]) ? true : false; +    } +    @trusted bool debug_do_harvest() { +      return (opts["debug"] || opts["debug-harvest"]) ? true : false; +    } +    @trusted bool debug_do_html() { +      return (opts["debug"] || opts["debug-html"]) ? true : false; +    } +    @trusted bool debug_do_latex() { +      return (opts["debug"] || opts["debug-latex"]) ? true : false; +    } +    @trusted bool debug_do_manifest() { +      return (opts["debug"] || opts["debug-manifest"]) ? true : false; +    } +    @trusted bool debug_do_metadata() { +      return (opts["debug"] || opts["debug-metadata"]) ? true : false; +    } +    @trusted bool debug_do_pod() { +      return (opts["debug"] || opts["debug-pod"]) ? true : false; +    } +    @trusted bool debug_do_sqlite() { +      return (opts["debug"] || opts["debug-sqlite"]) ? true : false; +    } +    @trusted bool debug_do_stages() { +      return (opts["debug"] || opts["debug-stages"]) ? true : false; +    } +    @trusted bool debug_do_xmls() { +      return (opts["debug"] || opts["debug-html"] || opts["debug-epub"]) ? true : false; +    } +    @trusted bool curate() { +      return (opts["curate"] || opts["curate-authors"] || opts["curate-topics"]) ? true : false; +    } +    @trusted bool curate_authors() { +      return (opts["curate"] || opts["curate-authors"]) ? true : false; +    } +    @trusted bool curate_topics() { +      return (opts["curate"] || opts["curate-topics"]) ? true : false; +    } +    @trusted bool digest() { +      return opts["digest"]; +    } +    @trusted bool epub() { +      return opts["epub"]; +    } +    @trusted bool generated_by() { +      return opts["generated-by"]; +    } +    @trusted bool html_link_curate() { +      return (opts["html-link-curate"]) ? true : false; +    } +    @trusted bool html_link_markup_source() { +      return (opts["html-link-markup"]) ? true : false; +    } +    @trusted bool html_link_pdf() { +      return (opts["html-link-pdf"]) ? true : false; +    } +    @trusted bool html_link_pdf_a4() { +      return (opts["html-link-pdf-a4"]) ? true : false; +    } +    @trusted bool html_link_pdf_letter() { +      return (opts["html-link-pdf-letter"]) ? true : false; +    } +    @trusted bool html_link_search() { +      return (opts["html-link-search"]) ? true : false; +    } +    @trusted bool html() { +      return (opts["html"] || opts["html-seg"] || opts["html-scroll"]) ? true : false; +    } +    @trusted bool html_seg() { +      return (opts["html"] || opts["html-seg"]) ? true : false; +    } +    @trusted bool html_scroll() { +      return (opts["html"] || opts["html-scroll"]) ? true : false; +    } +    @trusted bool html_stuff() { +      return (opts["html"] || opts["html-scroll"] || opts["html-seg"]) ? true : false; +    } +    @trusted bool latex() { +      return (opts["latex"] || opts["pdf"]) ? true : false; +    } +    @trusted bool latex_color_links() { +      return (opts["latex-color-links"] || opts["pdf-color-links"]) ? true : false; +    } +    @trusted bool latex_document_header_sty() { +      return (opts["latex-init"] || opts["latex-header-sty"] || opts["pdf-init"]) ? true : false; +    } +    @trusted bool manifest() { +      return opts["manifest"]; +    } +    @trusted bool odt() { +      return (opts["odf"] || opts["odt"]) ? true : false; +    } +    @trusted bool ocn_hidden() { +      return opts["hide-ocn"]; +    } +    @trusted bool ocn_off() { +      return opts["ocn-off"]; +    } +    @trusted bool pod() { +      return opts["pod"]; +    } +    @trusted bool show_config() { +      return opts["show-config"]; +    } +    @trusted bool show_curate() { +      return opts["show-curate"]; +    } +    @trusted bool show_curate_authors() { +      return (opts["show-curate"] || opts["show-curate-authors"] || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool show_curate_topics() { +      return (opts["show-curate"] || opts["show-curate-topics"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool show_epub() { +      return opts["show-epub"]; +    } +    @trusted bool show_html() { +      return opts["show-html"]; +    } +    @trusted bool show_latex() { +      return opts["show-latex"]; +    } +    @trusted bool show_make() { +      return opts["show-make"]; +    } +    @trusted bool show_manifest() { +      return opts["show-manifest"]; +    } +    @trusted bool show_metadata() { +      return opts["show-metadata"]; +    } +    @trusted bool show_pod() { +      return opts["show-pod"]; +    } +    @trusted bool show_sqlite() { +      return (opts["show-sqlite"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool show_summary() { +      return (opts["show-summary"] || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool source() { +      return opts["source"]; +    } +    @trusted bool source_or_pod() { +      return (opts["pod"] || opts["source"]) ? true : false; +    } +    @trusted bool sqlite_discrete() { +      return opts["sqlite-discrete"]; +    } +    @trusted bool sqlite_db_drop() { +      return (opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) ? true : false; +    } +    @trusted bool sqlite_db_create() { +      return (opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) ? true : false; +    } +    @trusted bool sqlite_delete() { +      return opts["sqlite-delete"]; +    } +    @trusted bool sqlite_update() { +      return (opts["sqlite-update"] || opts["sqlite-insert"]) ? true : false; +    } +    @trusted bool sqlite_shared_db_action() { +      return ( +        opts["sqlite-db-recreate"] +        || opts["sqlite-db-create"] +        || opts["sqlite-delete"] +        || opts["sqlite-insert"] +        || opts["sqlite-update"] +      ) ? true : false; +    } +    @trusted bool vox_is0() { // --quiet -q +      return opts["vox_is0"]; +    } +    @trusted bool vox_gt0() { // normal, minimal, without flag +      return (!(opts["vox_is0"]) || opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool vox_gt1() { // -- verbose -v +      return (opts["vox_gt1"] || opts["vox_gt2"]) ? true : false; +    } +    @trusted bool vox_gt2() { // --very-verbose +      return opts["vox_gt2"]; +    } +    @trusted bool text() { +      return opts["text"]; +    } +    @trusted bool xhtml() { +      return opts["xhtml"]; +    } +    @trusted bool section_toc() { +      return opts["section_toc"]; +    } +    @trusted bool section_body() { +      return opts["section_body"]; +    } +    @trusted bool section_endnotes() { +      return opts["section_endnotes"]; +    } +    @trusted bool section_glossary() { +      return opts["section_glossary"]; +    } +    @trusted bool section_biblio() { +      return opts["section_biblio"]; +    } +    @trusted bool section_bookindex() { +      return opts["section_bookindex"]; +    } +    @trusted bool section_blurb() { +      return opts["section_blurb"]; +    } +    @trusted bool backmatter() { +      return opts["backmatter"]; +    } +    @trusted bool skip_output() { +      return opts["skip-output"]; +    } +    @trusted bool workon() { +      return opts["workon"]; +    } +    @trusted string[] languages_set() { +      return settings["lang"].split(","); +    } +    @trusted string output_dir_set() { +      return settings["output"]; +    } +    @trusted string sqliteDB_filename() { +      return settings["sqlite-db-filename"]; +    } +    @trusted string sqliteDB_path() { +      return settings["sqlite-db-path"]; +    } +    @trusted string cgi_bin_root() { +      return settings["cgi-bin-root"]; +    } +    @trusted string cgi_search_title() { +      return settings["cgi-search-title"]; +    } +    @trusted string cgi_sqlite_search_filename() { +      return settings["cgi-sqlite-search-filename"]; +    } +    @trusted string cgi_sqlite_search_filename_d() { +      return (settings["cgi-sqlite-search-filename"].length > 0) +      ? (settings["cgi-sqlite-search-filename"].translate(['-' : "_"]) ~ ".d") +      : ""; +    } +    @trusted string cgi_url_root() { +      return settings["cgi-url-root"]; +    } +    @trusted string cgi_url_action() { +      return settings["cgi-url-action"]; +    } +    @trusted string hash_digest_type() { +      return settings["set-digest"]; +    } +    @trusted string text_wrap() { +      return settings["set-textwrap"]; +    } +    @trusted string latex_papersize() { +      return settings["set-papersize"]; +    } +    @trusted string webserver_host_name() { +      return settings["www-host"]; +    } +    @trusted string webserver_host_doc_root() { +      return settings["www-host-doc-root"]; +    } +    @trusted string webserver_url_doc_root() { +      return settings["www-url-doc-root"]; +    } +    @trusted string webserver_http() { +      return settings["www-http"]; +    } +    @trusted bool parallelise() { +      bool _is; +      if (opts["serial"] == true) { +        _is = false; +      } else if (sqlite_shared_db_action) { +        _is = false; +      } else if (opts["parallel"] == true) { +        _is = true; +        if (sqlite_shared_db_action) { _is = false; } +      } else if ( +        opts["abstraction"] +        || concordance +        || curate +        || html +        || epub +        || odt +        || latex +        || manifest +        || source_or_pod +        || sqlite_discrete +      ) { +        _is = true; +      } else { _is = false; } +      return _is; +    } +    @trusted bool parallelise_subprocesses() { +      return opts["parallel-subprocesses"]; +    } +    auto output_task_scheduler() { +      int[] schedule; +      if (source_or_pod) { +        schedule ~= outTask.source_or_pod; +      } +      if (sqlite_discrete) { +        schedule ~= outTask.sqlite; +      } +      if (epub) { +        schedule ~= outTask.epub; +      } +      if (html_scroll) { +        schedule ~= outTask.html_scroll; +      } +      if (html_seg) { +        schedule ~= outTask.html_seg; +      } +      if (html_stuff) { +        schedule ~= outTask.html_stuff; +      } +      if (odt) { +        schedule ~= outTask.odt; +      } +      if (latex) { +        schedule ~= outTask.latex; +      } +      return schedule.sort().uniq; +    } +    @trusted bool abstraction() { +      return ( +        opts["abstraction"] +        || concordance +        || source_or_pod +        || curate +        || html +        || epub +        || odt +        || latex +        || manifest +        || sqlite_discrete +        || sqlite_delete +        || sqlite_update +      ) ? true : false; +    } +    @trusted bool require_processing_files() { +      return ( +        opts["abstraction"] +        || epub +        || curate +        || html +        || html_seg +        || html_scroll +        || latex +        || odt +        || manifest +        || show_make +        || show_metadata +        || show_summary +        || source_or_pod +        || sqlite_discrete +        || sqlite_update +        || text +        || xhtml +      ) ? true : false; +    } +    @trusted bool meta_processing_general() { +      return ( +        opts["abstraction"] +        || curate +        || html +        || epub +        || odt +        || latex +        || sqlite_discrete +        || sqlite_update +      ) ? true :false; +    } +    @trusted bool meta_processing_xml_dom() { +      return ( +        opts["abstraction"] +        || html +        || epub +        || odt +        || sqlite_discrete +        || sqlite_update +      ) ? true : false; +    } +  } +  OptActions _opt_action = OptActions(); +  auto program_info() { +    struct ProgramInfo { +      string project() { +        return project_name; +      } +      string name() { +        return program_name; +      } +      string ver() { +        return format("%s.%s.%s", +          _ver.major, _ver.minor, _ver.patch, +        ); +      } +      string compiler() { +        return format ("%s D:%s, %s %s", +          __VENDOR__, __VERSION__, +          bits, os, +        ); +      } +      @trusted string name_and_version() { +        return format("%s-%s", name, ver); +      } +      @trusted string name_version_and_compiler() { +        return format("%s-%s (%s)", name, ver, compiler); +      } +      auto time_output_generated() { +        auto _st = Clock.currTime(UTC()); +        auto _t  = TimeOfDay(_st.hour, _st.minute, _st.second); +        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 ~ "]" +          ~ " - " ~ _t.toISOExtString +          // ~ " " ~ _st.hour.to!string ~ ":" ~ _st.minute.to!string ~ ":" ~ _st.second.to!string +          ~ " UTC"; +        return _time; +        // return _st.toISOExtString(); +      } +    } +    return ProgramInfo(); +  } +  auto _env = [ +    "pwd" :     environment["PWD"], +    "home" :    environment["HOME"], +  ]; +  auto _manifested = PathMatters!()(_opt_action, _env, ""); +  auto _manifests = [ _manifested ]; +  auto _conf_file_details = configFilePaths!()(_manifested, _env, _opt_action.config_path_set); +  ConfComposite _siteConfig; +  if ( +    _opt_action.require_processing_files +    && _opt_action.config_path_set.empty +  ) { +    foreach(arg; args[1..$]) { +      if (!(arg.match(rgx.flag_action))) { /+ cli markup source path +/ // get first input markup source file names for processing +        _manifested = PathMatters!()(_opt_action, _env, arg); +        { /+ local site config +/ +          _conf_file_details = configFilePaths!()(_manifested, _env, _opt_action.config_path_set); +          auto _config_local_site_struct = readConfigSite!()(_conf_file_details, _opt_action, _cfg); +          import sisudoc.meta.conf_make_meta_yaml; +          _siteConfig = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_siteConfig, _manifested, _opt_action, _cfg); // - get local site config +          break; +        } +      } +    } +  } else { /+ local site config +/ +    auto _config_local_site_struct = readConfigSite!()(_conf_file_details, _opt_action, _cfg); +    import sisudoc.meta.conf_make_meta_yaml; +    _siteConfig = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_siteConfig, _manifested, _opt_action, _cfg); // - get local site config +  } +  if (_opt_action.show_config) { +    import sisudoc.meta.metadoc_show_config; +    spineShowSiteConfig!()(_opt_action, _siteConfig); +  } +  if (!(_opt_action.skip_output)) { +    if ((_opt_action.debug_do) +      || (_opt_action.debug_do_stages) +    ) { +      writeln("step0 commence → (without processing files)"); +    } +    outputHubOp!()(_env, _opt_action, _siteConfig); +    if ((_opt_action.debug_do) +      || (_opt_action.debug_do_stages) +    ) { +      writeln("- step0 complete"); +    } +  } +  ConfComposite _make_and_meta_struct = _siteConfig; +  destroy(_siteConfig); +  foreach(arg; args[1..$]) { +    if (arg.match(rgx.flag_action)) { /+ cli instruction, flag do +/ +      flag_action ~= " " ~ arg;   // flags not taken by getopt +    } else if (_opt_action.require_processing_files) { /+ cli, assumed to be path to source files +/ +      auto _manifest_start = PodManifest!()(_opt_action, arg); +      if ( /+ pod files +/ +        !(arg.match(rgx_files.src_pth_sst_or_ssm)) +        && _manifest_start.pod_manifest_file_with_path +        && _opt_action.abstraction +      ) { +        string pod_manifest_root_content_paths_to_markup_location_raw_; +        string markup_contents_location_; +        string sisudoc_txt_ = _manifest_start.pod_manifest_file_with_path; +        enforce( +          exists(sisudoc_txt_)!=0, +          "file not found: «" ~ +          sisudoc_txt_ ~ "»" +        ); +        if (exists(sisudoc_txt_)) { +          try { +            if (exists(sisudoc_txt_)) { +              import dyaml; +              try { +                Node pod_manifest_yaml; +                try { +                  pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); +                } catch (ErrnoException ex) { +                } catch (FileException ex) { +                  writeln("ERROR failed to read config file"); +                } catch (Throwable) { +                  writeln("ERROR failed to read config file content, not parsed as yaml"); +                } +                if ("doc" in pod_manifest_yaml) { +                  if (pod_manifest_yaml["doc"].type.mapping +                    && pod_manifest_yaml["doc"].tag.match(rgx_y.yaml_tag_is_map) +                  ) { +                    if ("path" in pod_manifest_yaml["doc"]) { +                      if (pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_seq)) { +                        foreach (string _path; pod_manifest_yaml["doc"]["path"]) { +                          markup_contents_location_ ~= _path ~ "\n"; +                          pod_manifest_root_content_paths_to_markup_location_raw_ ~= +                            _path ~ "\n"; +                        } +                      } else if ( +                        pod_manifest_yaml["doc"]["path"].type.string +                        && pod_manifest_yaml["doc"]["path"].tag.match(rgx_y.yaml_tag_is_str) +                      ) { +                        markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; +                        pod_manifest_root_content_paths_to_markup_location_raw_ = +                          pod_manifest_yaml["doc"]["path"].get!string; +                      } +                    } +                    if ("filename" in pod_manifest_yaml["doc"]) { +                      if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_seq)) { +                        foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { +                          if ("language" in pod_manifest_yaml["doc"]) { +                            if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { +                              foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { +                                markup_contents_location_ ~= +                                  "media/text/" +                                  ~ _lang ~ "/" +                                  ~ _filename ~ "\n"; +                              } +                            } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str) +                            ) { +                              markup_contents_location_ = +                                "media/text/" +                                ~ pod_manifest_yaml["doc"]["language"].get!string +                                ~ "/" ~ _filename ~ "\n"; +                            } else { +                              string _lang_default = "en"; +                              markup_contents_location_ ~= +                                "media/text/" +                                ~ _lang_default ~ "/" +                                ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                            } +                          } else { +                            string _lang_default = "en"; +                            markup_contents_location_ ~= +                              "media/text/" +                              ~ _lang_default ~ "/" +                              ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                          } +                        } +                      } else if ( +                        pod_manifest_yaml["doc"]["filename"].type.string +                        && pod_manifest_yaml["doc"]["filename"].tag.match(rgx_y.yaml_tag_is_str) +                      ) { +                        if ("language" in pod_manifest_yaml["doc"]) { +                          if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_seq)) { +                            foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { +                              markup_contents_location_ ~= +                                "media/text/" +                                ~ _lang ~ "/" +                                ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                            } +                          } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx_y.yaml_tag_is_str)) { +                            markup_contents_location_ = +                              "media/text/" +                              ~ pod_manifest_yaml["doc"]["language"].get!string +                              ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                          } else { +                            string _lang_default = "en"; +                            markup_contents_location_ ~= +                              "media/text/" +                              ~ _lang_default ~ "/" +                              ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                          } +                        } else { +                          string _lang_default = "en"; +                          markup_contents_location_ ~= +                            "media/text/" +                            ~ _lang_default ~ "/" +                            ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; +                        } +                      } +                    } +                  } +                } +              } catch (ErrnoException ex) { +              } +            } +          } catch (ErrnoException ex) { +          } catch (FileException ex) { +            // Handle errors +          } +        } else { +          writeln("manifest not found: ", sisudoc_txt_); +        } +        auto markup_contents_locations_arr +          = (cast(char[]) markup_contents_location_).split; +        auto tmp_dir_ = (sisudoc_txt_).dirName.array; +        foreach (markup_contents_location; markup_contents_locations_arr) { +          assert(markup_contents_location.match(rgx_files.src_pth_sst_or_ssm), +            "not a recognised file: «" ~ +            markup_contents_location ~ "»" +          ); +          auto markup_contents_location_pth_ = (markup_contents_location).to!string; +          Regex!(char) lang_rgx_ = regex(r"/(" ~ _opt_action.languages_set.join("|") ~ ")/"); +          if (_opt_action.languages_set[0] == "all" +            || (markup_contents_location_pth_).match(lang_rgx_) +          ) { +            auto _fns = (((tmp_dir_).chainPath(markup_contents_location_pth_)).array).to!string; +            _manifested = PathMatters!()(_opt_action, _env, arg, _fns, markup_contents_locations_arr); +            _manifests ~= _manifested; +          } +        } +      } else if (arg.match(rgx_files.src_pth_sst_or_ssm)) { /+ markup txt files +/ +        if (exists(arg)==0) { +          writeln("ERROR >> Processing Skipped! File not found: ", arg); +        } else { +          _manifested = PathMatters!()(_opt_action, _env, arg, arg); +          _manifests ~= _manifested; +        } +      } else if (arg.match(rgx_files.src_pth_zip)) { +        // fns_src ~= arg;          // gather input markup source file names for processing +      } else {                      // anything remaining, unused +        arg_unrecognized ~= " " ~ arg; +      } +    } +  } +  if (_manifests.length > 1                            // _manifests[0] initialized dummy element +  && _opt_action.abstraction) { +    /+ ↓ output hub +/ +    if (!(_opt_action.skip_output)) { +      outputHubInitialize!()(_opt_action, program_info); +    } +    if (_opt_action.parallelise) {                     // see else +      import std.parallelism; +      foreach(manifest; parallel(_manifests[1..$])) { +        if (!empty(manifest.src.filename)) { +          scope(success) { +            if (_opt_action.vox_gt0) { +              writefln( +                "%s", +                "-- ~ document complete, ok ~ ------------------------------------", +              ); +            } +          } +          scope(failure) { +            debug(checkdoc) { +              stderr.writefln( +                "~ document run failure ~ (%s  v%s)\n\t%s\n%s", +                __VENDOR__, __VERSION__, +                manifest.src.filename, +                "------------------------------------------------------------------", +              ); +            } +          } +          enforce( +            manifest.src.filename.match(rgx_files.src_pth_types), +            "not a sisu markup filename: «" ~ +            manifest.src.filename ~ "»" +          ); +          if ((_opt_action.debug_do) +            || (_opt_action.debug_do_stages) +          ) { +            writeln("--->\nstepX commence → (document abstraction) [", manifest.src.filename, "]"); +          } +          auto t = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); +          static assert(t.length==2); +          auto doc_abstraction = t[dAM.abstraction]; +          auto doc_matters = t[dAM.matters]; +          if ((doc_matters.opt.action.debug_do) +            || (_opt_action.debug_do_stages) +          ) { +            writeln("- stepX complete for [", manifest.src.filename, "]"); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_summary) { +            import sisudoc.meta.metadoc_show_summary; +            spineMetaDocSummary!()(doc_abstraction, doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_metadata) { +            import sisudoc.meta.metadoc_show_metadata; +            spineShowMetaData!()(doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_make) { +            import sisudoc.meta.metadoc_show_make; +            spineShowMake!()(doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_config) { +            import sisudoc.meta.metadoc_show_config; +            spineShowConfig!()(doc_matters); +          } +          if (doc_matters.opt.action.curate) { +            auto _hvst = spineMetaDocCurate!()(doc_matters, hvst); +            if ( +              _hvst.title.length > 0 +              && _hvst.author_surname_fn.length > 0 +            ) { +              hvst.curates ~= _hvst; +            } else { +              if ((doc_matters.opt.action.debug_do) +                || (_opt_action.debug_do_curate) +                || (doc_matters.opt.action.vox_gt2) +              ) { +                writeln("WARNING curate: document header yaml does not contain information related to: title or author: ", _hvst.path_html_segtoc); +              } +            } +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.debug_do) { +            spineDebugs!()(doc_abstraction, doc_matters); +          } +          /+ ↓ output hub +/ +          if (!(doc_matters.opt.action.skip_output)) { +            if ((_opt_action.debug_do) +              || (_opt_action.debug_do_stages) +            ) { +              writeln("step5 commence → (process outputs) [", manifest.src.filename, "]"); +            } +            doc_abstraction.outputHub!()(doc_matters); +            if ((_opt_action.debug_do) +              || (_opt_action.debug_do_stages) +            ) { +              writeln("- step5 complete for [", manifest.src.filename, "]"); +            } +          } +          scope(exit) { +            if (_opt_action.vox_gt0) { +              writefln( +                "processed file: %s [%s]", +                manifest.src.filename, +                manifest.src.language +              ); +            } +            destroy(manifest); +          } +        } else { +          /+ no recognized filename provided +/ +          writeln("no recognized filename"); +          break; // terminate, stop +        } +      } +    } else {                                           // note cannot parallelise sqlite shared db +      foreach(manifest; _manifests[1..$]) { +        if (_opt_action.vox_gt2) { +          writeln("parallelisation off: actions include sqlite shared db"); +        } +        if (!empty(manifest.src.filename)) { +          scope(success) { +            if (_opt_action.vox_gt0) { +              writefln( +                "%s", +                "-- ~ document complete, ok ~ ------------------------------------", +              ); +            } +          } +          scope(failure) { +            debug(checkdoc) { +              stderr.writefln( +                "~ document run failure ~ (%s  v%s)\n\t%s\n%s", +                __VENDOR__, __VERSION__, +                manifest.src.filename, +                "------------------------------------------------------------------", +              ); +            } +          } +          enforce( +            manifest.src.filename.match(rgx_files.src_pth_types), +            "not a sisu markup filename: «" ~ +            manifest.src.filename ~ "»" +          ); +          if ((_opt_action.debug_do) +            || (_opt_action.debug_do_stages) +          ) { +            writeln("--->\nstepX commence → (document abstraction) [", manifest.src.filename, "]"); +          } +          auto t = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); +          static assert(t.length==2); +          auto doc_abstraction = t[dAM.abstraction]; +          auto doc_matters = t[dAM.matters]; +          if ((doc_matters.opt.action.debug_do) +            || (_opt_action.debug_do_stages) +          ) { +            writeln("- stepX complete for [", manifest.src.filename, "]"); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_summary) { +            import sisudoc.meta.metadoc_show_summary; +            spineMetaDocSummary!()(doc_abstraction, doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_metadata) { +            import sisudoc.meta.metadoc_show_metadata; +            spineShowMetaData!()(doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_make) { +            import sisudoc.meta.metadoc_show_make; +            spineShowMake!()(doc_matters); +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.show_config) { +            import sisudoc.meta.metadoc_show_config; +            spineShowConfig!()(doc_matters); +          } +          if (doc_matters.opt.action.curate) { +            auto _hvst = spineMetaDocCurate!()(doc_matters, hvst); +            if ( +              _hvst.title.length > 0 +              && _hvst.author_surname_fn.length > 0 +            ) { +              hvst.curates ~= _hvst; +            } else { +              if ((doc_matters.opt.action.debug_do) +                || (_opt_action.debug_do_curate) +                || (doc_matters.opt.action.vox_gt2) +              ) { +                writeln("WARNING curate: document header yaml does not contain information related to: title or author: ", _hvst.path_html_segtoc); +              } +            } +          } +          /+ ↓ debugs +/ +          if (doc_matters.opt.action.debug_do) { +            spineDebugs!()(doc_abstraction, doc_matters); +          } +          /+ ↓ output hub +/ +          if (!(doc_matters.opt.action.skip_output)) { +            if ((_opt_action.debug_do) +              || (_opt_action.debug_do_stages) +            ) { +              writeln("step5 commence → (process outputs) [", manifest.src.filename, "]"); +            } +            doc_abstraction.outputHub!()(doc_matters); +            if ((_opt_action.debug_do) +              || (_opt_action.debug_do_stages) +            ) { +              writeln("- step5 complete for [", manifest.src.filename, "]"); +            } +          } +          scope(exit) { +            if (_opt_action.vox_gt0) { +              writefln( +                "processed file: %s [%s]", +                manifest.src.filename, +                manifest.src.language +              ); +            } +            destroy(manifest); +          } +        } else { +          /+ no recognized filename provided +/ +          writeln("no recognized filename"); +          break; // terminate, stop +        } +      } +    } +  } +  if (hvst.curates.length > 0) { +    if (_opt_action.curate_topics) { +      spineMetaDocCuratesTopics!()(hvst, _make_and_meta_struct, _opt_action); +    } +    if (_opt_action.curate_authors) { +      spineMetaDocCuratesAuthors!()(hvst.curates, _make_and_meta_struct, _opt_action); +    } +    if (_opt_action.vox_gt0) { +      import sisudoc.io_out.paths_output; +      auto out_pth = spinePathsHTML!()(_make_and_meta_struct.conf.output_path, ""); +      if (_opt_action.curate_authors) { +        writeln("- ", out_pth.curate("authors.html")); +      } +      if (_opt_action.curate_topics) { +        writeln("- ", out_pth.curate("topics.html")); +      } +    } +  } // else { writeln("NO METADATA CURATED"); } +}  | 
