From da32ec40fc237b03f22aac329017d06735289a3a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Mar 2019 13:03:02 -0400 Subject: housekeeping --- src/doc_reform/output/defaults.d | 1 + src/doc_reform/output/epub3.d | 8 ++++++-- src/doc_reform/output/paths_output.d | 8 ++++---- src/doc_reform/output/rgx.d | 17 ++++++++++++----- src/doc_reform/output/sqlite.d | 12 ++++++------ src/doc_reform/output/xmls.d | 18 +++++++++--------- 6 files changed, 38 insertions(+), 26 deletions(-) (limited to 'src/doc_reform/output') diff --git a/src/doc_reform/output/defaults.d b/src/doc_reform/output/defaults.d index a038802..b8ff322 100644 --- a/src/doc_reform/output/defaults.d +++ b/src/doc_reform/output/defaults.d @@ -8,6 +8,7 @@ template InternalMarkup() { static struct InlineMarkup { auto en_a_o = "【"; auto en_a_c = "】"; auto en_b_o = "〖"; auto en_b_c = "〗"; + auto quote_o = "“"; auto quote_c = "”"; auto ff_o = "┨"; auto ff_c = "┣"; // fontface auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; diff --git a/src/doc_reform/output/epub3.d b/src/doc_reform/output/epub3.d index 97d8427..e02637c 100644 --- a/src/doc_reform/output/epub3.d +++ b/src/doc_reform/output/epub3.d @@ -288,7 +288,11 @@ template outputEPub3() { } } } - toc ~= format(q"┋ + toc ~= format(q"┋ + + + + ┋"); return toc; } @@ -630,7 +634,7 @@ template outputEPub3() { ? zip_data.write(contents.dup) : zip_data.write(contents.dup .replaceAll(rgx.spaces_line_start, "") - .replaceAll(rgx.newline, "") + .replaceAll(rgx.newline, " ") .strip ); zip_arc_member_file.expandedData = zip_data.toBytes(); diff --git a/src/doc_reform/output/paths_output.d b/src/doc_reform/output/paths_output.d index c35fa55..7980594 100644 --- a/src/doc_reform/output/paths_output.d +++ b/src/doc_reform/output/paths_output.d @@ -46,7 +46,7 @@ template DocReformOutPathsFnPd() { /+ TODO stuff to work out here +/ auto DocReformOutPathsFnPd(Fn,Pn)( Fn fn_src_pth, - Pn pod_name + Pn pod_name_with_path ) { struct _PathsStruct { string base_filename() { @@ -64,11 +64,11 @@ template DocReformOutPathsFnPd() { +/ string _fn_src = fn_src_pth.baseName.stripExtension; string _output_base_name; - if (!(pod_name.empty)) { - if (pod_name == _fn_src) { + if (!(pod_name_with_path.empty)) { + if (pod_name_with_path == _fn_src) { _output_base_name = _fn_src; } else { - _output_base_name = pod_name ~ "." ~ _fn_src; + _output_base_name = pod_name_with_path ~ "." ~ _fn_src; } } else { _output_base_name = _fn_src; diff --git a/src/doc_reform/output/rgx.d b/src/doc_reform/output/rgx.d index bf1d766..8cb4581 100644 --- a/src/doc_reform/output/rgx.d +++ b/src/doc_reform/output/rgx.d @@ -38,6 +38,11 @@ static template DocReformOutputRgxInit() { static src_base_parent_path = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure static src_formalised_file_path_parts = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure /+ line breaks +/ + static empty_line = ctRegex!(`^\s*$`); + static empty_block = ctRegex!(`^\s*$`, "mg"); + static br_line_natural = ctRegex!(`\n`, "mg"); + static br_empty_line = ctRegex!(`\n[ ]*\n`, "mg"); + static br_newlines_linebreaks = ctRegex!(`[\n┘┙]`, "mg"); static br_line = ctRegex!(`┘`, "mg"); static br_nl = ctRegex!(`┙`, "mg"); static br_paragraph = ctRegex!(`┚`, "mg"); @@ -48,22 +53,23 @@ static template DocReformOutputRgxInit() { 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_gen = ctRegex!(`【.+?】`, "m"); + static inline_notes_al_regular = ctRegex!(`【(.+?)】`, "mg"); static inline_notes_al_gen_text = ctRegex!(`【(?P.+?)】`, "m"); static inline_notes_al_gen_ref = ctRegex!(`【(?P[*+]\s+)\s*(?P.+?)】`, "mg"); + static inline_notes_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)\s*】`, "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_al_delimiter_close_regular = ctRegex!(`】`, "m"); static inline_al_delimiter_open_and_close_regular = ctRegex!(`【|】`, "m"); - static inline_notes_delimiter_al_regular = ctRegex!(`【(.+?)】`, "mg"); - static inline_notes_delimiter_al_regular_number_note = ctRegex!(`【(?P\d+)\s+(?P.+?)】`, "mg"); static inline_al_delimiter_open_asterisk = ctRegex!(`【\*`, "m"); static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); static inline_text_and_note_al = ctRegex!(`(?P.+?)【(?:[*+ ]*)(?P.+?)】`, "mg"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); - /+ inline markup footnotes endnotes +/ - static inline_image = ctRegex!(`(?P
┥)☼(?P(?P\S+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+))\s*(?P.*?┝┤.*?├)`, "mg");
-    static inline_image_without_dimensions                = ctRegex!(`(?P
┥)☼(?P(?P\S+?\.(?:jpg|gif|png)),w(?P0)h(?P0))\s*(?P.*?┝┤.*?├)`, "mg");
+    /+ inline markup links +/
+    static inline_image                                   = ctRegex!(`(?P
┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+))\s*(?P.*?┝┤.*?├)`, "mg");
+    static inline_image_without_dimensions                = ctRegex!(`(?P
┥)☼(?P(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P0)h(?P0))\s*(?P.*?┝┤.*?├)`, "mg");
+    static inline_image_info                              = ctRegex!(`☼?(?P[a-zA-Z0-9._-]+?\.(?:jpg|gif|png)),w(?P\d+)h(?P\d+)`, "mg");
     static inline_link_anchor                             = ctRegex!(`┋(?P\S+?)┋`, "mg"); // TODO *~text_link_anchor
     static inline_link_                                   = ctRegex!(`┥(?P.+?)┝┤(?P.+?)├`, "mg");
     static inline_link                                    = ctRegex!(`┥(?P.+?)┝┤(?P\S+?)├`, "mg");
@@ -75,6 +81,7 @@ static template DocReformOutputRgxInit() {
     static inline_link_clean                              = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
     static inline_a_url                                   = ctRegex!(`(┤)([^\s┥┝┤├]+)(├)`, "mg");
     static url                                            = ctRegex!(`https?://`, "mg");
+    static uri                                            = ctRegex!(`(?:https?|git)://`, "mg");
     static inline_link_subtoc                             = ctRegex!(`^(?P[5-7])~ ┥(?P.+?)┝┤(?P.+?)├`, "mg");
     static fn_suffix                                      = ctRegex!(`\.fnSuffix`, "mg");
     static inline_link_fn_suffix                          = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg");
diff --git a/src/doc_reform/output/sqlite.d b/src/doc_reform/output/sqlite.d
index c57dde9..113af10 100644
--- a/src/doc_reform/output/sqlite.d
+++ b/src/doc_reform/output/sqlite.d
@@ -387,17 +387,17 @@ template SQLiteFormatAndLoadObject() {
         if (obj.has.inline_notes_reg) {
           // _txt = font_face(_txt);
           _txt = _txt.replaceAll(
-            rgx.inline_notes_delimiter_al_regular_number_note,
+            rgx.inline_notes_al_regular_number_note,
             (" $1 ")
           );
         }
         debug(markup_endnotes) {
-          if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
+          if (_txt.match(rgx.inline_notes_al_regular_number_note)) {
             writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text);
           }
         }
         debug(markup) {
-          if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
+          if (_txt.match(rgx.inline_notes_al_regular_number_note)) {
             writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text);
           }
         }
@@ -411,7 +411,7 @@ template SQLiteFormatAndLoadObject() {
         string[] _endnotes;
         if (obj.has.inline_notes_reg) {
           /+ need markup for text, and separated footnote +/
-          foreach(m; _txt.matchAll(rgx.inline_notes_delimiter_al_regular_number_note)) {
+          foreach(m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) {
             _endnotes ~= format(
               "%s%s%s%s\n  %s%s%s%s%s\n  %s\n%s",
               "

", @@ -428,10 +428,10 @@ template SQLiteFormatAndLoadObject() { ); } _txt = _txt.replaceAll( - rgx.inline_notes_delimiter_al_regular_number_note, + rgx.inline_notes_al_regular_number_note, (" $1 ") ); - } else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + } else if (_txt.match(rgx.inline_notes_al_regular_number_note)) { debug(markup) { writeln(__LINE__, " endnote: ", obj.metainfo.is_a, ": ", obj.text); } diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index 244a618..eb8debd 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -311,7 +311,7 @@ template outputXHTMLs() { } auto tail() { string o; - o = format(q"┋ + o = format(q"┋ @@ -334,8 +334,8 @@ template outputXHTMLs() { _img_pth = "../../../image/"; } if (_txt.match(rgx.inline_image)) { - _txt = _txt.replaceAll( - rgx.inline_image, + _txt = _txt + .replaceAll(rgx.inline_image, ("$1 $6")) @@ -440,17 +440,17 @@ template outputXHTMLs() { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); _txt = _txt.replaceAll( - rgx.inline_notes_delimiter_al_regular_number_note, + rgx.inline_notes_al_regular_number_note, (" $1 ") ); } debug(markup_endnotes) { - if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); } } debug(markup) { - if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + if (_txt.match(rgx.inline_notes_al_regular_number_note)) { writeln(__LINE__, " (missed) markup endnote: ", obj.metainfo.is_a, ": ", obj.text); } } @@ -465,7 +465,7 @@ template outputXHTMLs() { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); /+ need markup for text, and separated footnote +/ - foreach(m; _txt.matchAll(rgx.inline_notes_delimiter_al_regular_number_note)) { + foreach(m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { _endnotes ~= format( "%s%s%s%s\n %s%s%s%s%s\n %s\n%s", "

", @@ -482,10 +482,10 @@ template outputXHTMLs() { ); } _txt = _txt.replaceAll( - rgx.inline_notes_delimiter_al_regular_number_note, + rgx.inline_notes_al_regular_number_note, (" $1 ") ); - } else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) { + } else if (_txt.match(rgx.inline_notes_al_regular_number_note)) { debug(markup) { writeln(__LINE__, " endnote: ", obj.metainfo.is_a, ": ", obj.text); } -- cgit v1.2.3