diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-07 22:30:03 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-09 17:45:07 -0400 |
| commit | da575bf8a80cc2900bd5984718485cdacca0f527 (patch) | |
| tree | caf36b04621a87d6f063914bd2a62340a11d401c /org/in_source_files.org | |
| parent | ocda: the eight slot arrays are fixed length (diff) | |
ocda: clean heading text used for navigation
heading text used for navigation is normalised, and | escaped
(assisted by Claude-Code)
Diffstat (limited to 'org/in_source_files.org')
| -rw-r--r-- | org/in_source_files.org | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/org/in_source_files.org b/org/in_source_files.org index 2d788f3..7a9c6ee 100644 --- a/org/in_source_files.org +++ b/org/in_source_files.org @@ -782,12 +782,12 @@ return ret; module sisudoc.ocda.abstraction.ssp_in; @safe: /+ ↓ read a .ssp file back into the document abstraction - + . the reverse of sisudoc.ocda.abstraction.ssp. what it returns is the same value the parser produces, ObjGenericComposite[][string], so anything that consumes the abstraction can be fed from a .ssp instead of from markup. - + . the check that it is faithful is a round trip: load a .ssp, emit each object again with sspObjectRecord (the writer's own definition of a record) and require the result to be byte identical to the file read. @@ -801,9 +801,12 @@ template spineAbstractionRead() { import std.stdio; import std.string; import sisudoc.ocda.meta.metadoc_object_setter; + import sisudoc.ocda.abstraction.ssp : sspEscape; + mixin sspEscape; mixin ObjectSetter; /+ ↓ what a .ssp file holds: the three header blocks as key/value, and the - object sections in the order the file gives them +/ + object sections in the order the file gives them + +/ struct SSPdocument { string format; // "% SiSU Document Abstraction v0.1" string source; // "% Source: ..." @@ -837,9 +840,10 @@ template spineAbstractionRead() { return _out; } /+ ↓ the eight slot arrays are int[] with a literal default, so every - default constructed object shares one array; write into a fresh one +/ - private int[] _eight(string val) { - int[] _out = [ 0, 0, 0, 0, 0, 0, 0, 0, ]; + default constructed object shares one array; write into a fresh one + +/ + private int[8] _eight(string val) { + int[8] _out; foreach (i, v; _ints(val)) { if (i < _out.length) { _out[i] = v; } } @@ -1029,9 +1033,9 @@ template spineAbstractionRead() { case "segment_epub_is": obj.tags.epub_segment_anchor_tag_is = _val; break; case "heading_ancestors_text": { - string[] _h = [ "", "", "", "", "", "", "", "", ]; - foreach (i, h; _val.split("|")) { - if (i < _h.length) { _h[i] = h.to!string; } + string[8] _h; + foreach (i, h; sspUnescapeSplit(_val)) { + if (i < _h.length) { _h[i] = h; } } obj.tags.heading_ancestors_text = _h; } @@ -1043,7 +1047,8 @@ template spineAbstractionRead() { } _closeObject(); /+ ↓ .anchor is written only when it differs from .segment, and .section - only when it differs from the enclosing block; restore both +/ + only when it differs from the enclosing block; restore both + +/ foreach (sect; doc.section_order) { foreach (ref o; doc.abstraction[sect]) { if (o.tags.anchor_tag_html.length == 0 |
