diff options
-rw-r--r-- | org/default_misc.org | 2 | ||||
-rw-r--r-- | org/default_regex.org | 26 | ||||
-rw-r--r-- | org/meta_abstraction.org | 52 | ||||
-rw-r--r-- | org/output_sqlite.org | 32 | ||||
-rw-r--r-- | org/output_xmls.org | 5 | ||||
-rw-r--r-- | src/doc_reform/meta/defaults.d | 2 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 46 | ||||
-rw-r--r-- | src/doc_reform/meta/rgx.d | 16 | ||||
-rw-r--r-- | src/doc_reform/output/defaults.d | 2 | ||||
-rw-r--r-- | src/doc_reform/output/rgx.d | 19 | ||||
-rw-r--r-- | src/doc_reform/output/sqlite.d | 32 | ||||
-rw-r--r-- | src/doc_reform/output/xmls.d | 5 |
12 files changed, 155 insertions, 84 deletions
diff --git a/org/default_misc.org b/org/default_misc.org index a811b91..320021e 100644 --- a/org/default_misc.org +++ b/org/default_misc.org @@ -249,6 +249,8 @@ template InternalMarkup() { auto tc_c = "┚"; auto tc_p = "┆"; auto img = "☼"; + auto on_o = "「"; auto on_c = "」"; + auto mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/org/default_regex.org b/org/default_regex.org index 2af9ed2..170b74f 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -52,7 +52,7 @@ static template DocReformRgxInit() { static true_dollar = ctRegex!(`\$`, "gm"); static flag_action = ctRegex!(`^(--[a-z][a-z0-9-]+)$`); static flag_action_str = ctRegex!(` (--[a-z][a-z0-9-]+)`); -static within_quotes = ctRegex!(`"(.+?)"`); +static within_quotes = ctRegex!(`"(.+?)"`, "m"); static make_heading_delimiter = ctRegex!(`[;][ ]*`); static arr_delimiter = ctRegex!(`[ ]*[;][ ]*`); static name_delimiter = ctRegex!(`^([^,]+)[ ]*,[ ]+(.+?)$`); @@ -280,10 +280,11 @@ static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<co #+name: meta_rgx #+BEGIN_SRC d static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); +static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); static smid_image_generic = ctRegex!(`(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).+?\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); -static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); -static smid_mod_image_without_dimensions = ctRegex!(`\{(?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0\s+(?:.+?)\s*\}(?:image|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); +static smid_image_delimit = ctRegex!(`(?P<pre>^|[ ]|[^\S]?)\{\s*(?P<text>.+?)\s*\}(?:image)(?=[;:!,?.]?([ )\]]|$))`, "mg"); +static smid_mod_image_without_dimensions = ctRegex!(`[{┥](?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0\s+(?:.+?)\s*[}┝](?:image|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); #+END_SRC *** inline markup book index :inline:bookindex: @@ -407,11 +408,11 @@ static template DocReformOutputRgxInit() { #+name: sp_ch_xhtml_rgx #+BEGIN_SRC d -static xhtml_ampersand = ctRegex!(`[&]`); // & -static xhtml_quotation = ctRegex!(`["]`); // " -static xhtml_less_than = ctRegex!(`[<]`); // < -static xhtml_greater_than = ctRegex!(`[>]`); // > -static xhtml_line_break = ctRegex!(` [\\]{2}`); // <br /> +static xhtml_ampersand = ctRegex!(`[&]`, "m"); // & +static xhtml_quotation = ctRegex!(`["]`, "m"); // " +static xhtml_less_than = ctRegex!(`[<]`, "m"); // < +static xhtml_greater_than = ctRegex!(`[>]`, "m"); // > +static xhtml_line_break = ctRegex!(` [\\]{2}`, "m"); // <br /> #+END_SRC * 2. ctRegex defaults shared by meta & output (generic) @@ -502,10 +503,13 @@ static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+] #+name: prgmkup_rgx #+BEGIN_SRC d /+ inline markup footnotes endnotes +/ -static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg"); -static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg"); -static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); +static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); +static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); // TODO *~text_link_anchor +static inline_link_ = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg"); +static inline_link_empty = ctRegex!(`┥(?P<text>.+?)┝┤├`, "mg"); +static inline_link_number = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg"); diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index bf67dcc..98f76ec 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -659,7 +659,7 @@ line._code_block_(an_object, obj_type_status); continue; #+END_SRC -**** _non code objects_ (other blocks or regular text) [+4] :non_code: +**** _non code objects_ (non-code blocks & regular text: by line) [+4] :non_code: ***** inline fontface markup #+name: abs_in_loop_body_non_code_obj @@ -1411,7 +1411,7 @@ if ((obj_type_status["heading"] == State.on) } #+END_SRC -*** regular text objects :text:paragraph: +*** regular _text objects_ identified :text:paragraph: #+name: abs_in_loop_body_01 #+BEGIN_SRC d @@ -1430,6 +1430,7 @@ if (the_document_body_section.length > 0) { obj_type_status["glossary_section"] = State.off; obj_type_status["blurb_section"] = State.off; } + the_document_body_section[$-1].text = (the_document_body_section[$-1].text).inline_markup_faces; if (the_document_body_section[$-1].metainfo.is_a == "verse") { /+ scan for endnotes for whole poem (each verse in poem) +/ foreach (i; previous_length .. the_document_body_section.length) { @@ -1753,7 +1754,7 @@ comp_obj_toc.attrib.indent_base = indent["base_position"]; comp_obj_toc.attrib.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Endnotes", "endnotes", ); @@ -1764,7 +1765,7 @@ if (the_endnotes_section.length > 1) { } if (the_glossary_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Glossary", "glossary", ); @@ -1775,7 +1776,7 @@ if (the_glossary_section.length > 1) { } if (the_bibliography_section.length > 1){ toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Bibliography", "bibliography", ); @@ -1786,7 +1787,7 @@ if (the_bibliography_section.length > 1){ } if (the_bookindex_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Book Index", "bookindex", ); @@ -1797,7 +1798,7 @@ if (the_bookindex_section.length > 1) { } if (the_blurb_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Blurb", "blurb", ); @@ -2427,9 +2428,6 @@ if (the_document_body_section.length > 1) { tag_assoc[(obj.metainfo.identifier)]["seg_lv1_to_4"] = obj.tags.epub_segment_anchor_tag_is; } - if (obj.metainfo.is_a != "code") { - obj.text = obj.text.inline_markup_faces; - } if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -2480,7 +2478,6 @@ if (the_endnotes_section.length > 1) { dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_endnotes_section) { - obj.text = obj.text.inline_markup_faces; if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -2680,9 +2677,6 @@ if (the_bookindex_section.length > 1) { /+ optional only one 1~ level +/ if (the_blurb_section.length > 1) { foreach (ref obj; the_blurb_section) { - if (obj.metainfo.is_a != "code") { - obj.text = obj.text.inline_markup_faces; - } if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -2959,7 +2953,7 @@ dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; #+END_SRC -*** [#A] _return document tuple_ :return:tuple: +*** _return document tuple_ [#A] :return:tuple: #+name: abs_return_tuple #+BEGIN_SRC d @@ -5413,22 +5407,20 @@ static struct ObjInlineMarkupMunge { writeln("Image: ", obj_txt_in); } if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { - obj_txt_in = obj_txt_in.replaceAll( - rgx.smid_image_with_dimensions, - ("$1" - ~ mkup.img ~ "$2,w$3h$4 " - ~ "$5") // ("$1{ $2 }$2$3") - ); + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image_with_dimensions, ("$1" ~ mkup.img ~ "$2,w$3h$4 " ~ "$5")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); debug(images) { - writeln("IMAGE with size: ", obj_txt_in); // decide on representation + writeln("IMAGE with size: ", obj_txt_in); } } else if (obj_txt_in.match(rgx.smid_image)) { - obj_txt_in = obj_txt_in.replaceAll( - rgx.smid_image, - ("$1" - ~ mkup.img ~ "$2,w0h0 " - ~ "$3") // ("$1{ $2 }$2$3") - ); + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image, ("$1" ~ mkup.img ~ "$2,w0h0 " ~ "$3")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); debug(images) { writeln("IMAGE: ", obj_txt_in); // decide on representation } @@ -5965,7 +5957,7 @@ static struct ObjInlineMarkup { "base_position" : obj_["lev_markup_number"].to!int, ]; toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s".strip ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, heading_toc_, _anchor_tag, ); @@ -6025,7 +6017,7 @@ static struct ObjInlineMarkup { break; case 5: .. case 7: subtoc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s".strip ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, heading_toc_, _anchor_tag, ); diff --git a/org/output_sqlite.org b/org/output_sqlite.org index 13b8702..52839d3 100644 --- a/org/output_sqlite.org +++ b/org/output_sqlite.org @@ -733,6 +733,10 @@ auto html_heading(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); + assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "para"); + assert(obj.metainfo.is_a == "heading"); string _txt = munge_html(doc_matters, obj); _txt = inline_markup(doc_matters, obj, _txt); string o = format(q"┋<p class="%s"><b> @@ -775,6 +779,10 @@ auto html_para(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); + assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "para"); + assert(obj.metainfo.is_a == "para" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); string _txt = munge_html(doc_matters, obj); _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; _txt = inline_markup(doc_matters, obj, _txt); @@ -798,6 +806,10 @@ auto html_quote(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "quote"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s"> %s @@ -817,6 +829,10 @@ auto html_group(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "group"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s"> %s @@ -836,6 +852,10 @@ auto html_block(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "block"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋ <p class="%s">%s</p>┋", @@ -854,6 +874,10 @@ auto html_verse(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "verse"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s">%s</p>┋", obj.metainfo.is_a, @@ -870,6 +894,10 @@ auto html_verse(M,O)( auto html_code(O)( auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "code"); string _txt = html_special_characters_code(obj.text); string o = format(q"┋<p class="%s">%s</p>┋", obj.metainfo.is_a, @@ -887,6 +915,10 @@ auto html_table(M,O)( M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "table"); auto _tablarize(O)( auto ref const O obj, string _txt, diff --git a/org/output_xmls.org b/org/output_xmls.org index 27069fd..1e4f91a 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -447,7 +447,10 @@ auto inline_images(O,M)( rgx.inline_image, ("$1<img src=\"" ~ _img_pth - ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6")); + ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6")) + .replaceAll( + rgx.inline_link_empty, + ("$1")); } return _txt; } diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index 7c1a726..fbde36e 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -152,6 +152,8 @@ template InternalMarkup() { auto tc_c = "┚"; auto tc_p = "┆"; auto img = "☼"; + auto on_o = "「"; auto on_c = "」"; + auto mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index d82c60a..470d579 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -1086,6 +1086,7 @@ template DocReformDocAbstraction() { obj_type_status["glossary_section"] = State.off; obj_type_status["blurb_section"] = State.off; } + the_document_body_section[$-1].text = (the_document_body_section[$-1].text).inline_markup_faces; if (the_document_body_section[$-1].metainfo.is_a == "verse") { /+ scan for endnotes for whole poem (each verse in poem) +/ foreach (i; previous_length .. the_document_body_section.length) { @@ -1316,7 +1317,7 @@ template DocReformDocAbstraction() { comp_obj_toc.attrib.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Endnotes", "endnotes", ); @@ -1327,7 +1328,7 @@ template DocReformDocAbstraction() { } if (the_glossary_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Glossary", "glossary", ); @@ -1338,7 +1339,7 @@ template DocReformDocAbstraction() { } if (the_bibliography_section.length > 1){ toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Bibliography", "bibliography", ); @@ -1349,7 +1350,7 @@ template DocReformDocAbstraction() { } if (the_bookindex_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Book Index", "bookindex", ); @@ -1360,7 +1361,7 @@ template DocReformDocAbstraction() { } if (the_blurb_section.length > 1) { toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s" ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, "Blurb", "blurb", ); @@ -1830,9 +1831,6 @@ template DocReformDocAbstraction() { tag_assoc[(obj.metainfo.identifier)]["seg_lv1_to_4"] = obj.tags.epub_segment_anchor_tag_is; } - if (obj.metainfo.is_a != "code") { - obj.text = obj.text.inline_markup_faces; - } if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -1875,7 +1873,6 @@ template DocReformDocAbstraction() { dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_endnotes_section) { - obj.text = obj.text.inline_markup_faces; if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -2045,9 +2042,6 @@ template DocReformDocAbstraction() { /+ optional only one 1~ level +/ if (the_blurb_section.length > 1) { foreach (ref obj; the_blurb_section) { - if (obj.metainfo.is_a != "code") { - obj.text = obj.text.inline_markup_faces; - } if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -4338,22 +4332,20 @@ template DocReformDocAbstraction() { writeln("Image: ", obj_txt_in); } if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { - obj_txt_in = obj_txt_in.replaceAll( - rgx.smid_image_with_dimensions, - ("$1" - ~ mkup.img ~ "$2,w$3h$4 " - ~ "$5") // ("$1{ $2 }$2$3") - ); + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image_with_dimensions, ("$1" ~ mkup.img ~ "$2,w$3h$4 " ~ "$5")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); debug(images) { - writeln("IMAGE with size: ", obj_txt_in); // decide on representation + writeln("IMAGE with size: ", obj_txt_in); } } else if (obj_txt_in.match(rgx.smid_image)) { - obj_txt_in = obj_txt_in.replaceAll( - rgx.smid_image, - ("$1" - ~ mkup.img ~ "$2,w0h0 " - ~ "$3") // ("$1{ $2 }$2$3") - ); + obj_txt_in = obj_txt_in + .replaceAll(rgx.smid_image, ("$1" ~ mkup.img ~ "$2,w0h0 " ~ "$3")) + .replaceAll(rgx.smid_image_delimit, ("$1" + ~ mkup.lnk_o ~ "$2".strip ~ mkup.lnk_c + ~ mkup.url_o ~ mkup.url_c)); debug(images) { writeln("IMAGE: ", obj_txt_in); // decide on representation } @@ -4762,7 +4754,7 @@ template DocReformDocAbstraction() { "base_position" : obj_["lev_markup_number"].to!int, ]; toc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s".strip ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, heading_toc_, _anchor_tag, ); @@ -4822,7 +4814,7 @@ template DocReformDocAbstraction() { break; case 5: .. case 7: subtoc_txt_ = format( - mkup.lnk_o ~ " %s " ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, + mkup.lnk_o ~ "%s".strip ~ mkup.lnk_c ~ mkup.url_o ~ "#%s"~ mkup.url_c, heading_toc_, _anchor_tag, ); diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index 7dd4a89..f875ce3 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -9,7 +9,7 @@ static template DocReformRgxInit() { static true_dollar = ctRegex!(`\$`, "gm"); static flag_action = ctRegex!(`^(--[a-z][a-z0-9-]+)$`); static flag_action_str = ctRegex!(` (--[a-z][a-z0-9-]+)`); - static within_quotes = ctRegex!(`"(.+?)"`); + static within_quotes = ctRegex!(`"(.+?)"`, "m"); static make_heading_delimiter = ctRegex!(`[;][ ]*`); static arr_delimiter = ctRegex!(`[ ]*[;][ ]*`); static name_delimiter = ctRegex!(`^([^,]+)[ ]*,[ ]+(.+?)$`); @@ -155,10 +155,11 @@ static template DocReformRgxInit() { static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); + static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); static smid_image_generic = ctRegex!(`(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).+?\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); - static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); - static smid_mod_image_without_dimensions = ctRegex!(`\{(?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0\s+(?:.+?)\s*\}(?:image|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + static smid_image_delimit = ctRegex!(`(?P<pre>^|[ ]|[^\S]?)\{\s*(?P<text>.+?)\s*\}(?:image)(?=[;:!,?.]?([ )\]]|$))`, "mg"); + static smid_mod_image_without_dimensions = ctRegex!(`[{┥](?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0\s+(?:.+?)\s*[}┝](?:image|(?:https?|git):\/\/\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); /+ inline markup book index +/ static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m"); static book_index_open = ctRegex!(`^=\{\s*([^}]+?)$`); @@ -254,10 +255,13 @@ static template DocReformRgxInit() { static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); /+ inline markup footnotes endnotes +/ - static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); + static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); + static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); + static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); // TODO *~text_link_anchor + static inline_link_ = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg"); + static inline_link_empty = ctRegex!(`┥(?P<text>.+?)┝┤├`, "mg"); + static inline_link_number = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg"); diff --git a/src/doc_reform/output/defaults.d b/src/doc_reform/output/defaults.d index e54afb9..a038802 100644 --- a/src/doc_reform/output/defaults.d +++ b/src/doc_reform/output/defaults.d @@ -33,6 +33,8 @@ template InternalMarkup() { auto tc_c = "┚"; auto tc_p = "┆"; auto img = "☼"; + auto on_o = "「"; auto on_c = "」"; + auto mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/src/doc_reform/output/rgx.d b/src/doc_reform/output/rgx.d index 354de00..bf1d766 100644 --- a/src/doc_reform/output/rgx.d +++ b/src/doc_reform/output/rgx.d @@ -62,10 +62,13 @@ static template DocReformOutputRgxInit() { static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); /+ inline markup footnotes endnotes +/ - static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); + static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.*?├)`, "mg"); + static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.*?├)`, "mg"); + static inline_link_anchor = ctRegex!(`┋(?P<anchor>\S+?)┋`, "mg"); // TODO *~text_link_anchor + static inline_link_ = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg"); + static inline_link_empty = ctRegex!(`┥(?P<text>.+?)┝┤├`, "mg"); + static inline_link_number = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg"); @@ -116,10 +119,10 @@ static template DocReformOutputRgxInit() { /+ table delimiters +/ static table_delimiter_col = ctRegex!("[ ]*[┊][ ]*", "mg"); static table_delimiter_row = ctRegex!("[ ]*\n", "mg"); - static xhtml_ampersand = ctRegex!(`[&]`); // & - static xhtml_quotation = ctRegex!(`["]`); // " - static xhtml_less_than = ctRegex!(`[<]`); // < - static xhtml_greater_than = ctRegex!(`[>]`); // > - static xhtml_line_break = ctRegex!(` [\\]{2}`); // <br /> + static xhtml_ampersand = ctRegex!(`[&]`, "m"); // & + static xhtml_quotation = ctRegex!(`["]`, "m"); // " + static xhtml_less_than = ctRegex!(`[<]`, "m"); // < + static xhtml_greater_than = ctRegex!(`[>]`, "m"); // > + static xhtml_line_break = ctRegex!(` [\\]{2}`, "m"); // <br /> } } diff --git a/src/doc_reform/output/sqlite.d b/src/doc_reform/output/sqlite.d index 5f4e99d..c57dde9 100644 --- a/src/doc_reform/output/sqlite.d +++ b/src/doc_reform/output/sqlite.d @@ -457,6 +457,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); + assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "para"); + assert(obj.metainfo.is_a == "heading"); string _txt = munge_html(doc_matters, obj); _txt = inline_markup(doc_matters, obj, _txt); string o = format(q"┋<p class="%s"><b> @@ -471,6 +475,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); + assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "para"); + assert(obj.metainfo.is_a == "para" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); string _txt = munge_html(doc_matters, obj); _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; _txt = inline_markup(doc_matters, obj, _txt); @@ -488,6 +496,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "quote"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s"> %s @@ -501,6 +513,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "group"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s"> %s @@ -514,6 +530,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "block"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋ <p class="%s">%s</p>┋", @@ -526,6 +546,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "verse"); string _txt = munge_html(doc_matters, obj); string o = format(q"┋<p class="%s">%s</p>┋", obj.metainfo.is_a, @@ -536,6 +560,10 @@ template SQLiteFormatAndLoadObject() { auto html_code(O)( auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "code"); string _txt = html_special_characters_code(obj.text); string o = format(q"┋<p class="%s">%s</p>┋", obj.metainfo.is_a, @@ -547,6 +575,10 @@ template SQLiteFormatAndLoadObject() { M doc_matters, auto ref const O obj, ) { + assert(obj.metainfo.is_of_part == "body"); + assert(obj.metainfo.is_of_section == "body"); + assert(obj.metainfo.is_of_type == "block"); + assert(obj.metainfo.is_a == "table"); auto _tablarize(O)( auto ref const O obj, string _txt, diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index 266ad55..244a618 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -338,7 +338,10 @@ template outputXHTMLs() { rgx.inline_image, ("$1<img src=\"" ~ _img_pth - ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6")); + ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6")) + .replaceAll( + rgx.inline_link_empty, + ("$1")); } return _txt; } |