From 748c9e60ae65433f225f7ac49de7b596cc1148d3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 8 Oct 2025 19:14:19 -0400 Subject: text output, endnotes, add caller ocn (& some cleaning) --- org/default_regex.org | 24 ++++++++++++------------ org/ocda.org | 2 +- org/ocda_functions.org | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'org') diff --git a/org/default_regex.org b/org/default_regex.org index fb2b993..5a1842f 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -601,15 +601,16 @@ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(. static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); static inline_notes_al_gen_text = ctRegex!(`【(?P.+?)】`, "m"); -static inline_notes_al_all_note = ctRegex!(`【(?P\d+|(?:[*]|[+])+)\s+(?P.+?)\s*】`, "mg"); -static inline_notes_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*】`, "mg"); -// static inline_notes_al_all_note = ctRegex!(`【(?P\d+|(?:[*]|[+])+)\s+(?P.+?)\s*(≫\s\d+)?\s*】`, "mg"); // ocn of origin would be useful in endnote section -// static inline_notes_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*(≫\s\d+)?\s*】`, "mg"); // ocn of origin would be useful in endnote section +static inline_notes_al_all_note = ctRegex!(`【(?P\d+|(?:[*]|[+])+)\s+(?P.+?)\s*(≫\s\d+)?\s*】`, "mg"); // ocn of origin would be useful in endnote section +static inline_notes_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*(≫\s\d+)?\s*】`, "mg"); // ocn of origin would be useful in endnote section +// static inline_notes_al_all_note = ctRegex!(`【(?P\d+|(?:[*]|[+])+)\s+(?P.+?)\s*】`, "mg"); +// static inline_notes_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*】`, "mg"); static inline_notes_al_special_char_note = ctRegex!(`【(?P(?:[*]|[+])+)\s+(?P.+?)】`, "mg"); static inline_al_delimiter_open_regular = ctRegex!(`【\s`, "m"); static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|.+))`, "mg"); +static endnote_section_note = ctRegex!(`┥\s*⑆\^┨(?P\d+)\.┣\^┝┤(?P¤?.+?)├.+`, "mg"); #+END_SRC #+BEGIN_SRC d @@ -626,14 +627,13 @@ static inline_image = ctRegex!(`(?P
┥)☼(?P┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P0)h(?P0))\s*(?P.*?┝┤.*?├)`, "mg");
 static inline_image_info                        = ctRegex!(`☼?(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+)`, "mg");
 static inline_link_anchor                       = ctRegex!(`┃(?P\S+?)┃`, "mg"); // TODO *~text_link_anchor
-// space cleaning should not be necessary
-static inline_link                              = ctRegex!(`┥\s*(?P.+?)\s*┝┤(?P#?(\S+?))├`, "mg");
-static inline_link_empty                        = ctRegex!(`┥\s*(?P.+?)\s*┝┤├`, "mg");
-static inline_link_number                       = ctRegex!(`┥\s*(?P.+?)\s*┝┤(?P[0-9]+)├`, "mg"); // not used
-static inline_link_number_only                  = ctRegex!(`\s*(?P\s*┥.+?┝)┤(?P[0-9]+)├`, "mg");
-static inline_link_stow_uri                     = ctRegex!(`┥\s*(?P.+?)\s*┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links
-static inline_link_hash                         = ctRegex!(`┥\s*(?P.+?)\s*┝┤(?P#(?P\S+?))├`, "mg");
-static inline_link_seg_and_hash                 = ctRegex!(`┥\s*(?P.+?)\s*┝┤(?P(?P[^/#├]*)#(?P.+?))├`, "mg");
+static inline_link                              = ctRegex!(`┥(?P.+?)┝┤(?P#?(\S+?))├`, "mg");
+static inline_link_empty                        = ctRegex!(`┥(?P.+?)┝┤├`, "mg");
+static inline_link_number                       = ctRegex!(`┥(?P.+?)┝┤(?P[0-9]+)├`, "mg"); // not used
+static inline_link_number_only                  = ctRegex!(`(?P┥.+?┝)┤(?P[0-9]+)├`, "mg");
+static inline_link_stow_uri                     = ctRegex!(`┥(?P.+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links
+static inline_link_hash                         = ctRegex!(`┥(?P.+?)┝┤(?P#(?P\S+?))├`, "mg");
+static inline_link_seg_and_hash                 = ctRegex!(`┥(?P.+?)┝┤(?P(?P[^/#├]*)#(?P.+?))├`, "mg");
 static inline_link_clean                        = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
 static inline_link_toc_to_backmatter            = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg");
 static url                                      = ctRegex!(`https?://`, "mg");
diff --git a/org/ocda.org b/org/ocda.org
index 96fe139..ee24570 100644
--- a/org/ocda.org
+++ b/org/ocda.org
@@ -796,7 +796,7 @@ _loopMarkupSrcByLineStruct loopMarkupSrcByLine(
             comp_obj_.has.inline_links                      = substantive_obj_misc_struct.has_links;
             comp_obj_.has.image_without_dimensions          = substantive_obj_misc_struct.has_images_without_dimensions;
             the_document_body_section                       ~= comp_obj_;
-            tag_assoc                                           = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
+            tag_assoc                                       = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
             {
               ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);
               {
diff --git a/org/ocda_functions.org b/org/ocda_functions.org
index cba37b9..16de3f0 100644
--- a/org/ocda_functions.org
+++ b/org/ocda_functions.org
@@ -4453,10 +4453,30 @@ ST_the_section build_the_blurb_section(Opt) (
   int                   html_segnames_ptr_cntr,
   int                   html_segnames_ptr,
 ) {
+  string[string][string] notes_;
+  if (the_document_body_section.length > 1) {
+    string _notes;
+    foreach (ref obj; the_document_body_section) {
+      if (obj.has.inline_notes_reg) {
+        if ((obj.text).matchFirst(rgx.inline_notes_al_gen)) {
+          foreach (m; (obj.text).matchAll(rgx.inline_notes_al_regular_number_note)) {
+            _notes ~= "\n\n" ~ m["num"] ~ ". " ~ m["note"] ~ " ≫" ~ obj.metainfo.ocn.to!string;
+            notes_[(m["num"])]["ocn"] = obj.metainfo.ocn.to!string;
+          }
+        }
+      }
+    }
+  }
   if (the_document_endnotes_section.length > 1) {
     segnames["html"] ~= "endnotes";
     segnames["epub"] ~= "endnotes";
     html_segnames_ptr = html_segnames_ptr_cntr;
+    foreach (ref obj; the_document_endnotes_section) {
+      auto matches = (obj.text).matchAll(rgx.endnote_section_note);
+      foreach (m; matches) {
+        obj.text = m.hit ~ " ≫" ~ notes_[(m["notenumber"])]["ocn"];
+      }
+    }
     foreach (ref obj; the_document_endnotes_section) {
       if (obj.metainfo.is_a == "heading") {
         obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
-- 
cgit v1.2.3