aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_xhtmls.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/output_xhtmls.d')
-rw-r--r--src/sdp/output_xhtmls.d212
1 files changed, 208 insertions, 4 deletions
diff --git a/src/sdp/output_xhtmls.d b/src/sdp/output_xhtmls.d
index 6a4c3a3..de5236d 100644
--- a/src/sdp/output_xhtmls.d
+++ b/src/sdp/output_xhtmls.d
@@ -1,5 +1,30 @@
template outputXHTMLs() {
+ private import
+ std.algorithm,
+ std.array,
+ std.container,
+ std.exception,
+ std.file,
+ std.getopt,
+ std.json,
+ std.process,
+ std.stdio,
+ std.path,
+ std.range,
+ std.regex,
+ std.string,
+ std.traits,
+ std.typecons,
+ std.uni,
+ std.utf,
+ std.conv : to;
+ import
+ defaults,
+ output_rgx,
+ output_xhtmls;
+ mixin SiSUoutputRgxInit;
struct outputXHTMLs {
+ auto rgx = Rgx();
string _xhtml_anchor_tags(const(string[]) anchor_tags) {
string tags="";
if (anchor_tags.length > 0) {
@@ -98,6 +123,137 @@ template outputXHTMLs() {
</html>¶");
return o;
}
+ auto inline_links(O)(
+ auto return ref const O obj,
+ string _txt,
+ string _suffix = ".html",
+ string seg_scroll = "seg",
+ ) {
+ if (obj.inline_links) {
+ if ((seg_scroll == "scroll")
+ && match(_txt, rgx.mark_internal_site_lnk)) {
+ _txt = (_txt).replaceAll(
+ rgx.inline_seg_link,
+ "$1");
+ }
+ _txt = (_txt).replaceAll(
+ rgx.inline_link_fn_suffix,
+ ("$1" ~ _suffix));
+ _txt = (_txt).replaceAll(
+ rgx.inline_link,
+ ("<a href=\"$2\">$1</a>"));
+ _txt = (_txt).replaceAll(
+ rgx.mark_internal_site_lnk,
+ ""
+ );
+ }
+ debug(markup_links) {
+ if ( match(_txt, rgx.inline_link)) {
+ writeln(__LINE__,
+ " (missed) markup link identified (",
+ obj.inline_links,
+ "): ", obj.is_a, ": ",
+ obj.text
+ );
+ }
+ }
+ debug(markup) {
+ if ( match(_txt, rgx.inline_link)) {
+ writeln(__LINE__,
+ " (missed) markup link identified (",
+ obj.inline_links,
+ "): ", obj.is_a, ": ",
+ obj.text
+ );
+ }
+ }
+ return _txt;
+ }
+ auto inline_notes_scroll(O)(
+ auto return ref const O obj,
+ string _txt,
+ ) {
+ if (obj.inline_notes_reg) {
+ _txt = (_txt).replaceAll(
+ rgx.inline_notes_delimiter_al_regular_number_note,
+ ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&nbsp;<sup>$1</sup>&nbsp;</note></a>")
+ );
+ }
+ debug(markup_endnotes) {
+ if (match(_txt, rgx.inline_notes_delimiter_al_regular_number_note)) {
+ writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text);
+ }
+ }
+ debug(markup) {
+ if (match(_txt, rgx.inline_notes_delimiter_al_regular_number_note)) {
+ writeln(__LINE__, " (missed) markup endnote: ", obj.is_a, ": ", obj.text);
+ }
+ }
+ // if (obj.inline_notes_star) {
+ // _txt = replaceAll(
+ // _txt,
+ // rgx.inline_notes_delimiter_al_regular_number_note,
+ // ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&nbsp;<sup>$1</sup>&nbsp;</note></a>")
+ // );
+ // }
+ return _txt;
+ }
+ auto inline_notes_seg(O)(
+ auto return ref const O obj,
+ string _txt,
+ ) {
+ string[] _endnotes;
+ if (obj.inline_notes_reg) {
+ /+ need markup for text, and separated footnote +/
+ foreach(m; matchAll(_txt, rgx.inline_notes_delimiter_al_regular_number_note)) {
+ _endnotes ~= format(
+ "%s%s%s%s\n %s%s%s%s%s\n %s\n%s",
+ "<p class=\"endnote\">",
+ "<a href=\"#noteref_",
+ m.captures[1],
+ "\">",
+ "<note id=\"note_",
+ m.captures[1],
+ "\">&nbsp;<sup>",
+ m.captures[1],
+ ".</sup></note></a>",
+ m.captures[2],
+ "</p>"
+ );
+ }
+ _txt = (_txt).replaceAll(
+ rgx.inline_notes_delimiter_al_regular_number_note,
+ ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&nbsp;<sup>$1</sup>&nbsp;</note></a>")
+ );
+ } else if (match(_txt, rgx.inline_notes_delimiter_al_regular_number_note)) {
+ debug(markup) {
+ writeln(__LINE__, " endnote: ", obj.is_a, ": ", obj.text);
+ }
+ }
+ auto t = tuple(
+ _txt,
+ _endnotes,
+ );
+ return t;
+ }
+ auto inline_markup_scroll(O)(
+ auto return ref const O obj,
+ string _suffix = ".html",
+ ) {
+ string _txt = obj.text;
+ _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 _suffix = ".html",
+ ) {
+ string _txt = obj.text;
+ _txt = inline_links(obj, _txt, _suffix, "seg");
+ auto t = inline_notes_seg(obj, _txt);
+ return t;
+ }
auto toc(O)(
auto return ref const O obj,
) {
@@ -116,6 +272,7 @@ template outputXHTMLs() {
}
auto heading(O)(
auto return ref const O obj,
+ string _txt,
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
string o;
@@ -129,7 +286,7 @@ template outputXHTMLs() {
obj.heading_lev_markup,
obj.is_a,
tags,
- obj.text,
+ _txt,
obj.heading_lev_markup,
);
} else {
@@ -147,14 +304,38 @@ template outputXHTMLs() {
obj.obj_cite_number,
obj.obj_cite_number,
tags,
- obj.text,
+ _txt,
obj.heading_lev_markup,
);
}
return o;
}
+ auto heading_scroll(O)(
+ auto return ref const O obj,
+ string _suffix = ".html",
+ ) {
+ auto tags = _xhtml_anchor_tags(obj.anchor_tags);
+ string _txt = inline_markup_scroll(obj, _suffix); // issue
+ string o = heading(obj, _txt);
+ return o;
+ }
+ auto heading_seg(O)(
+ auto return ref const O obj,
+ string _suffix = ".html",
+ ) {
+ auto t = inline_markup_seg(obj, _suffix);
+ string _txt = t[0];
+ string[] _endnotes = t[1];
+ string o = heading(obj, _txt);
+ auto u = tuple(
+ o,
+ _endnotes,
+ );
+ return u;
+ }
auto para(O)(
auto return ref const O obj,
+ string _txt,
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
string o;
@@ -168,7 +349,7 @@ template outputXHTMLs() {
obj.indent_hang,
obj.indent_base,
tags,
- obj.text
+ _txt
);
} else {
o = format(q"¶ <div class="substance">
@@ -184,11 +365,34 @@ template outputXHTMLs() {
obj.indent_base,
obj.obj_cite_number,
tags,
- obj.text
+ _txt
);
}
return o;
}
+ auto para_scroll(O)(
+ auto return ref const O obj,
+ string _suffix = ".html",
+ ) {
+ auto tags = _xhtml_anchor_tags(obj.anchor_tags);
+ string _txt = inline_markup_scroll(obj, _suffix); // issue
+ string o = para(obj, _txt);
+ return o;
+ }
+ auto para_seg(O)(
+ auto return ref const O obj,
+ string _suffix = ".html",
+ ) {
+ auto t = inline_markup_seg(obj, _suffix);
+ string _txt = to!string(t[0]);
+ string[] _endnotes = t[1];
+ string o = para(obj, _txt);
+ auto u = tuple(
+ o,
+ _endnotes,
+ );
+ return u;
+ }
auto nugget(O)(
auto return ref const O obj,
) {