diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-01-13 14:19:04 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-05-17 16:59:38 -0400 |
commit | 87d62f48d6c8a2ccf9807f56c23a6ca71d1102e6 (patch) | |
tree | e367aff1a05f89104c7c81ac8a6c618a4f38b021 /src/doc_reform/meta | |
parent | 0.4.2 xmls output, internal (diff) |
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)
Diffstat (limited to 'src/doc_reform/meta')
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 27 | ||||
-rw-r--r-- | src/doc_reform/meta/object_setter.d | 4 | ||||
-rw-r--r-- | src/doc_reform/meta/rgx.d | 4 |
3 files changed, 34 insertions, 1 deletions
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) { diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index a4eaaf6..7b94027 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -98,6 +98,9 @@ template ObjectSetter() { struct DocObj_CodeBlock_ { string syntax = ""; } + struct DocObj_Stow_ { + string[] link = []; + } struct DocObj_Pointer_ { int doc_object = 0; int html_segnames = 0; @@ -124,6 +127,7 @@ template ObjectSetter() { DocObj_Has_ has; DocObj_Table_ table; DocObj_CodeBlock_ code_block; + DocObj_Stow_ stow; DocObj_Pointer_ ptr; } struct TheObjects { diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index c43390d..dcfc245 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -257,9 +257,11 @@ static template DocReformRgxInit() { 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_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg"); + 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"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); - static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); + static inline_a_url = ctRegex!(`(┤)([^\s┥┝┤├]+)(├)`, "mg"); static url = ctRegex!(`https?://`, "mg"); static inline_link_subtoc = ctRegex!(`^(?P<level>[5-7])~ ┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); |