aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/meta
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2018-05-04 21:22:39 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:15 -0400
commit48ba380760b306077afa7a156a21d3ff98d26775 (patch)
tree3385a7efddac04cb52fb08a93b245c89e958e83d /src/sdp/meta
parentlink url matching (diff)
html & epub images in place (dimensions not & other issues)
Diffstat (limited to 'src/sdp/meta')
-rw-r--r--src/sdp/meta/defaults.d1
-rw-r--r--src/sdp/meta/metadoc_from_src.d49
-rw-r--r--src/sdp/meta/rgx.d4
3 files changed, 50 insertions, 4 deletions
diff --git a/src/sdp/meta/defaults.d b/src/sdp/meta/defaults.d
index f0137cb..2663c15 100644
--- a/src/sdp/meta/defaults.d
+++ b/src/sdp/meta/defaults.d
@@ -142,6 +142,7 @@ template InternalMarkup() {
auto tc_c = "┚";
auto tc_p = "┆";
auto mono = "■";
+ auto img = "☼";
static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") {
_indent_spaces = replicate(_indent_spaces, indent);
return _indent_spaces;
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;
diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d
index d15f90a..8b6f4d2 100644
--- a/src/sdp/meta/rgx.d
+++ b/src/sdp/meta/rgx.d
@@ -150,6 +150,9 @@ static template SiSUrgxInit() {
static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P<after>[.,;:?!]?(?:[ ]|$))`, "mg");
static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg");
static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg");
+ static smid_image_generic = ctRegex!(`(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).+?\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)[;:!,?.]?(?:[ )\]]|$)`, "mg");
+ static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?:[;:!,?.]?(?:[ )\]]|$)))`, "mg");
+ static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?:[;:!,?.]?(?:[ )\]]|$)))`, "mg");
/+ inline markup book index +/
static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m");
static book_index_open = ctRegex!(`^=\{\s*([^}]+?)$`);
@@ -244,6 +247,7 @@ static template SiSUrgxInit() {
static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg");
static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg");
/+ inline markup footnotes endnotes +/
+ static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg");
static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg");
static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg");