diff options
Diffstat (limited to 'org/out_sqlite.org')
| -rw-r--r-- | org/out_sqlite.org | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/org/out_sqlite.org b/org/out_sqlite.org index a9f1065..418b2d3 100644 --- a/org/out_sqlite.org +++ b/org/out_sqlite.org @@ -875,14 +875,40 @@ string inline_images(M,O)( _img_pth = "../../../image/"; } if (_txt.match(rgx.inline_image)) { - _txt = _txt.replaceAll( // TODO bug where image dimensions (w or h) not given & consequently set to 0; should not be used (calculate earlier, abstraction) - rgx.inline_image, - ("$1<img src=\"" - ~ _img_pth - ~ "$3\" width=\"$4\" height=\"$5\" /> $6")); + _txt = replaceAll!(m => + m["pre"].to!string + ~ _img_element(_img_pth ~ m["img"].to!string, m["width"].to!string, + m["height"].to!string, _image_alt(m["post"].to!string)) + ~ " " ~ _image_rest(m["post"].to!string) + )(_txt, rgx.inline_image); } return _txt; } +/+ ↓ the same treatment of an image as the html and epub writers give + it, because this is the html the cgi search renders: the markup's + description is the alt text, and dimensions that are not there are + not written as zeroes. ++/ +string _image_alt(string _post) { + if (auto m = _post.matchFirst(rgx.inline_image_alt)) { + return m["alt"].to!string; + } + return ""; +} +string _image_rest(string _post) { + if (auto m = _post.matchFirst(rgx.inline_image_alt)) { + return m.post.to!string; + } + return _post; +} +string _img_element(string _src, string _w, string _h, string _alt) { + string _dim = (_w == "0" && _h == "0") + ? "" + : " width=\"" ~ _w ~ "\" height=\"" ~ _h ~ "\""; + return "<img src=\"" ~ _src ~ "\"" + ~ " alt=\"" ~ html_special_characters(_alt) ~ "\"" + ~ _dim ~ " />"; +} #+END_SRC ******* links |
