diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-11 13:57:47 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-12 12:14:39 -0400 |
| commit | f41bf1cc525c70cced764a5e4df70d499d82f9c9 (patch) | |
| tree | 5825a95d525fcaa332bd378c1493bbd4a14613a0 /src/sisudoc/ocda/meta | |
| parent | ocda: one constructor for doc_matters (diff) | |
spine: process a document from .ocda.db or .ssp
Process a document from its .ocda.db or .ssp abstraction. A .ssp or a
.ocda.db given as an argument is now a document like any other: read
rather than parsed, and handed to the output writers as the same doc
they already take.
The 35 document sample collection built from its .ssp files is byte
identical to the same collection built from markup: 1457 files, no
differences.
Three things had to be rebuilt rather than read, all of them a value
parsed rather than a structure derived:
- classify_topic_register_arr and its expanded twin. The split is not a
plain one, so the rule moved to sisudoc.ocda.meta.topic_register and
both the yaml reader and this one call it.
- creator_author_arr, which is creator.author split on the ", " it was
joined with.
- title_sub, a copy of title_subtitle made where the header is read, and
what epub3 puts in dc:title id="subtitle".
Fixed ordering bug found by the acceptance test. A heading's own anchor
can be a bare number taken from its text and this can collide with the
ocn of an unrelated object. Whole output comparison found that before
the fix there was one wrong link in one epub's table of contents.
From a .ocda.db, 1446 of 1457 files are identical. The 11 that are not
are the images: a database carries its own image blobs and nothing yet
extracts them, so the five sisu_markup images are not copied and the
epub that embeds them differs. That is the next step and is not a defect
in this one.
--source and --pod2 are refused with a warning rather than half
done, no artefact carrying the markup.
(assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/ocda/meta')
| -rw-r--r-- | src/sisudoc/ocda/meta/conf_make_meta_yaml.d | 33 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/topic_register.d | 105 |
2 files changed, 113 insertions, 25 deletions
diff --git a/src/sisudoc/ocda/meta/conf_make_meta_yaml.d b/src/sisudoc/ocda/meta/conf_make_meta_yaml.d index e73a843..6dd045d 100644 --- a/src/sisudoc/ocda/meta/conf_make_meta_yaml.d +++ b/src/sisudoc/ocda/meta/conf_make_meta_yaml.d @@ -68,6 +68,7 @@ template contentYAMLtoSpineStruct() { import sisudoc.ocda.meta.defaults; import sisudoc.ocda.meta.rgx_yaml; import sisudoc.ocda.meta.rgx; + import sisudoc.ocda.meta.topic_register; ConfComposite _struct_composite; @system ConfComposite contentYAMLtoSpineStruct(C,Y,M,O,Cfg)( C _struct_composite, @@ -80,6 +81,7 @@ template contentYAMLtoSpineStruct() { mixin spineRgxIn; static auto rgx = RgxI(); mixin spineRgxYamlTags; + mixin spineTopicRegister; static auto rgx_y = RgxYaml(); string check_input_markup()( string _txt, @@ -738,32 +740,13 @@ template contentYAMLtoSpineStruct() { .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(", "); - } - } + /+ ↓ one rule, shared with a document loaded from an artefact, + whose header carries the string but not the arrays +/ + { + auto _tr = topicRegisterArrays(_struct_composite.meta.classify_topic_register); + _struct_composite.meta.classify_topic_register_arr = _tr.arr; + _struct_composite.meta.classify_topic_register_expanded_arr = _tr.expanded; } - _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")); diff --git a/src/sisudoc/ocda/meta/topic_register.d b/src/sisudoc/ocda/meta/topic_register.d new file mode 100644 index 0000000..a22c70c --- /dev/null +++ b/src/sisudoc/ocda/meta/topic_register.d @@ -0,0 +1,105 @@ +/+ +- Name: SisuDoc Spine, Doc Reform [a part of] + - Description: documents, structuring, processing, publishing, search + - static content generator + + - Author: Ralph Amissah + [ralph.amissah@gmail.com] + + - Copyright: (C) 2015 (continuously updated, current 2026) Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.sisudoc.org] + [https://www.doc-reform.org] + + - Git + [https://git.sisudoc.org/] + ++/ +module sisudoc.ocda.meta.topic_register; +@safe: +/+ ↓ the topic register, as the two arrays the curate writers walk + . + classify.topic_register is authored as one string, and the topic index + needs it as a list of paths and as a list of readable labels. The rule + is not a plain split: a main term is separated from the rest, sub terms + divided by "|" become one entry each, and the parts are joined with the + internal separator that the writers then split on again. + . + It lives here because two callers need the same answer from the same + string: the yaml reader, which has just read it from a document header, + and a document loaded from a .ssp or a .ocda.db, whose header carries + the string but not the arrays. Deriving it twice is how two answers to + one question get into a program. ++/ +template spineTopicRegister() { + import std.algorithm : sort, uniq; + import std.array; + import std.regex; + import std.string; + import sisudoc.ocda.meta.rgx; + import sisudoc.ocda.meta.defaults; + mixin spineRgxIn; + mixin InternalMarkup; + struct ST_TopicRegister { + string[] arr; // topic paths, joined with the internal separator + string[] expanded; // the same, as readable ", " separated labels + } + ST_TopicRegister topicRegisterArrays(string _topic_register) { + static auto rgx = RgxI(); + auto mkup = InlineMarkup(); + ST_TopicRegister _out; + if (_topic_register.length == 0) { return _out; } + string[] _main_topics = _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; + } + } + _out.arr = _topics; + foreach (_topic; _out.arr) { + if (_topic.length > 0) { _out.expanded ~= _topic.split(mkup.sep).join(", "); } + } + return _out; + } +} |
