aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output/xmls.d
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/output/xmls.d
parentlink url matching (diff)
html & epub images in place (dimensions not & other issues)
Diffstat (limited to 'src/sdp/output/xmls.d')
-rw-r--r--src/sdp/output/xmls.d61
1 files changed, 48 insertions, 13 deletions
diff --git a/src/sdp/output/xmls.d b/src/sdp/output/xmls.d
index 7dd6a60..1621732 100644
--- a/src/sdp/output/xmls.d
+++ b/src/sdp/output/xmls.d
@@ -311,15 +311,39 @@ template outputXHTMLs() {
</html>ΒΆ");
return o;
}
+ auto inline_images(O)(
+ auto return ref const O obj,
+ string _txt,
+ string _suffix = ".html",
+ string _xml_type = "seg",
+ ) {
+ string _img_pth;
+ if (_xml_type == "epub") {
+ _img_pth = "image/";
+ } else if (_xml_type == "scroll") {
+ _img_pth = "../../image/";
+ } else if (_xml_type == "seg") {
+ _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\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6"));
+ }
+ return _txt;
+ }
auto inline_links(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
- string seg_scroll = "seg",
+ string _xml_type = "seg",
) {
if (obj.inline_links) {
if ((_txt.match(rgx.mark_internal_site_lnk))
- && (seg_scroll == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
+ && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
_txt = (_txt).replaceAll(
rgx.inline_seg_link,
"$1");
@@ -424,6 +448,7 @@ template outputXHTMLs() {
string _txt,
string _suffix = ".html",
) {
+ _txt = inline_images(obj, _txt, _suffix, "scroll");
_txt = inline_links(obj, _txt, _suffix, "scroll");
_txt = inline_notes_scroll(obj, _txt);
return _txt;
@@ -432,8 +457,10 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "seg",
) {
- _txt = inline_links(obj, _txt, _suffix, "seg");
+ _txt = inline_images(obj, _txt, _suffix, _xml_type);
+ _txt = inline_links(obj, _txt, _suffix, _xml_type);
auto t = inline_notes_seg(obj, _txt);
return t;
}
@@ -543,11 +570,11 @@ template outputXHTMLs() {
auto heading(O)(
auto return ref const O obj,
string _txt,
- string _type="html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
string _horizontal_rule = "<hr />";
- if ((_type != "html")
+ if ((_xml_type != "html")
|| (obj.heading_lev_markup == 0 || obj.heading_lev_markup > 4)) {
_horizontal_rule = "";
}
@@ -603,12 +630,12 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
- string _type = "html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0];
string[] _endnotes = t[1];
- string o = heading(obj, _txt, _type);
+ string o = heading(obj, _txt, _xml_type);
auto u = tuple(
o,
_endnotes,
@@ -668,8 +695,9 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = para(obj, _txt);
@@ -724,8 +752,9 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = quote(obj, _txt);
@@ -770,6 +799,7 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -780,8 +810,9 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = group(obj, _txt);
@@ -822,6 +853,7 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -832,8 +864,9 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = block(obj, _txt);
@@ -874,6 +907,7 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -884,8 +918,9 @@ template outputXHTMLs() {
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = verse(obj, _txt);