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) --- org/meta_abstraction.org | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'org/meta_abstraction.org') diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 4c98f66..5249df1 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -2294,6 +2294,37 @@ auto _image_dimensions(M,O)(M manifest_matter, O obj) { } #+END_SRC +***** links: think about!!! +- move actual links to an array in object struct so they cannot be regex munged within text block + - you may wish to exclude certain types of internal document link + - object number links + - toc + - book index + - footnotes and footnote numbers + +#+name: abs_post +#+BEGIN_SRC d +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; +} +#+END_SRC + ***** ↻ Loop section: head #+name: abs_post @@ -2327,6 +2358,7 @@ foreach (ref obj; the_document_head_section) { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } #+END_SRC @@ -2360,6 +2392,7 @@ if (the_table_of_contents_section.length > 1) { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } } #+END_SRC @@ -2412,6 +2445,7 @@ if (the_document_body_section.length > 1) { _images ~= extract_images(obj.text); obj = _image_dimensions(manifest_matter, obj); } + obj = _links(obj); } } auto images=uniq(_images.sort()); @@ -2460,6 +2494,7 @@ if (the_endnotes_section.length > 1) { } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } + obj = _links(obj); } } #+END_SRC @@ -2507,6 +2542,7 @@ if (the_glossary_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj = _links(obj); } } #+END_SRC @@ -2554,6 +2590,7 @@ if (the_bibliography_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj = _links(obj); } } #+END_SRC @@ -2610,6 +2647,7 @@ if (the_bookindex_section.length > 1) { 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_ @@ -2659,6 +2697,7 @@ if (the_blurb_section.length > 1) { obj.metainfo.object_number_off = obj_cite_digits.off; obj.metainfo.object_number_type = OCNtype.non; } + obj = _links(obj); } } #+END_SRC @@ -7861,6 +7900,15 @@ struct DocObj_CodeBlock_ { } #+END_SRC +**** stow (things to be protected from regular text transformations, so far links) + +#+name: meta_structs_init +#+BEGIN_SRC d +struct DocObj_Stow_ { + string[] link = []; +} +#+END_SRC + **** pointers #+name: meta_structs_init @@ -7903,6 +7951,7 @@ struct ObjGenericComposite { DocObj_Has_ has; DocObj_Table_ table; DocObj_CodeBlock_ code_block; + DocObj_Stow_ stow; DocObj_Pointer_ ptr; } #+END_SRC -- cgit v1.2.3