From 64922b57604c8e0c29a1dcd3ae313d243bf6b46d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 6 Jun 2017 17:52:38 -0400 Subject: html seg, work on subtoc & on nav pre-next --- org/default_regex.org | 1 + org/output_xmls.org | 139 ++++++++++++++++++++++++++++++++++++++------------ src/sdp/ao/rgx.d | 1 + src/sdp/output/html.d | 2 + src/sdp/output/rgx.d | 1 + src/sdp/output/xmls.d | 130 ++++++++++++++++++++++++++++++++++------------ 6 files changed, 208 insertions(+), 66 deletions(-) diff --git a/org/default_regex.org b/org/default_regex.org index dc9c4ab..b6173cf 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -440,6 +440,7 @@ static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+] /+ inline markup footnotes endnotes +/ static inline_link = ctRegex!(`┥(.+?)┝┤(.+?)├`, "mg"); static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); +static inline_link_subtoc = ctRegex!(`^(?P[5-7])~ ┥(?P.+?)┝┤(?P.+?)├`, "mg"); static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); diff --git a/org/output_xmls.org b/org/output_xmls.org index 2e9e72c..b826a12 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -137,28 +137,25 @@ auto html_scroll_head(Dm)( o = format(q"¶ - - - %s%s - - - - - - - - - - - - - - + + %s%s + + + + + + + + + + + + + - ¶", @@ -200,8 +197,7 @@ auto html_seg_head(Dm)( - - + @@ -449,23 +445,98 @@ auto inline_markup_seg(O)( #+END_SRC *** toc +**** subtoc #+name: xhtml_format_objects #+BEGIN_SRC d -auto toc_seg(O)( +string lev4_heading_subtoc(O)( auto return ref const O obj, - string _txt, ) { - string o; - o = format(q"¶
-

- %s -

-
¶", - obj.is_a, - obj.indent_hang, - obj.indent_base, - _txt, + char[] lev4_subtoc; + lev4_subtoc ~= "
\n"; + foreach (subtoc; obj.lev4_subtoc) { + if (auto m = subtoc.match(rgx.inline_link_subtoc)) { + auto indent = to!string(m.captures[1]); + auto text = to!string(m.captures[2]); + text = font_face(text); + auto link = to!string(m.captures[3]); + lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc, + format(q"¶

+ %s +

+¶", + indent, + indent, + link, + text, + )); + } + } + lev4_subtoc ~= "
\n"; + return lev4_subtoc.to!string; +} +#+END_SRC + +**** navigation pre next + +#+name: xhtml_format_objects +#+BEGIN_SRC d +string nav_pre_next_table(O)( + auto return ref const O obj, +) { + string prev, next, toc; + if (obj.segname_prev == "") { + prev = ""; + } else { + prev = format(q"¶ + + +  << [ prev ] + + +¶", + obj.segname_prev, + ); + } + if (obj.segname_next == "") { + next = ""; + } else { + next = format(q"¶ + + +  [ next ] >> + + +¶", + obj.segname_next, + ); + } + if (obj.segment_anchor_tag == "toc") { + toc = ""; + prev = ""; + } else { + toc = format(q"¶ + + +  [ toc ] + + +¶", + ); + } + string o = format(q"¶ +¶", + prev, + toc, + next, ); return o; } @@ -1333,6 +1404,8 @@ void seg(D,I)( } auto t = xhtml_format.heading_seg(obj, _txt, suffix); doc_html[segment_filename] ~= to!string(t[0]); + doc_html[segment_filename] ~= xhtml_format.nav_pre_next_table(obj); + doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj); doc_html_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: diff --git a/src/sdp/ao/rgx.d b/src/sdp/ao/rgx.d index d0d42df..aeab6e9 100644 --- a/src/sdp/ao/rgx.d +++ b/src/sdp/ao/rgx.d @@ -218,6 +218,7 @@ template SiSUrgxInit() { /+ inline markup footnotes endnotes +/ static inline_link = ctRegex!(`┥(.+?)┝┤(.+?)├`, "mg"); static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); + static inline_link_subtoc = ctRegex!(`^(?P[5-7])~ ┥(?P.+?)┝┤(?P.+?)├`, "mg"); static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); diff --git a/src/sdp/output/html.d b/src/sdp/output/html.d index 1b984fe..f620498 100644 --- a/src/sdp/output/html.d +++ b/src/sdp/output/html.d @@ -237,6 +237,8 @@ template outputHTML() { } auto t = xhtml_format.heading_seg(obj, _txt, suffix); doc_html[segment_filename] ~= to!string(t[0]); + doc_html[segment_filename] ~= xhtml_format.nav_pre_next_table(obj); + doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj); doc_html_endnotes[segment_filename] ~= t[1]; break; case 5: .. case 7: diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index ae7599f..4a9e33e 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -40,6 +40,7 @@ template SiSUoutputRgxInit() { /+ inline markup footnotes endnotes +/ static inline_link = ctRegex!(`┥(.+?)┝┤(.+?)├`, "mg"); static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); + static inline_link_subtoc = ctRegex!(`^(?P[5-7])~ ┥(?P.+?)┝┤(?P.+?)├`, "mg"); static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); diff --git a/src/sdp/output/xmls.d b/src/sdp/output/xmls.d index 2482f28..c7dd552 100644 --- a/src/sdp/output/xmls.d +++ b/src/sdp/output/xmls.d @@ -71,28 +71,25 @@ template outputXHTMLs() { o = format(q"¶ - - - %s%s - - - - - - - - - - - - - - + + %s%s + + + + + + + + + + + + + - ¶", @@ -128,8 +125,7 @@ template outputXHTMLs() { - - + @@ -331,20 +327,88 @@ template outputXHTMLs() { auto t = inline_notes_seg(obj, _txt); return t; } - auto toc_seg(O)( + string lev4_heading_subtoc(O)( auto return ref const O obj, - string _txt, ) { - string o; - o = format(q"¶
-

- %s -

-
¶", - obj.is_a, - obj.indent_hang, - obj.indent_base, - _txt, + char[] lev4_subtoc; + lev4_subtoc ~= "
\n"; + foreach (subtoc; obj.lev4_subtoc) { + if (auto m = subtoc.match(rgx.inline_link_subtoc)) { + auto indent = to!string(m.captures[1]); + auto text = to!string(m.captures[2]); + text = font_face(text); + auto link = to!string(m.captures[3]); + lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc, + format(q"¶

+ %s +

+ ¶", + indent, + indent, + link, + text, + )); + } + } + lev4_subtoc ~= "
\n"; + return lev4_subtoc.to!string; + } + string nav_pre_next_table(O)( + auto return ref const O obj, + ) { + string prev, next, toc; + if (obj.segname_prev == "") { + prev = ""; + } else { + prev = format(q"¶ + + +  << [ prev ] + + + ¶", + obj.segname_prev, + ); + } + if (obj.segname_next == "") { + next = ""; + } else { + next = format(q"¶ + + +  [ next ] >> + + + ¶", + obj.segname_next, + ); + } + if (obj.segment_anchor_tag == "toc") { + toc = ""; + prev = ""; + } else { + toc = format(q"¶ + + +  [ toc ] + + + ¶", + ); + } + string o = format(q"¶ + ¶", + prev, + toc, + next, ); return o; } -- cgit v1.2.3