From 48ba380760b306077afa7a156a21d3ff98d26775 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 4 May 2018 21:22:39 -0400 Subject: html & epub images in place (dimensions not & other issues) --- src/sdp/meta/metadoc_from_src.d | 49 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'src/sdp/meta/metadoc_from_src.d') diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index f4701dc..fb95a98 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -1995,7 +1995,7 @@ template SiSUdocAbstraction() { if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { line = line.replaceAll( - regex(substitution_pair[Substitute.match]), + regex("\b" ~ substitution_pair[Substitute.match]), substitution_pair[Substitute.markup] ); } @@ -2012,19 +2012,19 @@ template SiSUdocAbstraction() { enum Substitute { match, markup, } if ( conf_make_meta.make.bold) { line = line.replaceAll( - regex(conf_make_meta.make.bold[Substitute.match]), + regex("\b" ~ conf_make_meta.make.bold[Substitute.match]), conf_make_meta.make.bold[Substitute.markup] ); } if (conf_make_meta.make.emphasis) { line = line.replaceAll( - regex(conf_make_meta.make.emphasis[Substitute.match]), + regex("\b" ~ conf_make_meta.make.emphasis[Substitute.match]), conf_make_meta.make.emphasis[Substitute.markup] ); } if (conf_make_meta.make.italics) { line = line.replaceAll( - regex(conf_make_meta.make.italics[Substitute.match]), + regex("\b" ~ conf_make_meta.make.italics[Substitute.match]), conf_make_meta.make.italics[Substitute.markup] ); } @@ -3867,6 +3867,43 @@ template SiSUdocAbstraction() { obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono_box, ("#{$1}#")); return obj_txt_in; } + static auto images(Ot)(Ot obj_txt_in) { + debug(asserts) { + static assert(is(typeof(obj_txt_in) == string)); + } + static auto mng = InlineMarkup(); + obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono, (mng.mono ~ "{$1}" ~ mng.mono)); // figure + /+ url matched +/ + obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented + if (obj_txt_in.match(rgx.smid_image_generic)) { /+ images with and without links +/ + debug(images) { + writeln("Image: ", obj_txt_in); + } + if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { + obj_txt_in = (obj_txt_in).replaceAll( + rgx.smid_image_with_dimensions, + ("$1" + ~ mkup.img ~ "$2,w$3h$4 " + ~ "$5") // ("$1{ $2 }$2$3") + ); + debug(images) { + writeln("IMAGE with size: ", obj_txt_in); // decide on representation + } + } else if (obj_txt_in.match(rgx.smid_image)) { + obj_txt_in = (obj_txt_in).replaceAll( + rgx.smid_image, + ("$1" + ~ mkup.img ~ "$2,w0h0 " + ~ "$3") // ("$1{ $2 }$2$3") + ); + debug(images) { + writeln("IMAGE: ", obj_txt_in); // decide on representation + } + } + } + obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono_box, ("#{$1}#")); // figure + return obj_txt_in; + } auto footnotes_endnotes_markup_and_number_or_stars(Ot)(Ot obj_txt_in, bool reset_note_numbers) { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -3954,6 +3991,10 @@ template SiSUdocAbstraction() { rgx.inline_notes_curly_sp_plus, (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) ); + /+ image matched +/ + if (obj_txt_in.match(rgx.smid_image_generic)) { + obj_txt_in = images(obj_txt_in); + } /+ url matched +/ if (obj_txt_in.match(rgx.smid_inline_url)) { urls = true; -- cgit v1.2.3