diff options
Diffstat (limited to 'src/sisudoc/ocda')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 39 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/rgx.d | 11 |
2 files changed, 41 insertions, 9 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index c5a63cd..922f389 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -2340,7 +2340,7 @@ template docAbstractionFunctions() { // ↓ - 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(); @@ -2351,6 +2351,8 @@ template docAbstractionFunctions() { 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(); @@ -2381,13 +2383,13 @@ template docAbstractionFunctions() { 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; @@ -2398,6 +2400,8 @@ template docAbstractionFunctions() { 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) { @@ -2439,6 +2443,33 @@ template docAbstractionFunctions() { } 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/src/sisudoc/ocda/meta/rgx.d b/src/sisudoc/ocda/meta/rgx.d index 249fd3d..22828d7 100644 --- a/src/sisudoc/ocda/meta/rgx.d +++ b/src/sisudoc/ocda/meta/rgx.d @@ -151,6 +151,7 @@ static template spineRgxIn() { 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 static smid_inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); static smid_inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); @@ -236,17 +237,17 @@ static template spineRgxIn() { +/ static trailing_backslash = ctRegex!(`\s*\\`, "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"); |
