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 /org/ocda_obj_setter.org | |
| 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 'org/ocda_obj_setter.org')
| -rw-r--r-- | org/ocda_obj_setter.org | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/org/ocda_obj_setter.org b/org/ocda_obj_setter.org index e0e7363..cd90f36 100644 --- a/org/ocda_obj_setter.org +++ b/org/ocda_obj_setter.org @@ -505,6 +505,70 @@ static auto eN() { } #+END_SRC +* topic register + +#+HEADER: :tangle "../src/sisudoc/ocda/meta/topic_register.d" +#+HEADER: :noweb yes +#+BEGIN_SRC d +<<doc_header_including_copyright_and_license>> +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; + } +} +#+END_SRC + * org includes ** project version |
