From 845f6440b8d2a672769f553a45aa1406c17d4c4f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Jan 2022 15:20:01 -0500 Subject: xmls, html group text output (bullets & indents) --- src/doc_reform/io_out/epub3.d | 2 +- src/doc_reform/io_out/html.d | 4 +-- src/doc_reform/io_out/rgx.d | 23 +++++++++++++++++ src/doc_reform/io_out/sqlite.d | 56 ++++++++++++++++++++++++++++++++++++++++++ src/doc_reform/io_out/xmls.d | 43 +++++++++++++++++++++++++++++++- src/doc_reform/meta/rgx.d | 3 ++- 6 files changed, 126 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 2881b69..029a2c2 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -415,7 +415,7 @@ template outputEPub3() { auto epubWrite = writeOut(); foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { - string _txt = xhtml_format.special_characters(obj); + string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); if (obj.metainfo.is_a == "heading") { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d index dd77ab8..136229b 100644 --- a/src/doc_reform/io_out/html.d +++ b/src/doc_reform/io_out/html.d @@ -76,7 +76,7 @@ template outputHTML() { foreach (part; doc_matters.has.keys_seq.scroll) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); - string _txt = xhtml_format.special_characters(obj); + string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { @@ -279,7 +279,7 @@ template outputHTML() { foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); - string _txt = xhtml_format.special_characters(obj); + string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj); if (obj.metainfo.is_a == "heading") { assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { diff --git a/src/doc_reform/io_out/rgx.d b/src/doc_reform/io_out/rgx.d index 12392f9..7f3b9da 100644 --- a/src/doc_reform/io_out/rgx.d +++ b/src/doc_reform/io_out/rgx.d @@ -160,5 +160,28 @@ static template spineRgxOut() { static latex_clean_internal_link = ctRegex!(`^(?:#|¤\S+?#)`, "m"); static latex_identify_inline_fontface = ctRegex!(`\\([_#$]┨.+?┣)\\([_#$])`, "mg"); static latex_clean_bookindex_linebreak = ctRegex!(`\s*\\\\\\\\\s*`, "m"); + /+ paragraph operators +/ + static grouped_para_indent_1 = ctRegex!(`^_1[ ]`, "m"); + static grouped_para_indent_2 = ctRegex!(`^_2[ ]`, "m"); + static grouped_para_indent_3 = ctRegex!(`^_3[ ]`, "m"); + static grouped_para_indent_4 = ctRegex!(`^_4[ ]`, "m"); + static grouped_para_indent_5 = ctRegex!(`^_5[ ]`, "m"); + static grouped_para_indent_6 = ctRegex!(`^_6[ ]`, "m"); + static grouped_para_indent_7 = ctRegex!(`^_7[ ]`, "m"); + static grouped_para_indent_8 = ctRegex!(`^_8[ ]`, "m"); + static grouped_para_indent_9 = ctRegex!(`^_9[ ]`, "m"); + static grouped_para_bullet = ctRegex!(`^_[*] `, "m"); + static grouped_para_bullet_indent_1 = ctRegex!(`^_1[*] `, "m"); + static grouped_para_bullet_indent_2 = ctRegex!(`^_2[*] `, "m"); + static grouped_para_bullet_indent_3 = ctRegex!(`^_3[*] `, "m"); + static grouped_para_bullet_indent_4 = ctRegex!(`^_4[*] `, "m"); + static grouped_para_bullet_indent_5 = ctRegex!(`^_5[*] `, "m"); + static grouped_para_bullet_indent_6 = ctRegex!(`^_6[*] `, "m"); + static grouped_para_bullet_indent_7 = ctRegex!(`^_7[*] `, "m"); + static grouped_para_bullet_indent_8 = ctRegex!(`^_8[*] `, "m"); + static grouped_para_bullet_indent_9 = ctRegex!(`^_9[*] `, "m"); + static grouped_para_bullet_indent = ctRegex!(`^_(?P[1-9])[*] `, "m"); + static grouped_para_indent = ctRegex!(`^_(?P[1-9])[ ]`, "m"); + static grouped_para_indent_hang = ctRegex!(`^_(?P[0-9])_(?P[0-9])[ ]`, "m"); } } diff --git a/src/doc_reform/io_out/sqlite.d b/src/doc_reform/io_out/sqlite.d index 58f8dd9..c1b55de 100644 --- a/src/doc_reform/io_out/sqlite.d +++ b/src/doc_reform/io_out/sqlite.d @@ -294,6 +294,57 @@ template SQLiteFormatAndLoadObject() { .replaceAll(rgx.inline_cite, "$1"); return _txt; } + string inline_grouped_text_bullets_indents(M,O)( + M doc_matters, + const O obj, + string _txt, + string _suffix = ".html", + string _xml_type = "seg", + ) { + static auto rgx = RgxO(); + if (obj.metainfo.is_a == "group") { + _txt = (_txt) + .replaceAll(rgx.grouped_para_indent_1, + "  ") + .replaceAll(rgx.grouped_para_indent_2, + "    ") + .replaceAll(rgx.grouped_para_indent_3, + "      ") + .replaceAll(rgx.grouped_para_indent_4, + "        ") + .replaceAll(rgx.grouped_para_indent_5, + "          ") + .replaceAll(rgx.grouped_para_indent_6, + "            ") + .replaceAll(rgx.grouped_para_indent_7, + "              ") + .replaceAll(rgx.grouped_para_indent_8, + "                ") + .replaceAll(rgx.grouped_para_indent_9, + "                  ") + .replaceAll(rgx.grouped_para_indent_hang, "  ") + .replaceAll(rgx.grouped_para_bullet, "●  ") + .replaceAll(rgx.grouped_para_bullet_indent_1, + "  ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_2, + "    ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_3, + "      ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_4, + "        ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_5, + "          ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_6, + "            ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_7, + "              ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_8, + "                ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_9, + "                  ●  "); + } + return _txt; + } string inline_images(M,O)( M doc_matters, const O obj, @@ -457,6 +508,9 @@ template SQLiteFormatAndLoadObject() { const O obj, string _txt, ) { + if (obj.metainfo.is_a == "group") { + _txt = inline_grouped_text_bullets_indents(doc_matters, obj, _txt, xml_type); + } _txt = inline_images(doc_matters, obj, _txt, xml_type); _txt = inline_links(doc_matters, obj, _txt, xml_type); _txt = inline_notes_scroll(doc_matters, obj, _txt); @@ -527,6 +581,7 @@ template SQLiteFormatAndLoadObject() { assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "group"); string _txt = munge_html(doc_matters, obj); + _txt = inline_markup(doc_matters, obj, _txt); string o = format(q"┃

%s

┃", @@ -544,6 +599,7 @@ template SQLiteFormatAndLoadObject() { assert(obj.metainfo.is_of_type == "block"); assert(obj.metainfo.is_a == "block"); string _txt = munge_html(doc_matters, obj); + _txt = inline_markup(doc_matters, obj, _txt); string o = format(q"┃

%s

┃", obj.metainfo.is_a, diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 0112df8..f0c7185 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -102,10 +102,51 @@ template outputXHTMLs() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - @safe string special_characters(O)( + @safe string special_characters_breaks_indents_bullets(O)( const O obj, ) { string _txt = special_characters_text(obj.text); + if (obj.metainfo.is_a == "group") { + _txt = (_txt) + .replaceAll(rgx.grouped_para_indent_1, + "  ") + .replaceAll(rgx.grouped_para_indent_2, + "    ") + .replaceAll(rgx.grouped_para_indent_3, + "      ") + .replaceAll(rgx.grouped_para_indent_4, + "        ") + .replaceAll(rgx.grouped_para_indent_5, + "          ") + .replaceAll(rgx.grouped_para_indent_6, + "            ") + .replaceAll(rgx.grouped_para_indent_7, + "              ") + .replaceAll(rgx.grouped_para_indent_8, + "                ") + .replaceAll(rgx.grouped_para_indent_9, + "                  ") + .replaceAll(rgx.grouped_para_indent_hang, "  ") + .replaceAll(rgx.grouped_para_bullet, "●  ") + .replaceAll(rgx.grouped_para_bullet_indent_1, + "  ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_2, + "    ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_3, + "      ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_4, + "        ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_5, + "          ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_6, + "            ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_7, + "              ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_8, + "                ●  ") + .replaceAll(rgx.grouped_para_bullet_indent_9, + "                  ●  "); + } if (!(obj.metainfo.is_a == "code")) { _txt = (_txt) .replaceAll(rgx.xhtml_line_break, "
"); diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index 78b86a4..5df1e9c 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -96,7 +96,7 @@ static template spineRgxIn() { static raw_author_munge = ctRegex!(`(?P\S.+?),\s+(?P.+)`,"i"); static yaml_header_meta_title = ctRegex!(`^\s*title\s*:\s*(?:"?\w|$)`, "m"); static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); - /+ heading & paragraph operators +/ + /+ heading operators +/ static heading_a = ctRegex!(`^:?[A][~] `, "m"); static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); static headings = ctRegex!(`^:?(?P[A-D1-4])[~](?:[a-z0-9_.-]*[?]?|[!](?:glossary|bibliogrphy|biblio|references?|blurb))(?:\s|$)`,"i"); @@ -112,6 +112,7 @@ static template spineRgxIn() { static heading_biblio = ctRegex!(`^1[~][!](biblio(?:graphy)?|references?)`); static heading_glossary = ctRegex!(`^1[~][!](glossary)`); static heading_blurb = ctRegex!(`^1[~][!](blurb)`); + /+ paragraph operators +/ static para_bullet = ctRegex!(`^_[*] `); static para_bullet_indent = ctRegex!(`^_(?P[1-9])[*] `); static para_indent = ctRegex!(`^_(?P[1-9])[ ]`); -- cgit v1.2.3