diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-27 13:53:54 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-28 10:22:20 -0400 |
| commit | 2b67e9532aada5c43061e49bb8e0954ffff0fadc (patch) | |
| tree | d9f41f7b55fe0f74999e4aee47393a6ceeb38793 | |
| parent | has.images: set flag but was not assigned, fix (diff) | |
doc_has: count inline links & notes, always 0, fix
Count them over the assembled body objects, (the body alone).
Previously dochas["inline_links"], ["inline_notes"] and
["inline_notes_star"] were initialised and read but never
incremented, so @doc_has reported 0 inline links and 0 notes for
every document while the block counters (codeblock, poem, group,
block, quote, table) were counted. create_abstraction_db.d records
the same values as document metadata.
(assisted by Claude-Code)
| -rw-r--r-- | org/ocda.org | 26 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/org/ocda.org b/org/ocda.org index f84d522..1e9d79e 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -1511,6 +1511,32 @@ ObjGenericComposite[][string] document_the = [ // dom tail only "tail": the_document_xml_dom_tail_section, ]; +/+ ↓ document level counts of inline markup. The block counters + (codeblock, poem, group, block, quote, table) are incremented as the + blocks are recognised; the inline markup is counted here, over the + assembled body objects. The body is counted alone: the endnotes + section is a rendering of the notes the body objects carry inline. + Links: those _links() stowed are counted from stow.link, their place + in the text having been taken by the stow index (a numeric target); + the link markup left in the text (anchors, and urls _links() does + not stow) is counted from the text ++/ +foreach (obj_; document_the["body"]) { + dochas["inline_links"] += obj_.stow.link.length.to!uint; + foreach (m; obj_.text.matchAll(rgx.inline_link)) { + if (!(m["link"].all!(c => (c >= '0' && c <= '9')))) { + ++dochas["inline_links"]; + } + } + foreach (m; obj_.text.matchAll(rgx.inline_notes_al_regular_number_note)) { + ++dochas["inline_notes"]; + } + foreach (m; obj_.text.matchAll(rgx.inline_notes_al_special_char_note)) { + if (m["char"].canFind("*")) { + ++dochas["inline_notes_star"]; + } + } +} // document parts keys as needed string[][string] document_section_keys_sequenced = [ "scroll": ["head", "toc", "body",], diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d index cae6c25..e104c94 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src.d @@ -1405,6 +1405,32 @@ template docAbstraction() { // dom tail only "tail": the_document_xml_dom_tail_section, ]; + /+ ↓ document level counts of inline markup. The block counters + (codeblock, poem, group, block, quote, table) are incremented as the + blocks are recognised; the inline markup is counted here, over the + assembled body objects. The body is counted alone: the endnotes + section is a rendering of the notes the body objects carry inline. + Links: those _links() stowed are counted from stow.link, their place + in the text having been taken by the stow index (a numeric target); + the link markup left in the text (anchors, and urls _links() does + not stow) is counted from the text + +/ + foreach (obj_; document_the["body"]) { + dochas["inline_links"] += obj_.stow.link.length.to!uint; + foreach (m; obj_.text.matchAll(rgx.inline_link)) { + if (!(m["link"].all!(c => (c >= '0' && c <= '9')))) { + ++dochas["inline_links"]; + } + } + foreach (m; obj_.text.matchAll(rgx.inline_notes_al_regular_number_note)) { + ++dochas["inline_notes"]; + } + foreach (m; obj_.text.matchAll(rgx.inline_notes_al_special_char_note)) { + if (m["char"].canFind("*")) { + ++dochas["inline_notes_star"]; + } + } + } // document parts keys as needed string[][string] document_section_keys_sequenced = [ "scroll": ["head", "toc", "body",], |
