diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-01-25 14:36:59 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-01-25 20:58:41 -0500 |
commit | 3c2da303eed87e506533c738c1bcfda154944790 (patch) | |
tree | 0e5125110e58ef64ce13a980b281328f325740c6 | |
parent | metadata, topic register to json removed, unused (diff) |
doc presentation, add option to include date with title and author
-rw-r--r-- | org/default_regex.org | 3 | ||||
-rw-r--r-- | org/metaverse.org | 28 | ||||
-rw-r--r-- | org/out_xmls.org | 23 | ||||
-rw-r--r-- | src/doc_reform/io_out/epub3.d | 4 | ||||
-rw-r--r-- | src/doc_reform/io_out/xmls.d | 14 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 28 | ||||
-rw-r--r-- | src/doc_reform/meta/rgx.d | 3 |
7 files changed, 91 insertions, 12 deletions
diff --git a/org/default_regex.org b/org/default_regex.org index 9ea040e..6734b62 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -138,8 +138,11 @@ static comment = ctRegex!(`^%+ `); #+NAME: meta_rgx_headers #+BEGIN_SRC d /+ header +/ +static variable_doc_title_author_date = ctRegex!(`@title-author-date`); +static variable_doc_title_author = ctRegex!(`@title-author`); static variable_doc_title = ctRegex!(`@title`); static variable_doc_author = ctRegex!(`@author|@creator`); +static variable_doc_date = ctRegex!(`@date`); static raw_author_munge = ctRegex!(`(?P<last>\S.+?),\s+(?P<first>.+)`,"i"); static yaml_header_meta_title = ctRegex!(`^\s*title\s*:\s*(?:"?\w|$)`, "m"); static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); diff --git a/org/metaverse.org b/org/metaverse.org index 421bd2b..f3e7425 100644 --- a/org/metaverse.org +++ b/org/metaverse.org @@ -5151,6 +5151,7 @@ if (pith["block_is"] == eN.blk_is.quote) { return ref CMM conf_make_meta, ) { static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); if (auto m = line.match(rgx.headings)) { /+ heading match +/ ++line_occur["heading"]; pith["txt_is"] = eN.txt_is.heading; @@ -5162,11 +5163,32 @@ if (pith["block_is"] == eN.blk_is.quote) { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": // Title set - if (an_object[an_object_key].match(rgx.variable_doc_title) - && an_object[an_object_key].match(rgx.variable_doc_author)) { + if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author) + && an_object[an_object_key].match(rgx.variable_doc_date))) { + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_nl + ~ conf_make_meta.meta.creator_author + ~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")")) + .replaceFirst(rgx.variable_doc_title, + (conf_make_meta.meta.title_full ~ mkup.br_nl)) + .replaceFirst(rgx.variable_doc_author, + conf_make_meta.meta.creator_author) + .replaceFirst(rgx.variable_doc_date, + " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"); + } else if ((an_object[an_object_key].match(rgx.variable_doc_title_author)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author))) { an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_nl + ~ conf_make_meta.meta.creator_author)) .replaceFirst(rgx.variable_doc_title, - (conf_make_meta.meta.title_full ~ ", ")) + (conf_make_meta.meta.title_full ~ mkup.br_nl)) .replaceFirst(rgx.variable_doc_author, conf_make_meta.meta.creator_author); } else if (an_object[an_object_key].match(rgx.variable_doc_title)) { diff --git a/org/out_xmls.org b/org/out_xmls.org index ca202c4..ef96b34 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -34,6 +34,7 @@ template outputXHTMLs() { static auto rgx = RgxO(); <<xhtml_format_objects_div_delimit>> <<xhtml_format_objects_special_characters_text>> + <<xhtml_format_objects_special_characters_date>> <<xhtml_format_objects_breaks_indents_bullets>> <<xhtml_format_objects_font_face>> <<xhtml_format_objects_xml_anchor_tags>> @@ -158,6 +159,22 @@ import .replaceAll(rgx.xhtml_quotation, """) // """ .replaceAll(rgx.xhtml_less_than, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" + .replaceAll(rgx.br_line, "<br>") + .replaceAll(rgx.br_nl, "<br>") + .replaceAll(rgx.nbsp_char, " "); + return _txt; +} +#+END_SRC + +**** special characters date + +#+NAME: xhtml_format_objects_special_characters_date +#+BEGIN_SRC d +@safe string special_characters_date(string _txt) { + _txt = _txt + .replaceAll(regex(r"(?:-00)+"), "") + .replaceAll(rgx.br_line, "<br>") + .replaceAll(rgx.br_nl, "<br>") .replaceAll(rgx.nbsp_char, " "); return _txt; } @@ -286,7 +303,7 @@ import special_characters_text(doc_matters.conf_make_meta.meta.title_full), special_characters_text(doc_matters.conf_make_meta.meta.creator_author), _publisher, - special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_date(doc_matters.conf_make_meta.meta.date_published), special_characters_text(doc_matters.conf_make_meta.meta.date_created), special_characters_text(doc_matters.conf_make_meta.meta.date_issued), special_characters_text(doc_matters.conf_make_meta.meta.date_available), @@ -490,7 +507,7 @@ import special_characters_text(doc_matters.conf_make_meta.meta.title_full), (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), - special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_date(doc_matters.conf_make_meta.meta.date_published), special_characters_text(doc_matters.conf_make_meta.meta.date_created), special_characters_text(doc_matters.conf_make_meta.meta.date_issued), special_characters_text(doc_matters.conf_make_meta.meta.date_available), @@ -2430,7 +2447,7 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), doc_matters.src.language, // language, fix (needed in dochead metadata) (doc_matters.conf_make_meta.meta.date_published.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.date_published), + ? "" : xhtml_format.special_characters_date(doc_matters.conf_make_meta.meta.date_published), (doc_matters.conf_make_meta.meta.rights_copyright.empty) ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), _uuid, diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 029a2c2..6593db5 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -70,6 +70,8 @@ template outputEPub3() { .replaceAll(rgx.xhtml_quotation, """) // """ .replaceAll(rgx.xhtml_less_than, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" + .replaceAll(rgx.br_line, "<br>") + .replaceAll(rgx.br_nl, "<br>") .replaceAll(rgx.nbsp_char, " "); return _txt; } @@ -126,7 +128,7 @@ template outputEPub3() { ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author), doc_matters.src.language, // language, fix (needed in dochead metadata) (doc_matters.conf_make_meta.meta.date_published.empty) - ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.date_published), + ? "" : xhtml_format.special_characters_date(doc_matters.conf_make_meta.meta.date_published), (doc_matters.conf_make_meta.meta.rights_copyright.empty) ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright), _uuid, diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index f0c7185..f4ca976 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -99,6 +99,16 @@ template outputXHTMLs() { .replaceAll(rgx.xhtml_quotation, """) // """ .replaceAll(rgx.xhtml_less_than, "<") // "<" .replaceAll(rgx.xhtml_greater_than, ">") // ">" + .replaceAll(rgx.br_line, "<br>") + .replaceAll(rgx.br_nl, "<br>") + .replaceAll(rgx.nbsp_char, " "); + return _txt; + } + @safe string special_characters_date(string _txt) { + _txt = _txt + .replaceAll(regex(r"(?:-00)+"), "") + .replaceAll(rgx.br_line, "<br>") + .replaceAll(rgx.br_nl, "<br>") .replaceAll(rgx.nbsp_char, " "); return _txt; } @@ -202,7 +212,7 @@ template outputXHTMLs() { special_characters_text(doc_matters.conf_make_meta.meta.title_full), special_characters_text(doc_matters.conf_make_meta.meta.creator_author), _publisher, - special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_date(doc_matters.conf_make_meta.meta.date_published), special_characters_text(doc_matters.conf_make_meta.meta.date_created), special_characters_text(doc_matters.conf_make_meta.meta.date_issued), special_characters_text(doc_matters.conf_make_meta.meta.date_available), @@ -382,7 +392,7 @@ template outputXHTMLs() { special_characters_text(doc_matters.conf_make_meta.meta.title_full), (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : ", " ~ special_characters_text(doc_matters.conf_make_meta.meta.creator_author), - special_characters_text(doc_matters.conf_make_meta.meta.date_published), + special_characters_date(doc_matters.conf_make_meta.meta.date_published), special_characters_text(doc_matters.conf_make_meta.meta.date_created), special_characters_text(doc_matters.conf_make_meta.meta.date_issued), special_characters_text(doc_matters.conf_make_meta.meta.date_available), diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 65e0754..28ce990 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -4041,6 +4041,7 @@ template docAbstraction() { return ref CMM conf_make_meta, ) { static auto rgx = RgxI(); + static auto mkup = InlineMarkup(); if (auto m = line.match(rgx.headings)) { /+ heading match +/ ++line_occur["heading"]; pith["txt_is"] = eN.txt_is.heading; @@ -4052,11 +4053,32 @@ template docAbstraction() { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": // Title set - if (an_object[an_object_key].match(rgx.variable_doc_title) - && an_object[an_object_key].match(rgx.variable_doc_author)) { + if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author) + && an_object[an_object_key].match(rgx.variable_doc_date))) { + an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_nl + ~ conf_make_meta.meta.creator_author + ~ " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")")) + .replaceFirst(rgx.variable_doc_title, + (conf_make_meta.meta.title_full ~ mkup.br_nl)) + .replaceFirst(rgx.variable_doc_author, + conf_make_meta.meta.creator_author) + .replaceFirst(rgx.variable_doc_date, + " (" ~ (conf_make_meta.meta.date_published.replaceFirst(regex(r"(?:-00)+"),"")) ~ ")"); + } else if ((an_object[an_object_key].match(rgx.variable_doc_title_author)) + || (an_object[an_object_key].match(rgx.variable_doc_title) + && an_object[an_object_key].match(rgx.variable_doc_author))) { an_object[an_object_key] = an_object[an_object_key] + .replaceFirst(rgx.variable_doc_title_author_date, + (conf_make_meta.meta.title_full + ~ mkup.br_nl + ~ conf_make_meta.meta.creator_author)) .replaceFirst(rgx.variable_doc_title, - (conf_make_meta.meta.title_full ~ ", ")) + (conf_make_meta.meta.title_full ~ mkup.br_nl)) .replaceFirst(rgx.variable_doc_author, conf_make_meta.meta.creator_author); } else if (an_object[an_object_key].match(rgx.variable_doc_title)) { diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index 5df1e9c..0d2912d 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -91,8 +91,11 @@ static template spineRgxIn() { static comment = ctRegex!(`^%+ `); /+ header +/ /+ header +/ + static variable_doc_title_author_date = ctRegex!(`@title-author-date`); + static variable_doc_title_author = ctRegex!(`@title-author`); static variable_doc_title = ctRegex!(`@title`); static variable_doc_author = ctRegex!(`@author|@creator`); + static variable_doc_date = ctRegex!(`@date`); static raw_author_munge = ctRegex!(`(?P<last>\S.+?),\s+(?P<first>.+)`,"i"); static yaml_header_meta_title = ctRegex!(`^\s*title\s*:\s*(?:"?\w|$)`, "m"); static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); |