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 /src/sisudoc/ocda/meta | |
| 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 'src/sisudoc/ocda/meta')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index 9e9f8ba..f51f6fe 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -144,41 +144,65 @@ template docAbstractionFunctions() { invariant() { } } - pure ObjGenericComposite obj_heading_ancestors()( + /+ ↓ a heading's text as it is used for navigation, in + tags.heading_ancestors_text and in the lev4 subtoc entries. + . + these are one line labels, so what is dropped is what cannot be shown + on one line and means nothing there: the note itself (the reference + marker goes with it), the line break markers, and a line break that + came from a heading wrapped over two lines in the source. what is + kept is the text and its inline markup. + +/ + string heading_text_for_navigation()(string _txt) { + mixin InternalMarkup; + static auto mkup = InlineMarkup(); + static auto rgx = RgxI(); + string _out = _txt + .replaceAll(rgx.inline_notes_al, "") // 【...】 and its marker + .replaceAll(rgx.inline_notes_curly_gen, "") // ~{...}~ if any remains + .replace(mkup.br_line, " ") + .replace(mkup.br_line_inline, " ") + .replace(mkup.br_line_spaced, " ") + .replace("\n", " ") + .replace("\r", " "); + while (_out.canFind(" ")) { _out = _out.replace(" ", " "); } + return _out.strip; + } + ObjGenericComposite obj_heading_ancestors()( ObjGenericComposite obj, string[] lv_ancestors_txt, ) { switch (obj.metainfo.heading_lev_markup) { case 0: - lv_ancestors_txt[0] = obj.text.to!string; + lv_ancestors_txt[0] = heading_text_for_navigation(obj.text.to!string); foreach(k; 1..8) { lv_ancestors_txt[k] = ""; } goto default; case 1: - lv_ancestors_txt[1] = obj.text.to!string; + lv_ancestors_txt[1] = heading_text_for_navigation(obj.text.to!string); foreach(k; 2..8) { lv_ancestors_txt[k] = ""; } goto default; case 2: - lv_ancestors_txt[2] = obj.text.to!string; + lv_ancestors_txt[2] = heading_text_for_navigation(obj.text.to!string); foreach(k; 3..8) { lv_ancestors_txt[k] = ""; } goto default; case 3: - lv_ancestors_txt[3] = obj.text.to!string; + lv_ancestors_txt[3] = heading_text_for_navigation(obj.text.to!string); foreach(k; 4..8) { lv_ancestors_txt[k] = ""; } goto default; case 4: - lv_ancestors_txt[4] = obj.text.to!string; + lv_ancestors_txt[4] = heading_text_for_navigation(obj.text.to!string); foreach(k; 5..8) { lv_ancestors_txt[k] = ""; } goto default; case 5: - lv_ancestors_txt[5] = obj.text.to!string; + lv_ancestors_txt[5] = heading_text_for_navigation(obj.text.to!string); foreach(k; 6..8) { lv_ancestors_txt[k] = ""; } goto default; case 6: - lv_ancestors_txt[6] = obj.text.to!string; + lv_ancestors_txt[6] = heading_text_for_navigation(obj.text.to!string); lv_ancestors_txt[7] = ""; goto default; case 7: - lv_ancestors_txt[7] = obj.text.to!string; + lv_ancestors_txt[7] = heading_text_for_navigation(obj.text.to!string); goto default; default: obj.tags.heading_ancestors_text = lv_ancestors_txt.dup; @@ -2671,6 +2695,7 @@ template docAbstractionFunctions() { char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])) .replaceAll(rgx.inline_notes_al, ""); heading_toc_ = _clean_heading_toc_(heading_toc_); + heading_toc_ = heading_text_for_navigation(heading_toc_.to!string).to!(char[]); auto attrib = ""; string toc_txt_, subtoc_txt_; int[string] indent; |
