diff options
Diffstat (limited to 'org')
| -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 |
3 files changed, 18 insertions, 6 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_; } |
