aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-02-28 15:26:52 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commitd28ce48b155a11bf4f313982139f4697120e2df1 (patch)
tree5baad6cabd4787c06b539848d952f4883c174bff /org
parent0.13.5 defaults regex reorganised; some work on (x)html output (diff)
work on outputs
Diffstat (limited to 'org')
-rw-r--r--org/ao_doc_abstraction.org251
-rw-r--r--org/defaults.org62
-rw-r--r--org/output.org46
-rw-r--r--org/sdp.org3
4 files changed, 234 insertions, 128 deletions
diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org
index fce5c90..0074e1c 100644
--- a/org/ao_doc_abstraction.org
+++ b/org/ao_doc_abstraction.org
@@ -3695,6 +3695,7 @@ void _para_match_(L,O,K,I,B,T,C)(
}
auto rgx = Rgx();
if (line_occur["para"] == State.off) {
+ line = font_faces_line(line);
/+ para matches +/
type["para"] = State.on;
an_object[an_object_key] ~= line; // body_nugget
@@ -3737,6 +3738,25 @@ void _para_match_(L,O,K,I,B,T,C)(
}
#+END_SRC
+**** TODO text font face
+
+#+name: abs_functions_para
+#+BEGIN_SRC d
+auto font_faces_line(T)(
+ return ref T textline,
+) {
+ auto rgx = Rgx();
+ if (match(textline, rgx.inline_faces_line)) {
+ textline = (textline)
+ .replaceFirst(rgx.inline_emphasis_line, ("*{$1}*$2"))
+ .replaceFirst(rgx.inline_bold_line, ("!{$1}!$2"))
+ .replaceFirst(rgx.inline_underscore_line, ("_{$1}_$2"))
+ .replaceFirst(rgx.inline_italics_line, ("/{$1}/$2"));
+ }
+ return textline;
+}
+#+END_SRC
+
*** function emitters :emitters:
**** object :object:
***** ocn :ocn:
@@ -4045,7 +4065,8 @@ struct ObjInlineMarkupMunge {
}
}
body {
- obj_txt["munge"]=obj_txt_in;
+ obj_txt_in = (obj_txt_in).replaceAll(rgx.two_spaces, mkup.nbsp ~ mkup.nbsp);
+ obj_txt["munge"] = obj_txt_in;
return obj_txt["munge"];
}
invariant() {
@@ -4328,7 +4349,7 @@ struct ObjInlineMarkup {
ObjGenericComposite comp_obj_toc;
mixin InternalMarkup;
auto mkup = InlineMarkup();
- char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip);
+ char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])).replaceAll(rgx.inline_notes_al, "");
heading_toc_ = _clean_heading_toc_(heading_toc_);
auto attrib="";
string toc_txt_, subtoc_txt_;
@@ -4446,7 +4467,8 @@ struct ObjInlineMarkup {
heading_toc_,
_anchor_tag,
);
- lev4_subtoc[segment_anchor_tag_that_object_belongs_to] ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip;
+ lev4_subtoc[segment_anchor_tag_that_object_belongs_to]
+ ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip;
toc_txt_= munge.url_links(toc_txt_);
indent=[
"hang_position" : to!int(obj_["lev_markup_number"]),
@@ -4489,113 +4511,128 @@ private:
static assert(is(typeof(dochead_make_aa) == string[string][string]));
}
if (dochead_make_aa["make"]["num_top"].length > 0) {
- if (!(match(munge_, rgx.heading_anchor_tag))) {
- static __gshared int heading_num_top_level=9;
- static __gshared int heading_num_depth=2;
- static __gshared int heading_num_0 = 0;
- static __gshared int heading_num_1 = 0;
- static __gshared int heading_num_2 = 0;
- static __gshared int heading_num_3 = 0;
- static __gshared string heading_number_auto_composite = "";
- if (heading_num_top_level==9) {
- if (dochead_make_aa["make"]["num_depth"].length > 0) {
- heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]);
- }
- switch (dochead_make_aa["make"]["num_top"]) {
- case "A":
- break;
- case "B":
- heading_num_top_level=1;
- break;
- case "C":
- heading_num_top_level=2;
- break;
- case "D":
- heading_num_top_level=3;
- break;
- case "1":
- heading_num_top_level=4;
- break;
- case "2":
- heading_num_top_level=5;
- break;
- case "3":
- heading_num_top_level=6;
- break;
- case "4":
- heading_num_top_level=7;
- break;
- default:
- break;
- }
- }
- /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/
- if (heading_num_top_level > to!uint(obj_["lev_markup_number"])) {
- heading_num_0 = 0;
- heading_num_1 = 0;
- heading_num_2 = 0;
- heading_num_3 = 0;
- } else if (heading_num_top_level == to!uint(obj_["lev_markup_number"])) {
- heading_num_0 ++;
- heading_num_1 = 0;
- heading_num_2 = 0;
- heading_num_3 = 0;
- } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 1)) {
- heading_num_1 ++;
- heading_num_2 = 0;
- heading_num_3 = 0;
- } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 2)) {
- heading_num_2 ++;
- heading_num_3 = 0;
- } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 3)) {
- heading_num_3 ++;
+ // if (!(match(munge_, rgx.heading_anchor_tag))) {
+ static __gshared int heading_num_top_level=9;
+ static __gshared int heading_num_depth=2;
+ static __gshared int heading_num_0 = 0;
+ static __gshared int heading_num_1 = 0;
+ static __gshared int heading_num_2 = 0;
+ static __gshared int heading_num_3 = 0;
+ static __gshared string heading_number_auto_composite = "";
+ if (heading_num_top_level==9) {
+ if (dochead_make_aa["make"]["num_depth"].length > 0) {
+ heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]);
}
- if (heading_num_3 > 0) {
- heading_number_auto_composite =
- (heading_num_depth == 3)
- ? ( to!string(heading_num_0) ~ "." ~
- to!string(heading_num_1) ~ "." ~
- to!string(heading_num_2) ~ "." ~
- to!string(heading_num_3)
- )
- : "";
- } else if (heading_num_2 > 0) {
- heading_number_auto_composite =
- ((heading_num_depth >= 2)
- && (heading_num_depth <= 3))
- ? ( to!string(heading_num_0) ~ "." ~
- to!string(heading_num_1) ~ "." ~
- to!string(heading_num_2)
- )
- : "";
- } else if (heading_num_1 > 0) {
- heading_number_auto_composite =
- ((heading_num_depth >= 1)
- && (heading_num_depth <= 3))
- ? ( to!string(heading_num_0) ~ "." ~
- to!string(heading_num_1)
- )
- : "";
- } else if (heading_num_0 > 0) {
- heading_number_auto_composite =
- ((heading_num_depth >= 0)
- && (heading_num_depth <= 3))
- ? (to!string(heading_num_0))
- : "";
- } else {
- heading_number_auto_composite = "";
- }
- debug(heading_number_auto) {
- writeln(heading_number_auto_composite);
- }
- if (!empty(heading_number_auto_composite)) {
- munge_=(munge_)
- .replaceFirst(rgx.heading,
- "$1~$2 " ~ heading_number_auto_composite ~ ". ")
- .replaceFirst(rgx.heading_marker_missing_tag,
- "$1~" ~ heading_number_auto_composite ~ " ");
+ switch (dochead_make_aa["make"]["num_top"]) {
+ case "A":
+ break;
+ case "B":
+ heading_num_top_level=1;
+ break;
+ case "C":
+ heading_num_top_level=2;
+ break;
+ case "D":
+ heading_num_top_level=3;
+ break;
+ case "1":
+ heading_num_top_level=4;
+ break;
+ case "2":
+ heading_num_top_level=5;
+ break;
+ case "3":
+ heading_num_top_level=6;
+ break;
+ case "4":
+ heading_num_top_level=7;
+ break;
+ default:
+ break;
}
}
+ /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/
+ if (
+ heading_num_top_level
+ > to!uint(obj_["lev_markup_number"])
+ ) {
+ heading_num_0 = 0;
+ heading_num_1 = 0;
+ heading_num_2 = 0;
+ heading_num_3 = 0;
+ } else if (
+ heading_num_top_level
+ == to!uint(obj_["lev_markup_number"])
+ ) {
+ heading_num_0 ++;
+ heading_num_1 = 0;
+ heading_num_2 = 0;
+ heading_num_3 = 0;
+ } else if (
+ heading_num_top_level
+ == (to!uint(obj_["lev_markup_number"]) - 1)
+ ) {
+ heading_num_1 ++;
+ heading_num_2 = 0;
+ heading_num_3 = 0;
+ } else if (
+ heading_num_top_level
+ == (to!uint(obj_["lev_markup_number"]) - 2)
+ ) {
+ heading_num_2 ++;
+ heading_num_3 = 0;
+ } else if (
+ heading_num_top_level
+ == (to!uint(obj_["lev_markup_number"]) - 3)
+ ) {
+ heading_num_3 ++;
+ }
+ if (heading_num_3 > 0) {
+ heading_number_auto_composite =
+ (heading_num_depth == 3)
+ ? ( to!string(heading_num_0) ~ "."
+ ~ to!string(heading_num_1) ~ "."
+ ~ to!string(heading_num_2) ~ "."
+ ~ to!string(heading_num_3)
+ )
+ : "";
+ } else if (heading_num_2 > 0) {
+ heading_number_auto_composite =
+ ((heading_num_depth >= 2)
+ && (heading_num_depth <= 3))
+ ? ( to!string(heading_num_0) ~ "."
+ ~ to!string(heading_num_1) ~ "."
+ ~ to!string(heading_num_2)
+ )
+ : "";
+ } else if (heading_num_1 > 0) {
+ heading_number_auto_composite =
+ ((heading_num_depth >= 1)
+ && (heading_num_depth <= 3))
+ ? ( to!string(heading_num_0) ~ "."
+ ~ to!string(heading_num_1)
+ )
+ : "";
+ } else if (heading_num_0 > 0) {
+ heading_number_auto_composite =
+ ((heading_num_depth >= 0)
+ && (heading_num_depth <= 3))
+ ? (to!string(heading_num_0))
+ : "";
+ } else {
+ heading_number_auto_composite = "";
+ }
+ debug(heading_number_auto) {
+ writeln(heading_number_auto_composite);
+ }
+ if (!(match(munge_, rgx.heading_anchor_tag))
+ && !empty(heading_number_auto_composite)) {
+ munge_=(munge_)
+ .replaceFirst(rgx.heading,
+ "$1~$2 " ~ heading_number_auto_composite ~ ". ")
+ .replaceFirst(rgx.heading_marker_missing_tag,
+ "$1~" ~ heading_number_auto_composite ~ " ");
+ }
}
return munge_;
}
diff --git a/org/defaults.org b/org/defaults.org
index 5ba63df..03eecb0 100644
--- a/org/defaults.org
+++ b/org/defaults.org
@@ -705,21 +705,6 @@ static block_curly_table_open = ctRegex!(`^(table[{].*?$
static block_curly_table_close = ctRegex!(`^([}]table)`);
#+END_SRC
-*** inline markup font face mod :inline:font:face:
-
-#+name: ao_rgx
-#+BEGIN_SRC d
-/+ inline markup font face mod +/
-static inline_emphasis = ctRegex!(`\*\{(?P<text>.+?)\}\*`);
-static inline_bold = ctRegex!(`!\{(?P<text>.+?)\}!`);
-static inline_italics = ctRegex!(`/\{(?P<text>.+?)\}/`);
-static inline_superscript = ctRegex!(`\^\{(?P<text>.+?)\}\^`);
-static inline_subscript = ctRegex!(`,\{(?P<text>.+?)\},`);
-static inline_strike = ctRegex!(`-\{(?P<text>.+?)\}-`);
-static inline_insert = ctRegex!(`\+\{(?P<text>.+?)\}\+`);
-static inline_mono = ctRegex!(`#\{(?P<text>.+?)\}#`);
-#+END_SRC
-
*** inline markup footnotes endnotes :inline:footnote:
#+name: ao_rgx
@@ -750,7 +735,7 @@ static note_ref = ctRegex!(`^\S+?noteref_(
#+name: ao_rgx
#+BEGIN_SRC d
-static inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]`, "mg");
+static inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg");
static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg");
static inline_link_naked_url = ctRegex!(`(?P<before>^|[ ])(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P<after>[.,;:?!'"]?(?:[ ]|$))`, "mg");
static inline_link_markup_regular = ctRegex!(`(?P<before>^|[ ])\{\s*(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P<after>[.,;:?!]?(?:[ ]|$))`, "mg");
@@ -1023,10 +1008,22 @@ template SiSUoutputRgxInit() {
private import defaults;
struct Rgx {
<<prgmkup_rgx>>
+ <<sp_ch_xhtml_rgx>>
}
}
#+END_SRC
+*** special characters
+**** xhtml special characters
+
+#+name: sp_ch_xhtml_rgx
+#+BEGIN_SRC d
+static xhtml_ampersand = ctRegex!(`[&]`); // &amp;
+static xhtml_less_than = ctRegex!(`[<]`); // &lt;
+static xhtml_greater_than = ctRegex!(`[>]`); // &gt;
+static xhtml_line_break = ctRegex!(` [\\]{2}`); // <br />
+#+END_SRC
+
* 2. defaults shared by ao & output (generic)
** 0. defaults :defaults:
*** template: internal markup :markup:
@@ -1155,6 +1152,16 @@ template SiSUlanguageCodes() {
** 1. ctRegex :regex:
+*** misc generic
+
+#+name: prgmkup_rgx
+#+BEGIN_SRC d
+static newline = ctRegex!("\n", "mg");
+static space = ctRegex!(`[ ]`, "mg");
+static two_spaces = ctRegex!(`[ ]{2}`, "mg");
+static nbsp_char = ctRegex!(`░`, "mg");
+#+END_SRC
+
*** filename (and path) matching (including markup insert file) :insert:file:path:filename:
#+name: prgmkup_rgx
@@ -1200,6 +1207,29 @@ static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.f
static mark_internal_site_lnk = ctRegex!(`¤`, "mg");
#+END_SRC
+*** TODO inline markup font face mod :inline:font:face:
+
+#+name: prgmkup_rgx
+#+BEGIN_SRC d
+/+ inline markup font face mod +/
+static inline_faces = ctRegex!(`(?P<markup>(?P<mod>[*!_^,+#-])\{(?P<text>.+?)\}[*!_^,+#-])`, "mg");
+static inline_emphasis = ctRegex!(`\*\{(?P<text>.+?)\}\*`, "mg");
+static inline_bold = ctRegex!(`!\{(?P<text>.+?)\}!`, "mg");
+static inline_underscore = ctRegex!(`_\{(?P<text>.+?)\}_`, "mg");
+static inline_italics = ctRegex!(`/\{(?P<text>.+?)\}/`, "mg");
+static inline_superscript = ctRegex!(`\^\{(?P<text>.+?)\}\^`, "mg");
+static inline_subscript = ctRegex!(`,\{(?P<text>.+?)\},`, "mg");
+static inline_strike = ctRegex!(`-\{(?P<text>.+?)\}-`, "mg");
+static inline_insert = ctRegex!(`\+\{(?P<text>.+?)\}\+`, "mg");
+static inline_mono = ctRegex!(`#\{(?P<text>.+?)\}#`, "mg");
+static inline_cite = ctRegex!(`"\{(?P<text>.+?)\}"`, "mg");
+static inline_faces_line = ctRegex!(`^[*!/_]_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`);
+static inline_emphasis_line = ctRegex!(`^\*_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`);
+static inline_bold_line = ctRegex!(`^!_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`);
+static inline_italics_line = ctRegex!(`^/_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`);
+static inline_underscore_line = ctRegex!(`^__ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`);
+#+END_SRC
+
* +set colors for terminal+ (unused) :colors:terminal:
#+name: ao_ansi_colors
diff --git a/org/output.org b/org/output.org
index 8ad43d9..bda3325 100644
--- a/org/output.org
+++ b/org/output.org
@@ -272,6 +272,40 @@ template outputXHTMLs() {
#+END_SRC
**** misc
+***** special characters
+
+#+name: xhtml_format_objects
+#+BEGIN_SRC d
+string special_characters(string _txt){
+ _txt = (_txt)
+ .replaceAll(rgx.xhtml_ampersand, "&amp;")
+ .replaceAll(rgx.xhtml_less_than, "&lt;")
+ .replaceAll(rgx.xhtml_greater_than, "&gt;")
+ .replaceAll(rgx.xhtml_line_break, "<br />");
+ return _txt;
+}
+#+END_SRC
+
+***** font_face
+
+#+name: xhtml_format_objects
+#+BEGIN_SRC d
+string font_face(string _txt){
+ _txt = (_txt)
+ .replaceAll(rgx.inline_emphasis, ("<emph>$1</emph>"))
+ .replaceAll(rgx.inline_bold, ("<b>$1</b>"))
+ .replaceAll(rgx.inline_underscore, ("<u>$1</u>"))
+ .replaceAll(rgx.inline_italics, ("<i>$1</i>"))
+ .replaceAll(rgx.inline_superscript, ("<sup>$1</sup>"))
+ .replaceAll(rgx.inline_subscript, ("<sub>$1</sub>"))
+ .replaceAll(rgx.inline_strike, ("<del>$1</del>"))
+ .replaceAll(rgx.inline_insert, ("<ins>$1</ins>"))
+ .replaceAll(rgx.inline_mono, ("<tt>$1</tt>"))
+ .replaceAll(rgx.inline_cite, ("<cite>$1</cite>"));
+ return _txt;
+}
+#+END_SRC
+
***** anchor tags
#+name: xhtml_format_objects
@@ -536,6 +570,7 @@ auto inline_markup_scroll(O)(
string _suffix = ".html",
) {
string _txt = obj.text;
+ _txt = special_characters(_txt);
_txt = inline_links(obj, _txt, _suffix, "scroll");
_txt = inline_notes_scroll(obj, _txt);
return _txt;
@@ -551,6 +586,7 @@ auto inline_markup_seg(O)(
string _suffix = ".html",
) {
string _txt = obj.text;
+ _txt = special_characters(_txt);
_txt = inline_links(obj, _txt, _suffix, "seg");
auto t = inline_notes_seg(obj, _txt);
return t;
@@ -671,7 +707,9 @@ auto para(O)(
string _txt,
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
+ _txt = font_face(_txt);
string o;
+ _txt = (obj.bullet) ? ("●&nbsp;&nbsp" ~ _txt) : _txt;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
<p class="%s" indent="h%si%s">%s
@@ -802,6 +840,10 @@ auto endnote(O)(
auto code(O)(
auto return ref const O obj,
) {
+ string _txt = obj.text;
+ _txt = (_txt)
+ .replaceAll(rgx.newline, "<br>\n")
+ .replaceAll(rgx.nbsp_char, "&nbsp;");
string o;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
@@ -810,7 +852,7 @@ auto endnote(O)(
</p>
</div>¶",
obj.is_a,
- obj.text
+ _txt
);
} else {
o = format(q"¶ <div class="substance">
@@ -823,7 +865,7 @@ auto endnote(O)(
obj.obj_cite_number,
obj.is_a,
obj.obj_cite_number,
- obj.text
+ _txt
);
}
return o;
diff --git a/org/sdp.org b/org/sdp.org
index 3700bfc..ce0aa0d 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -676,15 +676,12 @@ foreach (k; doc_matters.keys_seq_seg) {
#+name: ao_abstraction_summary
#+BEGIN_SRC d
-// auto char_repeat_number = doc_matters.source_filename.length;
-// char_repeat_number = (char_repeat_number > 33)
auto min_repeat_number = 66;
auto char_repeat_number = (doc_matters.dochead_meta["title"]["full"].length
+ doc_matters.dochead_meta["creator"]["author"].length + 4);
char_repeat_number = (char_repeat_number > min_repeat_number)
? char_repeat_number
: min_repeat_number;
-// writeln(char_repeat_number);
writefln(
"%s\n\"%s\", %s\n%s\n%s\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n(%s: %s)\n%s",
markup.repeat_character_by_number_provided("-", char_repeat_number),