summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--dlang/README.md14
-rw-r--r--dlang/src/ssp_parser.d12
-rw-r--r--dlang/src/validate.d2
-rw-r--r--gleam/README.md2
-rw-r--r--gleam/src/ssp/types.gleam2
-rw-r--r--gleam/src/ssp_reader.gleam2
7 files changed, 25 insertions, 15 deletions
diff --git a/README.md b/README.md
index eba8c42..34a2dc6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# ssp-reader
+# sisudoc-ssp-reader
Readers for the **`.ssp`** document abstraction, the object-centric
document abstraction written as text, which `sisudoc-spine` emits and
@@ -18,7 +18,7 @@ These are not three tools that happen to share a name. They are **the same
specification implemented more than once**, and the interesting thing about
them is that they agree.
-Each was written from the format specification, `doc-abstraction-format`,
+Each was written from the format specification, `sisudoc-abstraction-format`,
rather than from spine's emitter or from each other. Run over the 36
document reference collection, **the D and Gleam readers agree on the
section counts of all 36**.
@@ -54,7 +54,7 @@ README. Neither depends on the other.
## The format
-Specified in **doc-abstraction-format**: `ocda-model.md` for the model both
+Specified in **sisudoc-abstraction-format**: `ocda-model.md` for the model both
serialisations share, `ssp-format-specification.md` for this one, and
`ocda-db-format-specification.md` for the sqlite form.
diff --git a/dlang/README.md b/dlang/README.md
index fa39eab..bb0aefd 100644
--- a/dlang/README.md
+++ b/dlang/README.md
@@ -1,4 +1,4 @@
-# ssp-reader
+# ssp-reader, in D
Reader for the **`.ssp` document-abstraction text format** emitted
by [sisudoc-spine](https://git.sisudoc.org/projects/sisudoc-spine).
@@ -44,7 +44,7 @@ Spine's processing pipeline has three stages:
`ssp-reader` picks up the abstraction at the end of stage 2 (the
`.ssp` file) and runs alternative stage-3 renderings on top of it.
The `.ssp` format itself is documented in
-[`doc-abstraction-format`](https://git.sisudoc.org/tools/doc-abstraction-format).
+[`sisudoc-abstraction-format`](https://git.sisudoc.org/tools/sisudoc-abstraction-format).
## Quickstart
@@ -127,7 +127,7 @@ the HTML, in the plain text, and as an embedding chunk in the JSONL.
Fixed, and the reason the report exists.
That is deliberate and is what makes the reader usable as a check on the
-[format specification](https://git.sisudoc.org/specs/doc-abstraction-format):
+[format specification](https://git.sisudoc.org/specs/sisudoc-abstraction-format):
a reader that drops what it does not know is conforming, but one that
cannot say what it dropped cannot tell you whether the specification it was
written from was complete. Silence and understanding look alike otherwise.
@@ -135,7 +135,7 @@ written from was complete. Silence and understanding look alike otherwise.
## Documentation
- The `.ssp` format itself: see
- [doc-abstraction-format](https://git.sisudoc.org/tools/doc-abstraction-format).
+ [sisudoc-abstraction-format](https://git.sisudoc.org/tools/sisudoc-abstraction-format).
- Source: [`src/`](src/) - one module per output format
(`output_tree.d`, `output_html.d`, `output_llm_breadcrumbs.d`,
`output_llm_jsonl.d`, `output_images.d`, `verify_images.d`), plus
@@ -149,14 +149,14 @@ project for full licence text.
## Repository
-- **Canonical URL:** https://git.sisudoc.org/tools/ssp-reader
-- **Clone:** `git clone --depth=1 git://git.sisudoc.org/tools/ssp-reader`
+- **Canonical URL:** https://git.sisudoc.org/tools/sisudoc-ssp-reader
+- **Clone:** `git clone --depth=1 git://git.sisudoc.org/tools/sisudoc-ssp-reader`
## Related projects
- [sisudoc-spine](https://git.sisudoc.org/projects/sisudoc-spine) -
produces the `.ssp` files this tool consumes.
-- [doc-abstraction-format](https://git.sisudoc.org/tools/doc-abstraction-format) -
+- [sisudoc-abstraction-format](https://git.sisudoc.org/tools/sisudoc-abstraction-format) -
specification of the `.ssp` text format.
- [tree-sitter-sisu](https://git.sisudoc.org/tools/tree-sitter-sisu) -
tree-sitter grammar for the upstream `.sst` / `.ssm` markup.
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
diff --git a/gleam/README.md b/gleam/README.md
index 32d4cf7..d41135a 100644
--- a/gleam/README.md
+++ b/gleam/README.md
@@ -6,7 +6,7 @@ and says what it found and what it did not understand.
**Written from the specification alone**, as an experiment in whether that
specification suffices:
-- `ssp-format-specification.md`, from the **doc-abstraction-format**
+- `ssp-format-specification.md`, from the **sisudoc-abstraction-format**
specification
- `ocda-model.md`, from the same
diff --git a/gleam/src/ssp/types.gleam b/gleam/src/ssp/types.gleam
index 1e98886..a90559b 100644
--- a/gleam/src/ssp/types.gleam
+++ b/gleam/src/ssp/types.gleam
@@ -1,6 +1,6 @@
//// The .ssp document abstraction, as Gleam types.
////
-//// Written from the doc-abstraction-format specification,
+//// Written from the sisudoc-abstraction-format specification,
//// ssp-format-specification.md and ocda-model.md, and from nothing else: the exercise is to find out
//// whether the specification suffices to write a reader from.
diff --git a/gleam/src/ssp_reader.gleam b/gleam/src/ssp_reader.gleam
index d8c4c78..5c79d95 100644
--- a/gleam/src/ssp_reader.gleam
+++ b/gleam/src/ssp_reader.gleam
@@ -4,7 +4,7 @@
//// and says what it found and what it did not understand.
////
//// Written from the specification alone:
-//// ssp-format-specification.md, of the doc-abstraction-format spec
+//// ssp-format-specification.md, of the sisudoc-abstraction-format spec
//// ocda-model.md, of the same
import argv