diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-11-28 20:03:08 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:13 -0400 |
commit | 42942142d1379e7e5361a641f837beb54b23a2f1 (patch) | |
tree | 83ddd207debd3f854b6b5d2150807c9abd457c8a /src | |
parent | housekeeping (diff) |
discrete objects marks, output html work in progress
Diffstat (limited to 'src')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 50 | ||||
-rw-r--r-- | src/sdp/ao_object_setter.d | 21 | ||||
-rw-r--r-- | src/sdp/ao_rgx.d | 2 | ||||
-rw-r--r-- | src/sdp/output_html.d | 100 |
4 files changed, 136 insertions, 37 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 9bfa6cb..51089cd 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -651,7 +651,7 @@ template SiSUdocAbstraction() { } /+ ← closed: loop markup document/text line by line +/ /+ ↓ post loop markup document/text +/ debug(objectrelated2) { // check - writeln(line); + writeln(line); } /+ Backmatter: @@ -814,7 +814,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -831,7 +831,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -848,7 +848,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -863,7 +863,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -880,7 +880,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -895,7 +895,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -912,7 +912,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -929,7 +929,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -946,7 +946,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -961,7 +961,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -2677,7 +2677,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -2691,7 +2691,7 @@ template SiSUdocAbstraction() { "base_position" : 0, ]; the_table_of_contents_section["scroll"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", "Table of Contents", "", // attrib @@ -2709,7 +2709,7 @@ template SiSUdocAbstraction() { toc_txt_ = "{ Table of Contents }../toc.fn_suffix"; toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -2729,7 +2729,7 @@ template SiSUdocAbstraction() { ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -2750,7 +2750,7 @@ template SiSUdocAbstraction() { "base_position" : to!int(obj_["lev_markup_number"]), ]; the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -2772,7 +2772,7 @@ template SiSUdocAbstraction() { "base_position" : to!int(obj_["lev_markup_number"]), ]; the_table_of_contents_section["seg"] ~= - set_abstract_object.contents_para( + set_abstract_object.contents_toc( "toc", toc_txt_, "", // attrib @@ -3487,11 +3487,7 @@ template SiSUdocAbstraction() { m.captures[2]); // sometimes need segment name (segmented html & epub) } // TODO NEXT you need anchor for segments at this point -> - object_notes["seg"] ~= - munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ - m.captures[1] - ) ~ " " ~ m.captures[2] ~ "』"; + object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』"; object_notes["seg"] ~= (segment_object_belongs_to.empty) ? (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ @@ -3517,9 +3513,11 @@ template SiSUdocAbstraction() { if (object_notes.length > 1) { endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1]; endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1]; + endnotes_["anchor"] = (split(object_notes["anchor"], rgx.break_string))[0..$-1]; } else { endnotes_["seg"] = []; endnotes_["scroll"] = []; + endnotes_["anchor"] = []; } return endnotes_; } @@ -3609,15 +3607,15 @@ template SiSUdocAbstraction() { 1 ); } - foreach (endnote; endnotes_["seg"]) { + foreach (i, endnote; endnotes_["seg"]) { attrib=""; the_endnotes_section["seg"] ~= - set_abstract_object.contents_endnote(endnote); + set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]); } - foreach (endnote; endnotes_["scroll"]) { + foreach (i, endnote; endnotes_["scroll"]) { attrib=""; the_endnotes_section["scroll"] ~= - set_abstract_object.contents_endnote(endnote); + set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]); } auto t = tuple(the_endnotes_section, obj_cite_number); return t; diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d index c48ddc0..844af9b 100644 --- a/src/sdp/ao_object_setter.d +++ b/src/sdp/ao_object_setter.d @@ -95,8 +95,28 @@ template ObjectSetter() { // object_set.node_structure.node = _node; return object_set; } + auto contents_toc( + in string is_a, + in string object, + in string attrib, + in int obj_cite_number, + in int[string] indent, + in bool bullet + ) { + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "toc"; + object_set.object = object.strip; + object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + object_set.para_attrib.indent_start = to!int(indent["hang_position"]); + object_set.para_attrib.indent_rest = to!int(indent["base_position"]); + object_set.para_attrib.bullet = false; // bullet; + return object_set; + } auto contents_endnote( in string object, + in string tag, ) { auto m = (matchFirst(object, rgx.note_ref)); string notenumber = to!string(m.captures[1]); @@ -107,6 +127,7 @@ template ObjectSetter() { object_set.is_a = "endnote"; object_set.object = object.strip; object_set.obj_cite_number = ""; + object_set.anchor_tags ~= [ tag ]; object_set.para_attrib.indent_start = 0; object_set.para_attrib.indent_rest = 0; object_set.para_attrib.bullet = false; diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 3d531dc..f320867 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -144,7 +144,7 @@ template RgxInit() { static inline_al_delimiter_open_asterisk = ctRegex!(`【\*`, "m"); static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg"); - static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+ ]*.+?】|$))`, "mg"); + static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d index 5552fe2..c20d6ef 100644 --- a/src/sdp/output_html.d +++ b/src/sdp/output_html.d @@ -7,7 +7,7 @@ template SiSUoutputHTML() { o = format(q"¶<br><hr /><br> <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> - <h%s class="norm" id="%s"><a name="%s"></a> + <h%s class="%s" id="%s"><a name="%s"></a> %s </h%s> </div> @@ -15,6 +15,7 @@ template SiSUoutputHTML() { obj.obj_cite_number, obj.obj_cite_number, obj.heading_attrib.lev_markup_number, + obj.is_a, obj.obj_cite_number, obj.obj_cite_number, obj.object, @@ -26,17 +27,91 @@ template SiSUoutputHTML() { auto ref const O obj, ) { string o; + if (obj.obj_cite_number.empty) { + o = format(q"¶<div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" attrib="h%si%s"> + %s + </p> + </div> + ¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.para_attrib.indent_start, + obj.para_attrib.indent_rest, + obj.object + ); + } else { + o = format(q"¶<div class="substance"> + <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> + <p class="%s" attrib="h%si%s" id="%s"> + %s + </p> + </div> + ¶", + obj.obj_cite_number, + obj.obj_cite_number, + obj.is_a, + obj.para_attrib.indent_start, + obj.para_attrib.indent_rest, + obj.obj_cite_number, + obj.object + ); + } + return o; + } + auto html_endnote(O)( + auto ref const O obj, + ) { + string o; + o = format(q"¶<div class="substance"> + <label class="tag"><a name="%s" a href="%s" class="lnkocn"></a></label> + <p class="%s" attrib="h%si%s"> + %s + </p> + </div> + ¶", + obj.anchor_tags[0], + obj.anchor_tags[0], + obj.is_a, + obj.para_attrib.indent_start, + obj.para_attrib.indent_rest, + obj.object + ); + return o; + } + auto html_toc(O)( + auto ref const O obj, + ) { + string o; + o = format(q"¶<div class="substance"> + <p class="%s" attrib="h%si%s"> + %s + </p> + </div> + ¶", + obj.is_a, + obj.para_attrib.indent_start, + obj.para_attrib.indent_rest, + obj.object + ); + return o; + } + auto html_nugget(O)( + auto ref const O obj, + ) { + string o; o = format(q"¶<div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> - <p class="h%si%s" id="%s"> + <p class="%s" id="%s"> %s </p> </div> ¶", obj.obj_cite_number, obj.obj_cite_number, - obj.para_attrib.indent_start, - obj.para_attrib.indent_rest, + obj.is_a, obj.obj_cite_number, obj.object ); @@ -104,29 +179,34 @@ template SiSUoutputHTML() { case "heading": body_html ~= html_heading(obj); break; + case "toc": + body_html ~= html_toc(obj); + break; case "para": body_html ~= html_para(obj); break; case "verse": - body_html ~= html_para(obj); + body_html ~= html_nugget(obj); break; case "group": - body_html ~= html_para(obj); + body_html ~= html_nugget(obj); break; case "block": - body_html ~= html_para(obj); + body_html ~= html_nugget(obj); break; case "quote": - body_html ~= html_para(obj); + body_html ~= html_nugget(obj); break; case "table": body_html ~= html_para(obj); break; case "code": - body_html ~= html_para(obj); + body_html ~= html_nugget(obj); + break; + case "endnote": + body_html ~= html_endnote(obj); break; default: - body_html ~= html_para(obj); break; } } |