From 87d62f48d6c8a2ccf9807f56c23a6ca71d1102e6 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 13 Jan 2019 14:19:04 -0500 Subject: 0.4.3 stow (most) uri/links in array, separate from object text - munge independently - no need to consider special munging of uri with text - uri can easily be munged independently (encoded as need be) --- src/doc_reform/meta/metadoc_from_src.d | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/doc_reform/meta/metadoc_from_src.d') diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 9d2935c..de2df2b 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -1731,6 +1731,25 @@ template DocReformDocAbstraction() { } return obj; } + auto _links(O)(O obj) { + if (auto m = obj.text.match(rgx.inline_link_stow_uri)) { + debug(links) { + writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count); + writeln("links to stow: ", (obj.text.match(rgx.inline_link_stow_uri))); + } + int _n_matches = (obj.text.match(rgx.inline_link_stow_uri)).count.to!int; + for(int i=0; i < _n_matches; ++i) { + if (obj.text.match(rgx.inline_link_stow_uri)) { + obj.stow.link ~= obj.text.matchFirst(rgx.inline_link_stow_uri)[2]; + obj.text = obj.text.replaceFirst( + rgx.inline_link_stow_uri, + format(q"¶┥%s┝┤%s├¶", "$1", i) + ); + } + } + } + return obj; + } foreach (ref obj; the_document_head_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1760,6 +1779,7 @@ template DocReformDocAbstraction() { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } if (the_table_of_contents_section.length > 1) { /+ scroll +/ @@ -1787,6 +1807,7 @@ template DocReformDocAbstraction() { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } } /+ multiple 1~ levels, loop through document body +/ @@ -1833,6 +1854,7 @@ template DocReformDocAbstraction() { _images ~= extract_images(obj.text); obj = _image_dimensions(manifest_matter, obj); } + obj = _links(obj); } } auto images=uniq(_images.sort()); @@ -1873,6 +1895,7 @@ template DocReformDocAbstraction() { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } } /+ optional only one 1~ level +/ @@ -1912,6 +1935,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj = _links(obj); } } /+ optional only one 1~ level +/ @@ -1951,6 +1975,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj = _links(obj); } } /+ optional only one 1~ level +/ @@ -1999,6 +2024,7 @@ template DocReformDocAbstraction() { obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; obj.metainfo.object_number_type = OCNtype.bkidx; } + obj = _links(obj); } /+ TODO assert failure, reinstate assert(obj_cite_digit_bkidx == ocn_bidx_ @@ -2042,6 +2068,7 @@ template DocReformDocAbstraction() { obj.metainfo.object_number_off = obj_cite_digits.off; obj.metainfo.object_number_type = OCNtype.non; } + obj = _links(obj); } } if (the_document_body_section.length > 1) { -- cgit v1.2.3