aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-04-28 12:00:37 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commitf5320e4c3a9b21209ad7fd7c089bf144cfb60971 (patch)
tree236ee8570415e312d1686b80665cb8bb0770d91b /src
parentxml family css (diff)
xml family, special characters, deal with once
Diffstat (limited to 'src')
-rw-r--r--src/sdp/output_epub3.d31
-rw-r--r--src/sdp/output_html.d68
-rw-r--r--src/sdp/output_xmls.d99
3 files changed, 104 insertions, 94 deletions
diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d
index ea33f2e..3df1992 100644
--- a/src/sdp/output_epub3.d
+++ b/src/sdp/output_epub3.d
@@ -273,6 +273,7 @@ template outputEPub3() {
string suffix = ".xhtml";
foreach (part; doc_matters.keys_seq.seg) {
foreach (obj; doc_abstraction[part]) {
+ string _txt = xhtml_format.special_characters(obj, obj.text);
if (obj.is_a == "heading") {
switch (obj.heading_lev_markup) {
case 0: .. case 3:
@@ -308,12 +309,12 @@ template outputEPub3() {
foreach (top_level_heading; top_level_headings) {
doc_epub3[segment_filename] ~= top_level_heading;
}
- auto t = xhtml_format.heading_seg(obj, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- auto t = xhtml_format.heading_seg(obj, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -336,7 +337,7 @@ template outputEPub3() {
case "para":
switch (obj.is_a) {
case "toc":
- doc_epub3[segment_filename] ~= xhtml_format.toc(obj);
+ doc_epub3[segment_filename] ~= xhtml_format.toc_seg(obj, _txt);
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -357,7 +358,7 @@ template outputEPub3() {
case "para":
switch (obj.is_a) {
case "para":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -371,32 +372,32 @@ template outputEPub3() {
case "block":
switch (obj.is_a) {
case "quote":
- auto t = xhtml_format.quote_seg(obj, suffix);
+ auto t = xhtml_format.quote_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= to!string(t[0]);
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "group":
- auto t = xhtml_format.group_seg(obj, suffix);
+ auto t = xhtml_format.group_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= to!string(t[0]);
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "block":
- auto t = xhtml_format.block_seg(obj, suffix);
+ auto t = xhtml_format.block_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= to!string(t[0]);
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "poem": // double check why both poem & verse
break;
case "verse":
- auto t = xhtml_format.verse_seg(obj, suffix);
+ auto t = xhtml_format.verse_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= to!string(t[0]);
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "code":
- doc_epub3[segment_filename] ~= xhtml_format.code(obj);
+ doc_epub3[segment_filename] ~= xhtml_format.code(obj, _txt);
break;
case "table":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -419,26 +420,26 @@ template outputEPub3() {
case "para":
switch (obj.is_a) {
case "endnote":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
break;
case "glossary":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bibliography":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bookindex":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "blurb":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index 155ad48..509ae43 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -42,16 +42,17 @@ template outputHTML() {
string suffix = ".html";
foreach (part; doc_matters.keys_seq.scroll) {
foreach (obj; doc_abstraction[part]) {
+ string _txt = xhtml_format.special_characters(obj, obj.text);
switch (obj.use) {
case "frontmatter":
switch (obj.is_of) {
case "para":
switch (obj.is_a) {
case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, suffix);
+ doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
break;
case "toc":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -72,10 +73,10 @@ template outputHTML() {
case "para":
switch (obj.is_a) {
case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, suffix);
+ doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
break;
case "para":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -87,24 +88,24 @@ template outputHTML() {
case "block":
switch (obj.is_a) {
case "quote":
- doc_html ~= xhtml_format.quote_scroll(obj);
+ doc_html ~= xhtml_format.quote_scroll(obj, _txt);
break;
case "group":
- doc_html ~= xhtml_format.group_scroll(obj);
+ doc_html ~= xhtml_format.group_scroll(obj, _txt);
break;
case "block":
- doc_html ~= xhtml_format.block_scroll(obj);
+ doc_html ~= xhtml_format.block_scroll(obj, _txt);
break;
case "poem":
break;
case "verse":
- doc_html ~= xhtml_format.verse_scroll(obj, suffix);
+ doc_html ~= xhtml_format.verse_scroll(obj, _txt, suffix);
break;
case "code":
- doc_html ~= xhtml_format.code(obj);
+ doc_html ~= xhtml_format.code(obj, _txt);
break;
case "table":
- doc_html ~= xhtml_format.table(obj);
+ doc_html ~= xhtml_format.table(obj, _txt);
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -125,22 +126,22 @@ template outputHTML() {
case "para":
switch (obj.is_a) {
case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, suffix);
+ doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
break;
case "endnote":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
case "glossary":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
case "bibliography":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
case "bookindex":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
case "blurb":
- doc_html ~= xhtml_format.para_scroll(obj, suffix);
+ doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -211,6 +212,7 @@ template outputHTML() {
string suffix = ".html";
foreach (part; doc_matters.keys_seq.seg) {
foreach (obj; doc_abstraction[part]) {
+ string _txt = xhtml_format.special_characters(obj, obj.text);
if (obj.is_a == "heading") { // all headings: frontmatter, body & backmatter
switch (obj.heading_lev_markup) {
case 0: .. case 3:
@@ -235,8 +237,8 @@ template outputHTML() {
top_level_headings[3] = "";
goto default;
default:
- auto t = xhtml_format.heading_seg(obj, suffix);
- top_level_headings[obj.heading_lev_markup] = t[0];
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix);
+ top_level_headings[obj.heading_lev_markup] = t[0]; // should probably have different css tagging (fontsize etc)
break;
}
break;
@@ -247,12 +249,12 @@ template outputHTML() {
// writeln(top_level_heading);
doc_html[segment_filename] ~= top_level_heading;
}
- auto t = xhtml_format.heading_seg(obj, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- auto t = xhtml_format.heading_seg(obj, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -275,7 +277,7 @@ template outputHTML() {
case "para":
switch (obj.is_a) {
case "toc":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
break;
default:
@@ -297,7 +299,7 @@ template outputHTML() {
case "para":
switch (obj.is_a) {
case "para":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -311,32 +313,32 @@ template outputHTML() {
case "block":
switch (obj.is_a) {
case "quote":
- auto t = xhtml_format.quote_seg(obj, suffix);
+ auto t = xhtml_format.quote_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "group":
- auto t = xhtml_format.group_seg(obj, suffix);
+ auto t = xhtml_format.group_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "block":
- auto t = xhtml_format.block_seg(obj, suffix);
+ auto t = xhtml_format.block_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "poem":
break;
case "verse":
- auto t = xhtml_format.verse_seg(obj, suffix);
+ auto t = xhtml_format.verse_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= to!string(t[0]);
doc_html_endnotes[segment_filename] ~= t[1]; // work on
break;
case "code":
- doc_html[segment_filename] ~= xhtml_format.code(obj);
+ doc_html[segment_filename] ~= xhtml_format.code(obj, _txt);
break;
case "table":
- doc_html[segment_filename] ~= xhtml_format.table(obj);
+ doc_html[segment_filename] ~= xhtml_format.table(obj, _txt);
doc_html_endnotes[segment_filename] ~= "";
break;
default:
@@ -358,26 +360,26 @@ template outputHTML() {
case "para":
switch (obj.is_a) {
case "endnote":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= t[0];
break;
case "glossary":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bibliography":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bookindex":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "blurb":
- auto t = xhtml_format.para_seg(obj, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix);
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
diff --git a/src/sdp/output_xmls.d b/src/sdp/output_xmls.d
index 27b6585..347409e 100644
--- a/src/sdp/output_xmls.d
+++ b/src/sdp/output_xmls.d
@@ -31,12 +31,20 @@ template outputXHTMLs() {
mixin SiSUoutputRgxInit;
struct outputXHTMLs {
auto rgx = Rgx();
- string special_characters(string _txt){
+ string special_characters(O)(
+ auto return ref const O obj,
+ string _txt
+ ){
_txt = (_txt)
- .replaceAll(rgx.xhtml_ampersand, "&amp;")
- .replaceAll(rgx.xhtml_less_than, "&lt;")
- .replaceAll(rgx.xhtml_greater_than, "&gt;")
- .replaceAll(rgx.xhtml_line_break, "<br />");
+ .replaceAll(rgx.xhtml_ampersand, "&#38;")
+ .replaceAll(rgx.xhtml_quotation, "&#34;")
+ .replaceAll(rgx.xhtml_less_than, "&#60;")
+ .replaceAll(rgx.xhtml_greater_than, "&#62;")
+ .replaceAll(rgx.nbsp_char, " ");
+ if (!(obj.is_a == "code")) {
+ _txt = (_txt)
+ .replaceAll(rgx.xhtml_line_break, "<br />");
+ }
return _txt;
}
string font_face(string _txt){
@@ -313,26 +321,25 @@ template outputXHTMLs() {
}
auto inline_markup_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- string _txt = obj.text;
- _txt = special_characters(_txt);
_txt = inline_links(obj, _txt, _suffix, "scroll");
_txt = inline_notes_scroll(obj, _txt);
return _txt;
}
auto inline_markup_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- string _txt = obj.text;
- _txt = special_characters(_txt);
_txt = inline_links(obj, _txt, _suffix, "seg");
auto t = inline_notes_seg(obj, _txt);
return t;
}
- auto toc(O)(
+ auto toc_seg(O)(
auto return ref const O obj,
+ string _txt,
) {
string o;
o = format(q"¶ <div class="substance">
@@ -343,7 +350,7 @@ template outputXHTMLs() {
obj.is_a,
obj.indent_hang,
obj.indent_base,
- obj.text
+ _txt,
);
return o;
}
@@ -395,19 +402,21 @@ template outputXHTMLs() {
}
auto heading_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = heading(obj, _txt);
return o;
}
auto heading_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = t[0];
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = t[0];
string[] _endnotes = t[1];
string o = heading(obj, _txt);
auto u = tuple(
@@ -457,19 +466,21 @@ template outputXHTMLs() {
}
auto para_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = para(obj, _txt);
return o;
}
auto para_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = to!string(t[0]);
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = to!string(t[0]);
string[] _endnotes = t[1];
string o = para(obj, _txt);
auto u = tuple(
@@ -511,19 +522,21 @@ template outputXHTMLs() {
}
auto quote_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = quote(obj, _txt);
return o;
}
auto quote_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = to!string(t[0]);
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = to!string(t[0]);
string[] _endnotes = t[1];
string o = quote(obj, _txt);
auto u = tuple(
@@ -565,19 +578,21 @@ template outputXHTMLs() {
}
auto group_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = group(obj, _txt);
return o;
}
auto group_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = to!string(t[0]);
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = to!string(t[0]);
string[] _endnotes = t[1];
string o = group(obj, _txt);
auto u = tuple(
@@ -615,19 +630,21 @@ template outputXHTMLs() {
}
auto block_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = block(obj, _txt);
return o;
}
auto block_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = to!string(t[0]);
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = to!string(t[0]);
string[] _endnotes = t[1];
string o = block(obj, _txt);
auto u = tuple(
@@ -641,11 +658,6 @@ template outputXHTMLs() {
string _txt,
) {
_txt = font_face(_txt);
- _txt = (_txt)
- .replaceAll(rgx.newline, "<br />\n")
- .replaceAll(rgx.two_spaces, "&#160;" ~ "&#160;" ~ "&#160;" ~ "&#160;")
- .replaceAll(rgx.nbsp_and_space, "&#160;" ~ "&#160;")
- .replaceAll(rgx.strip_br, "");
string o;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
@@ -670,19 +682,21 @@ template outputXHTMLs() {
}
auto verse_scroll(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
- string _txt = inline_markup_scroll(obj, _suffix); // issue
+ _txt = inline_markup_scroll(obj, _txt, _suffix); // issue
string o = verse(obj, _txt);
return o;
}
auto verse_seg(O)(
auto return ref const O obj,
+ string _txt,
string _suffix = ".html",
) {
- auto t = inline_markup_seg(obj, _suffix);
- string _txt = to!string(t[0]);
+ auto t = inline_markup_seg(obj, _txt, _suffix);
+ _txt = to!string(t[0]);
string[] _endnotes = t[1];
string o = verse(obj, _txt);
auto u = tuple(
@@ -726,8 +740,8 @@ template outputXHTMLs() {
}
auto table(O)(
auto return ref const O obj,
+ string _txt,
) {
- string _txt = obj.text;
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = font_face(_txt);
auto t = tablarize(obj, _txt);
@@ -755,6 +769,7 @@ template outputXHTMLs() {
}
auto endnote(O)(
auto return ref const O obj,
+ string _txt,
) {
string o;
o = format(q"¶ <p class="%s" indent="h%si%s">
@@ -763,20 +778,14 @@ template outputXHTMLs() {
obj.is_a,
obj.indent_hang,
obj.indent_base,
- obj.text
+ _txt
);
return o;
}
auto code(O)(
auto return ref const O obj,
+ string _txt,
) {
- string _txt = obj.text;
- _txt = (_txt)
- .replaceAll(rgx.xhtml_ampersand, "&#38;")
- .replaceAll(rgx.xhtml_quotation, "&#34;")
- .replaceAll(rgx.xhtml_less_than, "&#60;")
- .replaceAll(rgx.xhtml_greater_than, "&#62;")
- .replaceAll(rgx.nbsp_char, " ");
string o;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
@@ -788,9 +797,7 @@ template outputXHTMLs() {
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <p class="%s" id="%s">
-%s
- </p>
+ <p class="%s" id="%s">%s</p>
</div>¶",
obj.obj_cite_number,
obj.obj_cite_number,