diff options
Diffstat (limited to 'org/ocda_functions.org')
| -rw-r--r-- | org/ocda_functions.org | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/org/ocda_functions.org b/org/ocda_functions.org index b606891..6ab4bbf 100644 --- a/org/ocda_functions.org +++ b/org/ocda_functions.org @@ -179,41 +179,65 @@ pure struct OCNemitter { 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; @@ -2861,6 +2885,7 @@ static struct ObjInlineMarkup { 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; |
