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 /src/sisudoc/outputs | |
| 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 'src/sisudoc/outputs')
| -rw-r--r-- | src/sisudoc/outputs/io_out/latex.d | 14 | ||||
| -rw-r--r-- | src/sisudoc/outputs/io_out/odt.d | 21 | ||||
| -rw-r--r-- | src/sisudoc/outputs/io_out/rgx.d | 10 | ||||
| -rw-r--r-- | src/sisudoc/outputs/io_out/text.d | 5 |
4 files changed, 43 insertions, 7 deletions
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"┃<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; } 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<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"); /+ inline markup links +/ static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "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); |
