aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/out_text.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/out_text.org')
-rw-r--r--org/out_text.org69
1 files changed, 31 insertions, 38 deletions
diff --git a/org/out_text.org b/org/out_text.org
index df5ccb2..02d6294 100644
--- a/org/out_text.org
+++ b/org/out_text.org
@@ -212,8 +212,7 @@ template munge() {
string newlines = "\n\n";
template special_characters_and_font_face() {
string code(string _txt){
- _txt = _txt
- .replaceAll(rgx.nbsp_char, " ");
+ _txt = _txt.replaceAll(rgx.nbsp_char, " ");
return _txt;
}
string general(string _txt) {
@@ -235,21 +234,16 @@ template munge() {
return _txt;
}
string links_and_images(string _txt){
- if (_txt.matchFirst(rgx.inline_link)) {
+ if (_txt.match(rgx.inline_link)) {
foreach (m; _txt.matchAll(rgx.inline_link)) {
- if (m.captures[3] == "0") {
- _txt = _txt
- .replaceFirst(rgx.inline_link, (m.captures[1]));
- } else {
- _txt = _txt
- .replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3]));
- }
+ _txt = (m.captures[3] == "0")
+ ? _txt.replaceFirst(rgx.inline_link, (m.captures[1]))
+ : _txt.replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3]));
}
}
if (_txt.matchFirst(rgx.inline_image)) {
foreach (m; _txt.matchAll(rgx.inline_image)) {
- _txt = _txt
- .replaceFirst(rgx.inline_image, (m.captures[3]));
+ _txt = _txt.replaceFirst(rgx.inline_image, (m.captures[3]));
}
}
return _txt;
@@ -260,28 +254,22 @@ template munge() {
string _notes;
string _ocn;
string general_munge;
- if (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) {
- _ocn = "";
- } else {
- _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline;
- }
+ _ocn = (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off)
+ ? "" : "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline;
if (_txt.matchFirst(rgx.inline_notes_al_gen)) {
foreach (m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) {
- _notes ~= newlines ~ m["num"] ~ ". " ~ m["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]");
- if (obj.metainfo.is_a == "code") {
- _txt = special_characters_and_font_face!().code(_txt);
- } else {
- _txt = special_characters_and_font_face!().general(_txt);
- }
+ _txt = (obj.metainfo.is_a == "code")
+ ? special_characters_and_font_face!().code(_txt)
+ : special_characters_and_font_face!().general(_txt);
_txt = special_characters_and_font_face!().links_and_images(_txt);
- if (obj.metainfo.is_a == "heading") {
- general_munge = newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline;
- } else {
- general_munge = _txt ~ _notes ~ newline ~ _ocn ~ newline;
- }
+ general_munge = (obj.metainfo.is_a == "heading")
+ ? newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline
+ : _txt ~ _notes ~ newline ~ _ocn ~ newline;
return general_munge;
}
string toc(O,M)(O obj, M doc_matters) {
@@ -310,7 +298,9 @@ template munge() {
default:
break;
}
- _txt = _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3"));
+ _txt = (doc_matters.opt.action.ocn_off)
+ ? _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1"))
+ : _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3"));
return _txt ~ newline;
}
string heading(O,M)(O obj, M doc_matters) {
@@ -454,19 +444,24 @@ template munge() {
string _ocn;
_ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」";
string _txt = obj.text;
+ string _parent_ocn;
_txt = _txt
- .replaceFirst(rgx.inline_link, ("$1"))
- .replaceFirst(rgx.inline_superscript, ("$1"));
- _txt = special_characters_and_font_face!().general(_txt);
+ .replaceAll(rgx.inline_link, ("$1")) // consider
+ .replaceFirst(rgx.inline_superscript, ("$1"));
+ _parent_ocn = (obj.metainfo.parent_ocn == 0 || doc_matters.opt.action.ocn_off)
+ ? "" : " ≫" ~ obj.metainfo.parent_ocn.to!string;
+ _txt = special_characters_and_font_face!().general(_txt) ~ _parent_ocn;
return _txt ~ newlines;
}
string bookindex(O,M)(O obj, M doc_matters) {
// puts(obj.metainfo.is_a);
// return obj.metainfo.is_a;
string _txt = obj.text;
- _txt = _txt
- .replaceAll(rgx.inline_link, ("≫$1"))
- .replaceAll(regex("\\s*\\\\"), "");
+ _txt = (doc_matters.opt.action.ocn_off)
+ ? _txt.replaceAll(rgx.find_bookindex_ocn_link_and_comma, "")
+ .replaceAll(regex("\\s*\\\\"), "")
+ : _txt.replaceAll(rgx.inline_link, ("≫$1"))
+ .replaceAll(regex("\\s*\\\\"), "");
_txt = special_characters_and_font_face!().general(_txt);
return _txt ~ newlines;
}
@@ -543,7 +538,6 @@ TODO
WISH
- underline headings?
-- endnote info on calling object ≫\d+
- break para text at set width?
- text wrap at text-line-width specified option
@@ -561,8 +555,7 @@ DONE
- verse
- table
- endnote section
- - CAVEAT: would like to, but do not point back to object number of origin
- REDO gathering of endnotes, (get/tie calling ocn)
+ - point back to object number of origin, use parent_ocn (used e.g. in text output: endnote info on calling object ≫\d+)
- bookindex
- bibliography
- glossary