diff options
| author | Ralph Amissah <ralph@amissah.com> | 2017-02-28 15:26:52 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 | 
| commit | d28ce48b155a11bf4f313982139f4697120e2df1 (patch) | |
| tree | 5baad6cabd4787c06b539848d952f4883c174bff | |
| parent | 0.13.5 defaults regex reorganised; some work on (x)html output (diff) | |
work on outputs
| -rw-r--r-- | org/ao_doc_abstraction.org | 251 | ||||
| -rw-r--r-- | org/defaults.org | 62 | ||||
| -rw-r--r-- | org/output.org | 46 | ||||
| -rw-r--r-- | org/sdp.org | 3 | ||||
| -rw-r--r-- | src/sdp/abstraction_summary.d | 3 | ||||
| -rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 245 | ||||
| -rw-r--r-- | src/sdp/ao_rgx.d | 32 | ||||
| -rw-r--r-- | src/sdp/output_rgx.d | 25 | ||||
| -rw-r--r-- | src/sdp/output_xhtmls.d | 34 | 
9 files changed, 451 insertions, 250 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!(`[&]`);      // & +static xhtml_less_than                            = ctRegex!(`[<]`);      // < +static xhtml_greater_than                         = ctRegex!(`[>]`);      // > +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,    "&") +    .replaceAll(rgx.xhtml_less_than,    "<") +    .replaceAll(rgx.xhtml_greater_than, ">") +    .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) ? ("●  " ~ _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, " ");        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), diff --git a/src/sdp/abstraction_summary.d b/src/sdp/abstraction_summary.d index 4a9fc80..ab32249 100644 --- a/src/sdp/abstraction_summary.d +++ b/src/sdp/abstraction_summary.d @@ -32,15 +32,12 @@ template SiSUabstractionSummary() {            }          }        } -      // 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), diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 6690a9f..066ef3a 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -3015,6 +3015,7 @@ template SiSUdocAbstraction() {      }      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 @@ -3055,6 +3056,19 @@ template SiSUdocAbstraction() {        ++line_occur["para"];      }    } +  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; +  }    /+ abstraction functions ↑ +/    /+ ↓ abstraction function emitters +/    struct OCNemitter { @@ -3304,7 +3318,8 @@ template SiSUdocAbstraction() {        }      }      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() { @@ -3503,7 +3518,7 @@ template SiSUdocAbstraction() {        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_; @@ -3621,7 +3636,8 @@ template SiSUdocAbstraction() {            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"]), @@ -3652,113 +3668,128 @@ template SiSUdocAbstraction() {          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 (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))) { +        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 (!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/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 7d47608..20535d0 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -105,15 +105,6 @@ template SiSUrgxInit() {      static block_curly_quote_close                        = ctRegex!(`^([}]quote)`);      static block_curly_table_open                         = ctRegex!(`^(table[{].*?$)`);      static block_curly_table_close                        = ctRegex!(`^([}]table)`); -    /+ 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>.+?)\}#`);      /+ inline markup footnotes endnotes +/      static inline_notes_curly_gen                         = ctRegex!(`~\{.+?\}~`, "m");      static inline_notes_curly                             = ctRegex!(`~\{\s*(.+?)\}~`, "mg"); @@ -134,7 +125,7 @@ template SiSUrgxInit() {      static inline_curly_delimiter_close_regular           = ctRegex!(`\s*\}~`, "m");      static inline_text_and_note_curly                     = ctRegex!(`(?P<text>.+?)(?:(?:[~])[{][*+ ]*)(?P<note>.+?)(?:[}][~])`, "mg");      static note_ref                                       = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg");     // {^{73.}^}#noteref_73 -    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"); @@ -178,6 +169,10 @@ template SiSUrgxInit() {         ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)");      auto language_code_and_filename                                    =         ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$"); +    static newline                                        = ctRegex!("\n", "mg"); +    static space                                          = ctRegex!(`[ ]`, "mg"); +    static two_spaces                                     = ctRegex!(`[ ]{2}`, "mg"); +    static nbsp_char                                      = ctRegex!(`░`, "mg");      static src_pth                                        = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`);      static src_fn                                         =        ctRegex!(`^([a-zA-Z0-9._-]+/)*(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); @@ -207,5 +202,22 @@ template SiSUrgxInit() {      static inline_link_fn_suffix                          = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg");      static inline_seg_link                                = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg");      static mark_internal_site_lnk                         = ctRegex!(`¤`, "mg"); +    /+ 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}$)`);    }  } diff --git a/src/sdp/output_rgx.d b/src/sdp/output_rgx.d index 5a9a47e..e056b70 100644 --- a/src/sdp/output_rgx.d +++ b/src/sdp/output_rgx.d @@ -4,6 +4,10 @@  template SiSUoutputRgxInit() {    private import defaults;    struct Rgx { +    static newline                                        = ctRegex!("\n", "mg"); +    static space                                          = ctRegex!(`[ ]`, "mg"); +    static two_spaces                                     = ctRegex!(`[ ]{2}`, "mg"); +    static nbsp_char                                      = ctRegex!(`░`, "mg");      static src_pth                                        = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`);      static src_fn                                         =        ctRegex!(`^([a-zA-Z0-9._-]+/)*(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); @@ -33,5 +37,26 @@ template SiSUoutputRgxInit() {      static inline_link_fn_suffix                          = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg");      static inline_seg_link                                = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg");      static mark_internal_site_lnk                         = ctRegex!(`¤`, "mg"); +    /+ 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}$)`); +    static xhtml_ampersand                            = ctRegex!(`[&]`);      // & +    static xhtml_less_than                            = ctRegex!(`[<]`);      // < +    static xhtml_greater_than                         = ctRegex!(`[>]`);      // > +    static xhtml_line_break                           = ctRegex!(` [\\]{2}`); // <br />    }  } diff --git a/src/sdp/output_xhtmls.d b/src/sdp/output_xhtmls.d index de5236d..d39298c 100644 --- a/src/sdp/output_xhtmls.d +++ b/src/sdp/output_xhtmls.d @@ -25,6 +25,28 @@ template outputXHTMLs() {    mixin SiSUoutputRgxInit;    struct outputXHTMLs {      auto rgx = Rgx(); +    string special_characters(string _txt){ +      _txt = (_txt) +        .replaceAll(rgx.xhtml_ampersand,    "&") +        .replaceAll(rgx.xhtml_less_than,    "<") +        .replaceAll(rgx.xhtml_greater_than, ">") +        .replaceAll(rgx.xhtml_line_break,   "<br />"); +      return _txt; +    } +    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; +    }      string _xhtml_anchor_tags(const(string[]) anchor_tags) {        string tags="";        if (anchor_tags.length > 0) { @@ -241,6 +263,7 @@ template outputXHTMLs() {        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; @@ -250,6 +273,7 @@ template outputXHTMLs() {        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; @@ -338,7 +362,9 @@ template outputXHTMLs() {        string                     _txt,      ) {        auto tags = _xhtml_anchor_tags(obj.anchor_tags); +      _txt = font_face(_txt);        string o; +      _txt = (obj.bullet) ? ("●  " ~ _txt) : _txt;        if (obj.obj_cite_number.empty) {          o = format(q"¶  <div class="substance">        <p class="%s" indent="h%si%s">%s @@ -439,6 +465,10 @@ template outputXHTMLs() {      auto code(O)(        auto return ref const O  obj,      ) { +      string _txt = obj.text; +      _txt = (_txt) +        .replaceAll(rgx.newline, "<br>\n") +        .replaceAll(rgx.nbsp_char, " ");        string o;        if (obj.obj_cite_number.empty) {            o = format(q"¶  <div class="substance"> @@ -447,7 +477,7 @@ template outputXHTMLs() {        </p>      </div>¶",            obj.is_a, -          obj.text +          _txt          );        } else {          o = format(q"¶  <div class="substance"> @@ -460,7 +490,7 @@ template outputXHTMLs() {            obj.obj_cite_number,            obj.is_a,            obj.obj_cite_number, -          obj.text +          _txt          );        }        return o; | 
