diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-25 20:49:49 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-25 20:49:49 -0400 |
| commit | ead2f79ee41db99a292d763fe41f0613a74ef7b3 (patch) | |
| tree | f8ee798e50161aa30b650db7a531f174672d08cb /dlang/src | |
| parent | --validate, and a second reader, in Gleam (diff) | |
a blank first text line was being lost
An object whose first text line is blank lost it. The parser decided
whether to start a new line by asking whether the accumulated text
was empty, which is not the same question as whether a text line has
been seen: for an object opening on a blank line the first line left
the text empty and the second overwrote it rather than appending.
Seven documents of the markup document samples have verse opening on a
blank line, and in every one of them the blank was dropped, so the html,
the plain text and the JSONL chunks all began the verse a line early.
Spine's own text output has the blank line; this now matches.
Found by loading one document as .ssp and as .ocda.db and comparing
the two models object by object, which is what sisudoc-ocda-lib exists
to do. The comparison between the two .ssp readers had not caught it,
being on section counts, which the defect does not disturb.
Also: the repository is named sisudoc-ssp-reader, prefixed as every
repository of this project's own is (binary, package and module names
are unchanged), and the sources follow the specification directory's
name, sisudoc-abstraction-format. And the /+ ↓ +/ comment arrows in
ssp_parser.d, double-encoded by the in-place edit that applied the
fix, are restored; comment text only.
(assisted by Claude-Code)
Diffstat (limited to 'dlang/src')
| -rw-r--r-- | dlang/src/ssp_parser.d | 12 | ||||
| -rw-r--r-- | dlang/src/validate.d | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/dlang/src/ssp_parser.d b/dlang/src/ssp_parser.d index 1a1efe2..2efd94b 100644 --- a/dlang/src/ssp_parser.d +++ b/dlang/src/ssp_parser.d @@ -17,6 +17,12 @@ SspDocument parseSsp(string content) { SspDocument doc; SspObject current_obj; bool in_object = false; + /+ ↓ whether a text line has been seen for the object being read. + Not "is the text non-empty": an object whose first text line is blank + (a verse opening on an empty line, which the sample set has seven of) + would then lose it, the next line overwriting rather than appending. + +/ + bool seen_text = false; string current_section = ""; string current_block = ""; // meta, make, doc_has, or section name @@ -40,6 +46,7 @@ SspDocument parseSsp(string content) { commitObject(doc, current_section, current_obj); current_obj = SspObject.init; in_object = false; + seen_text = false; } continue; } @@ -68,6 +75,7 @@ SspDocument parseSsp(string content) { commitObject(doc, current_section, current_obj); current_obj = SspObject.init; in_object = false; + seen_text = false; } current_block = ""; continue; @@ -97,6 +105,7 @@ SspDocument parseSsp(string content) { current_obj = SspObject.init; current_obj.section = current_section; in_object = true; + seen_text = false; parseObjectDeclaration(line, current_obj); continue; } @@ -113,10 +122,11 @@ SspDocument parseSsp(string content) { if (line.length >= 1 && line[0] == '|') { if (in_object) { string text_content = (line.length > 2) ? line[2 .. $] : ""; - if (current_obj.text.length > 0) { + if (seen_text) { current_obj.text ~= "\n" ~ text_content; } else { current_obj.text = text_content; + seen_text = true; } } continue; diff --git a/dlang/src/validate.d b/dlang/src/validate.d index 7b48cd8..bf8668b 100644 --- a/dlang/src/validate.d +++ b/dlang/src/validate.d @@ -2,7 +2,7 @@ module validate; /+ ↓ check a .ssp against the format specification. . - Written from specs/doc-abstraction-format/ssp-format-specification.md + Written from specs/sisudoc-abstraction-format/ssp-format-specification.md and from nothing else: the point of it is to be what the specification says, executed, so that a file can be held against the document rather than against an implementation. Each check names the section it comes |
