From cc0b844be3822ac45603a095ceee77dc0f231288 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 29 Sep 2026 17:56:11 -0400 Subject: format 2.1: the poem, and a note mark of a symbol and a number From format 2.1 a poem comes before its verses, carries object number 0 and states the range of its verses, where it came after them sharing the last verse's number. The text writer's rule, an object with no text writes nothing, covers both forms and is unchanged; its comment, in both languages, and the README now describe the poem as it is. Spine now writes the markup's editor's notes, ~[* ]~ and ~[+ ]~, as their own numbered series, marked *1, *2 ... and +1, +2 ..., in the form the special notes already had. The note patterns took symbols alone, so in every writer, both languages, these went through as text. They now take [*+]+[0-9]* where they took symbols. Over the markup document samples written by spine at 2.1: D == Gleam byte for byte in all five formats; the same .typ from .ssp and .ocda.db; spine's .typ body == this writer's; epubcheck clean; every html link resolves. Against the same writers over 2.0 artefacts, two things move, both the abstraction's doing: the_public_domain's html and epub gain note 84, which 2.0 never gathered; and seven epubs lose an empty body.xhtml page listed in the navigation, which was where the 2.0 poems went for want of a segment. The repository is sisudoc-ocda-writer, in the singular: named for its role, as its siblings are. It holds one writer, ocda-write, in each language, taking the format as an option. flake.lock, in dlang/ and gleam/, now pins the library at its model 2.1 commit. (assisted by Claude-Code) --- gleam/src/write/epub.gleam | 2 +- gleam/src/write/rgx.gleam | 2 +- gleam/src/write/text.gleam | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'gleam/src') diff --git a/gleam/src/write/epub.gleam b/gleam/src/write/epub.gleam index 77f4f42..e035393 100644 --- a/gleam/src/write/epub.gleam +++ b/gleam/src/write/epub.gleam @@ -252,7 +252,7 @@ fn inline_anchor() -> regexp.Regexp { fn note_mark() -> regexp.Regexp { let assert Ok(r) = regexp.compile( - "【(\\d+|(?:[*]|[+])+)\\s", + "【(\\d+|[*+]+[0-9]*)\\s", regexp.Options(case_insensitive: False, multi_line: True), ) r diff --git a/gleam/src/write/rgx.gleam b/gleam/src/write/rgx.gleam index 71add21..1bc525f 100644 --- a/gleam/src/write/rgx.gleam +++ b/gleam/src/write/rgx.gleam @@ -174,7 +174,7 @@ fn apply( /// A note's mark may be a number or a run of stars or pluses, and both are /// gathered into the endnotes section, so both need a reference. pub fn inline_notes_any_mark() -> Regexp { - re("【(\\d+|(?:[*]|[+])+)\\s+(.+?)\\s*】") + re("【(\\d+|[*+]+[0-9]*)\\s+(.+?)\\s*】") } /// A link before its url has been substituted in: the number is an index into diff --git a/gleam/src/write/text.gleam b/gleam/src/write/text.gleam index 2e44e3a..77897d5 100644 --- a/gleam/src/write/text.gleam +++ b/gleam/src/write/text.gleam @@ -80,9 +80,11 @@ fn toc_depths(doc: Document) -> Dict(Int, Int) { /// and an output that loses it silently cannot be checked. fn object(obj: Object, depths: Dict(Int, Int)) -> String { // an object with no text of its own writes nothing. A poem is such an - // object: it is a container that closes a run of verses and carries the - // *same* object number as the last of them, so writing it would put that - // number in the file twice - 15 times over in one sample. + // object: a container of the verses that follow it, which are what is + // written. Since format 2.1 it carries object number 0 and states the + // range of its verses; before, it closed the run carrying the *same* + // number as the last verse, and writing it put that number in the file + // twice - 15 times over in one sample. Both forms write nothing. // and a dummy heading writes nothing: it is generated furniture whose text // repeats the heading above it, and every other writer here drops it. // Spine's text keeps it, so a trailing section's name is in the file twice. -- cgit v1.2.3