diff options
| -rw-r--r-- | org/default_regex.org | 4 | ||||
| -rw-r--r-- | org/in_source_files.org | 9 | ||||
| -rw-r--r-- | org/ocda_functions.org | 11 | ||||
| -rw-r--r-- | src/sisudoc/ocda/io_in/read_source_files.d | 9 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 11 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/rgx.d | 4 |
6 files changed, 36 insertions, 12 deletions
diff --git a/org/default_regex.org b/org/default_regex.org index 430828b..d1fc76f 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -343,7 +343,9 @@ static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<co #+NAME: meta_rgx_images #+BEGIN_SRC d -static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); +/+ image post internal markup ┥☼name.png,w640h447 ┝┤├ +/ +static image_in_object_text = ctRegex!(`☼(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg)),w\d+h\d+`, "mg"); +/+ smid_image for sisu markup source (.sst) images `{ name.png }image` +/ static smid_image = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); static smid_image_generic = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); diff --git a/org/in_source_files.org b/org/in_source_files.org index 6c6fd2c..e8b5272 100644 --- a/org/in_source_files.org +++ b/org/in_source_files.org @@ -301,11 +301,16 @@ template spineRawMarkupContent() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); string[] _images=[]; + /+ ↓ the images a markup source shows. + matched on the image markup itself ({ name.png }image, and the url and + ~^ forms), ensure a filename-shaped word in prose is not mistaken for + one, and over every match (so a line showing two images reports two). + +/ string[] _extract_images(S)(S content_block) { string[] images_; string _content_block = content_block.to!string; - if (auto m = _content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1].to!string; + foreach (m; _content_block.matchAll(rgx.smid_image)) { + images_ ~= m["image"].to!string; } return images_; } diff --git a/org/ocda_functions.org b/org/ocda_functions.org index 6ab4bbf..ca8a7be 100644 --- a/org/ocda_functions.org +++ b/org/ocda_functions.org @@ -1441,12 +1441,17 @@ ST_flow_table_array_munge flow_table_array_munge()( #+NAME: ocdaFunc_images #+HEADER: :noweb yes #+BEGIN_SRC d -// ↓ - images +/+ ↓ - images, the images an object shows. + matched on the internal markup an image has become by this stage + (┥☼name.png,w640h447 ┝┤├), so a filename-shaped word in prose is not + taken for one, and over every match rather than the first, so a + paragraph showing two images reports two. ++/ string[] extract_images()(string content_block) { static auto rgx = RgxI(); string[] images_; - if (auto m = content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1]; + foreach (m; content_block.matchAll(rgx.image_in_object_text)) { + images_ ~= m["image"].to!string; } return images_; } diff --git a/src/sisudoc/ocda/io_in/read_source_files.d b/src/sisudoc/ocda/io_in/read_source_files.d index 720ee63..f99bb9b 100644 --- a/src/sisudoc/ocda/io_in/read_source_files.d +++ b/src/sisudoc/ocda/io_in/read_source_files.d @@ -67,11 +67,16 @@ template spineRawMarkupContent() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); string[] _images=[]; + /+ ↓ the images a markup source shows. + matched on the image markup itself ({ name.png }image, and the url and + ~^ forms), ensure a filename-shaped word in prose is not mistaken for + one, and over every match (so a line showing two images reports two). + +/ string[] _extract_images(S)(S content_block) { string[] images_; string _content_block = content_block.to!string; - if (auto m = _content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1].to!string; + foreach (m; _content_block.matchAll(rgx.smid_image)) { + images_ ~= m["image"].to!string; } return images_; } diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index f51f6fe..77770f4 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -4278,12 +4278,17 @@ template docAbstractionFunctions() { return ret; } // ↑ - section blurb - // ↓ - images + /+ ↓ - images, the images an object shows. + matched on the internal markup an image has become by this stage + (┥☼name.png,w640h447 ┝┤├), so a filename-shaped word in prose is not + taken for one, and over every match rather than the first, so a + paragraph showing two images reports two. + +/ string[] extract_images()(string content_block) { static auto rgx = RgxI(); string[] images_; - if (auto m = content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1]; + foreach (m; content_block.matchAll(rgx.image_in_object_text)) { + images_ ~= m["image"].to!string; } return images_; } diff --git a/src/sisudoc/ocda/meta/rgx.d b/src/sisudoc/ocda/meta/rgx.d index 357df25..4ade610 100644 --- a/src/sisudoc/ocda/meta/rgx.d +++ b/src/sisudoc/ocda/meta/rgx.d @@ -158,7 +158,9 @@ static template spineRgxIn() { static smid_inline_link_markup_regular = ctRegex!(`(?P<pre>^|[ (\[])\{\s*(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[.,;:?!]?([ ]|$))`, "mg"); static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); - static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); + /+ image post internal markup ┥☼name.png,w640h447 ┝┤├ +/ + static image_in_object_text = ctRegex!(`☼(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg)),w\d+h\d+`, "mg"); + /+ smid_image for sisu markup source (.sst) images `{ name.png }image` +/ static smid_image = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); static smid_image_generic = ctRegex!(`(?:^|[ ])[{┥](?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).*?[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$))`, "mg"); static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ])[{┥](?:~\^\s+|\s*))(?P<image>[a-zA-Z0-9._-]+?\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.*?)\s*[}┝](?:image|┤.*?├|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?=[;:!,?.]?([ )\]]|$)))`, "mg"); |
