diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-30 14:32:03 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-30 22:31:56 -0400 |
| commit | 36d0935c9a7521a87929d676a6b657fb033c44eb (patch) | |
| tree | acb1e27aa0a95691419e2b05f5623fbd4f1aac61 /org | |
| parent | unused function removed (diff) | |
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)
Diffstat (limited to 'org')
| -rw-r--r-- | org/default_regex.org | 11 | ||||
| -rw-r--r-- | org/ocda_functions.org | 39 | ||||
| -rw-r--r-- | org/out_latex.org | 14 | ||||
| -rw-r--r-- | org/out_odt.org | 21 | ||||
| -rw-r--r-- | org/out_text.org | 5 |
5 files changed, 79 insertions, 11 deletions
diff --git a/org/default_regex.org b/org/default_regex.org index 4b2178c..33707c4 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -315,6 +315,7 @@ static inline_notes_curly_gen = ctRegex!(`~\{.+?\}~`, "m"); static inline_notes_curly = ctRegex!(`~\{\s*(.+?)\s*\}~`, "mg"); static inline_notes_curly_sp_asterisk = ctRegex!(`~\{[*]+\s+(.+?)\s*\}~`, "m"); static inline_notes_curly_sp_plus = ctRegex!(`~\{[+]+\s+(.+?)\s*\}~`, "m"); +static inline_notes_square = ctRegex!(`~\[\s*(?P<series>[*+]?)\s*(?P<note>.+?)\s*\]~`, "mg"); // editor's notes, their own numbered series static note_ref = ctRegex!(`^\S+?noteref_(?P<ref>[0-9]+)`, "mg"); // {^{73.}^}#noteref_73 #+END_SRC @@ -612,17 +613,17 @@ static inline_underscore_line = ctRegex!(`^__ (?P<text>.+?)(?P #+NAME: prgmkup_rgx_internal_footnotes_and_endnotes #+BEGIN_SRC d /+ 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<text>.+?)】`, "m"); -static inline_notes_al_all_note = ctRegex!(`【(?P<num>\d+|(?:[*]|[+])+)\s+(?P<note>.+?)\s*】`, "mg"); +static inline_notes_al_all_note = ctRegex!(`【(?P<num>\d+|[*+]+[0-9]*)\s+(?P<note>.+?)\s*】`, "mg"); static inline_notes_al_regular_number_note = ctRegex!(`【(?P<num>\d+)\s+(?P<note>.+?)\s*】`, "mg"); -static inline_notes_al_special_char_note = ctRegex!(`【(?P<char>(?:[*]|[+])+)\s+(?P<note>.+?)】`, "mg"); +static inline_notes_al_special_char_note = ctRegex!(`【(?P<char>[*+]+[0-9]*)\s+(?P<note>.+?)】`, "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<notenumber>\d+)\.┣\^┝┤(?P<link>¤?.+?)├.+`, "mg"); #+END_SRC diff --git a/org/ocda_functions.org b/org/ocda_functions.org index a5b60fa..da8e5ee 100644 --- a/org/ocda_functions.org +++ b/org/ocda_functions.org @@ -2528,7 +2528,7 @@ ObjGenericComposite set_object_generic()( // ↓ - object inline munge static struct ObjInlineMarkupMunge { string[string] obj_txt; - int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; + int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus, n_foot_ed_asterisk, n_foot_ed_plus; string asterisks_, plus_; string obj_txt_out, tail, note; static auto rgx = RgxI(); @@ -2539,6 +2539,8 @@ static struct ObjInlineMarkupMunge { n_foot_reg = 0; n_foot_sp_asterisk = 0; n_foot_sp_plus = 0; + n_foot_ed_asterisk = 0; + n_foot_ed_plus = 0; } static auto images()(string obj_txt_in) { static auto mng = InlineMarkup(); @@ -2569,13 +2571,13 @@ static struct ObjInlineMarkupMunge { bool flg_notes_reg = false; bool flg_notes_star = false; bool flg_notes_plus = false; + if (!(stage_reset_note_numbers) && reset_note_numbers) { + stage_reset_note_numbers = true; + } obj_txt_in = obj_txt_in.replaceAll( rgx.inline_notes_curly, (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) ); - if (!(stage_reset_note_numbers) && reset_note_numbers) { - stage_reset_note_numbers = true; - } obj_txt_out = ""; if (obj_txt_in.match(rgx.inline_notes_al_gen)) { string[] _tmp_txt; @@ -2586,6 +2588,8 @@ static struct ObjInlineMarkupMunge { n_foot_reg = 0; n_foot_sp_asterisk = 0; n_foot_sp_plus = 0; + n_foot_ed_asterisk = 0; + n_foot_ed_plus = 0; } stage_reset_note_numbers = false; foreach(n; m) { @@ -2627,6 +2631,33 @@ static struct ObjInlineMarkupMunge { } else { obj_txt_out = obj_txt_in; } + /+ ↓ editor's notes: ~[* note ]~ and ~[+ note ]~, and a bare ~[ note ]~, + which joins the asterisk series as it did in sisu. Each series is + numbered through the document, apart from the author's notes: + ,*1, *2 ... and +1, +2 ... + . + Placed after the author's notes rather than before, so that the reset + above, made once per document at its first note, has happened by the + time these are counted. + +/ + if (obj_txt_out.match(rgx.inline_notes_square)) { + if (stage_reset_note_numbers) { + n_foot = 0; + n_foot_reg = 0; + n_foot_sp_asterisk = 0; + n_foot_sp_plus = 0; + n_foot_ed_asterisk = 0; + n_foot_ed_plus = 0; + stage_reset_note_numbers = false; + } + obj_txt_out = replaceAll!((m) { + string _series = (m["series"] == "+") ? "+" : "*"; + int _n = (_series == "+") ? ++n_foot_ed_plus : ++n_foot_ed_asterisk; + if (_series == "+") { flg_notes_plus = true; } + return mkup.en_a_o ~ _series ~ _n.to!string ~ " " ~ m["note"] ~ mkup.en_a_c; + })(obj_txt_out, rgx.inline_notes_square); + flg_notes_star = true; + } ST_txtPlusHasFootnotes ret; { ret.obj_txt = obj_txt_out; diff --git a/org/out_latex.org b/org/out_latex.org index 88a409a..6d1308e 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -1210,6 +1210,20 @@ string footnotes()( "$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/org/out_odt.org b/org/out_odt.org index b28e8d1..295e7f1 100644 --- a/org/out_odt.org +++ b/org/out_odt.org @@ -205,6 +205,8 @@ string obj_num(O)(const O obj) { // TODO #+NAME: odt_format_objects_3 #+BEGIN_SRC d string _footnotes()(string _txt) { + import std.array : replace; + import std.regex : replaceAll; static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); _txt = _txt.replaceAll( @@ -222,6 +224,25 @@ string _footnotes()(string _txt) { "$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"┃<text:note text:id="ftn_%s" text:note-class="footnote"> + <text:note-citation text:label="%s">%s</text:note-citation> + <text:note-body> + <text:p text:style-name="Footnote"> + %s + </text:p> + </text:note-body> +</text:note>┃", + _id, _mark, _mark, m["note"].strip, + ); + })(_txt, rgx.inline_notes_al_special_char_note); return _txt; } #+END_SRC diff --git a/org/out_text.org b/org/out_text.org index 5d0e77d..a40bf69 100644 --- a/org/out_text.org +++ b/org/out_text.org @@ -256,13 +256,14 @@ template munge() { 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); |
