From 36d0935c9a7521a87929d676a6b657fb033c44eb Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 30 Sep 2026 14:32:03 -0400 Subject: notes: editor's notes, ~[* ]~ & ~[+ ]~, as series The markup documents ~[* note ]~ and ~[+ note ]~ as editor's notes, each a separately numbered series, and a bare ~[ note ]~ which sisu put in the asterisk series. They are included as notes. Each series is numbered through the document, *1, *2 ... and +1, +2 ..., apart from the author's notes. (assisted by Claude-Code) --- src/sisudoc/outputs/io_out/latex.d | 14 ++++++++++++++ src/sisudoc/outputs/io_out/odt.d | 21 +++++++++++++++++++++ src/sisudoc/outputs/io_out/rgx.d | 10 +++++----- src/sisudoc/outputs/io_out/text.d | 5 +++-- 4 files changed, 43 insertions(+), 7 deletions(-) (limited to 'src/sisudoc/outputs/io_out') diff --git a/src/sisudoc/outputs/io_out/latex.d b/src/sisudoc/outputs/io_out/latex.d index 8e7b37c..1562fae 100644 --- a/src/sisudoc/outputs/io_out/latex.d +++ b/src/sisudoc/outputs/io_out/latex.d @@ -494,6 +494,20 @@ template outputLaTeX() { "$2".strip ).strip ); + /+ ↓ a note of a special series (*, *1, +1 ...). \footnote[n] takes a + number, so the mark is set as \thefootnote for this one note, + and the counter put back, so that the numbered series does not + move. + +/ + _txt = replaceAll!((m) { + import std.array : replace; + string _mark = m["char"]; + string _name = _mark.replace("*", "a").replace("+", "p"); + return "\\hypertarget{noteref_" ~ _name ~ "}{}" + ~ "{\\renewcommand{\\thefootnote}{" ~ _mark ~ "}" + ~ "\\footnote{\\label{note_" ~ _name ~ "}" ~ m["note"].strip ~ "}" + ~ "\\addtocounter{footnote}{-1}}"; + })(_txt, rgx.inline_notes_al_special_char_note); } return _txt; } diff --git a/src/sisudoc/outputs/io_out/odt.d b/src/sisudoc/outputs/io_out/odt.d index 40d760d..d8f6c2f 100644 --- a/src/sisudoc/outputs/io_out/odt.d +++ b/src/sisudoc/outputs/io_out/odt.d @@ -107,6 +107,8 @@ template formatODT() { return _on; } string _footnotes()(string _txt) { + import std.array : replace; + import std.regex : replaceAll; static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); _txt = _txt.replaceAll( @@ -124,6 +126,25 @@ template formatODT() { "$1", "$1", "$2", ) ); + /+ ↓ a note of a special series (*, *1, +1 ...): the same footnote, carrying + its mark as the citation's label, since odf numbers a note itself unless + instructed otherwise. The id takes the mark spelled in letters, "*" and + "+" having no place in one. + +/ + _txt = replaceAll!((m) { + string _mark = m["char"]; + string _id = _mark.replace("*", "a").replace("+", "p"); + return format(q"┃ + %s + + + %s + + + ┃", + _id, _mark, _mark, m["note"].strip, + ); + })(_txt, rgx.inline_notes_al_special_char_note); return _txt; } string _bullet(O)(const O obj) { diff --git a/src/sisudoc/outputs/io_out/rgx.d b/src/sisudoc/outputs/io_out/rgx.d index 60e169b..d2e842c 100644 --- a/src/sisudoc/outputs/io_out/rgx.d +++ b/src/sisudoc/outputs/io_out/rgx.d @@ -93,17 +93,17 @@ static template spineRgxOut() { /+ quotation marks +/ static quotes_open_and_close = ctRegex!(`[“”]`, "mg"); /+ inline markup footnotes endnotes +/ - static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); - static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented + static inline_notes_al = ctRegex!(`【(?:[*+]+[0-9]*\s+|\s*)(.+?)】`, "mg"); + static inline_notes_al_special = ctRegex!(`【(?:[*+]+[0-9]*\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_all_note = ctRegex!(`【(?P\d+|[*+]+[0-9]*)\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_notes_al_special_char_note = ctRegex!(`【(?P[*+]+[0-9]*)\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 inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*[0-9]*\s+.+?】|.+))`, "mg"); static endnote_section_note = ctRegex!(`┥\s*⑆\^┨(?P\d+)\.┣\^┝┤(?P¤?.+?)├.+`, "mg"); /+ inline markup links +/ static inline_image = ctRegex!(`(?P
┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+))\s*(?P.*?┝┤.*?├)`, "mg");
diff --git a/src/sisudoc/outputs/io_out/text.d b/src/sisudoc/outputs/io_out/text.d
index 89e85d9..43c7705 100644
--- a/src/sisudoc/outputs/io_out/text.d
+++ b/src/sisudoc/outputs/io_out/text.d
@@ -110,13 +110,14 @@ template outputText() {
       string general_munge;
       _ocn = (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off)
         ? "" : "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline;
+      /+ ↓ every note, numbered (1, 2 ...) or of a special series (*, *1, +1 ...) +/
       if (_txt.matchFirst(rgx.inline_notes_al_gen)) {
-        foreach (m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) {
+        foreach (m; _txt.matchAll(rgx.inline_notes_al_all_note)) {
           _notes ~= newlines ~ m["num"] ~ ". "
             ~ special_characters_and_font_face!().general(m["note"].replaceAll(rgx.inline_link, ("$1")));
         }
       }
-      _txt = _txt.replaceAll(rgx.inline_notes_al_regular_number_note, "[$1]");
+      _txt = _txt.replaceAll(rgx.inline_notes_al_all_note, "[$1]");
       _txt = (obj.metainfo.is_a == "code")
         ? special_characters_and_font_face!().code(_txt)
         : special_characters_and_font_face!().general(_txt);
-- 
cgit v1.2.3