From ff78ec1fffc029a6947528f4b546dde57a633549 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 6 Sep 2016 20:58:58 -0400 Subject: 0.6.8 work on heading & anchor tag attributes, re-fix header_make headings --- src/sdp/ao_abstract_doc_source.d | 37 ++++++++++++------------------------- src/sdp/ao_object_setter.d | 34 ++++++++++++++++++++++++++++++++++ src/sdp/ao_rgx.d | 1 + 3 files changed, 47 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 3971db1..0ef486e 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -109,8 +109,8 @@ template SiSUdocAbstraction() { /+ ↓ abstract marked up document +/ auto abstract_doc_source( char[][] markup_sourcefile_content, - string[string][string] dochead_make_json, - string[string][string] dochead_meta_json + string[string][string] dochead_make_aa, + string[string][string] dochead_meta_aa ) { /+ ↓ abstraction init +/ scope(success) { @@ -327,11 +327,11 @@ template SiSUdocAbstraction() { && ((type["para"] == State.off) && (type["heading"] == State.off))) { /+ heading or para but neither flag nor line exists +/ - if ((to!string(dochead_make_json["make"]["headings"]).length > 2) + if ((dochead_make_aa["make"]["headings"].length > 2) && (type["make_headings"] == State.off)) { /+ heading found +/ auto dochead_make_headings = - to!string(dochead_make_json["make"]["headings"]); + dochead_make_aa["make"]["headings"]; heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type); } if ((type["make_headings"] == State.on) @@ -344,7 +344,7 @@ template SiSUdocAbstraction() { } if (matchFirst(line, rgx.heading)) { /+ heading match +/ - heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json); + heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_aa); } else if (line_occur["para"] == State.off) { /+ para match +/ para_match(line, an_object, indent, bullet, type, line_occur); @@ -1381,7 +1381,7 @@ template SiSUdocAbstraction() { an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= - set_abstract_object.contents_block( + set_abstract_object.contents_block_code( an_object["is"], an_object["substantive"], an_object["attrib"], @@ -1602,19 +1602,15 @@ template SiSUdocAbstraction() { ref Regex!(char)[string] heading_match_rgx, ref int[string] type ) { - if ((to!string(dochead_make_headings).length > 2) + if ((dochead_make_headings.length > 2) && (type["make_headings"] == State.off)) { /+ headings found +/ debug(headingsfound) { writeln(dochead_make_headings); } - auto make_headings_txt = - match( - to!string(dochead_make_headings), - rgx.within_quotes); char[][] make_headings_spl = split( - cast(char[]) make_headings_txt.captures[1], + cast(char[]) dochead_make_headings, rgx.make_heading_delimiter); debug(headingsfound) { writeln(make_headings_spl.length); @@ -1746,7 +1742,7 @@ template SiSUdocAbstraction() { ref int[string] lv, ref int[string] collapsed_lev, ref int[string] type, - ref string[string][string] dochead_meta_json + ref string[string][string] dochead_meta_aa ) { if (auto m = match(line, rgx.heading)) { /+ heading match +/ @@ -1760,8 +1756,8 @@ template SiSUdocAbstraction() { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": - an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"])); - an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"])); + an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_aa["title"]["main"])); + an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_aa["creator"]["author"])); collapsed_lev["h0"] = 1; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); @@ -2781,10 +2777,7 @@ template SiSUdocAbstraction() { ++obj_cite_number; ++mkn; foreach (endnote; endnotes_) { - type="para"; attrib=""; - indent["first"] = "0"; - indent["second"] = "0"; attrib=""; // endnotes ~= // set_abstract_object.contents_para( @@ -2794,15 +2787,9 @@ template SiSUdocAbstraction() { // false // ); endnotes_section ~= - set_abstract_object.contents_para( - type, + set_abstract_object.contents_endnote( endnote, - attrib, - obj_cite_number, - indent, - false ); - ++obj_cite_number; ++mkn; } auto t = tuple(endnotes_section, obj_cite_number); diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d index bb7a17e..0d8107c 100644 --- a/src/sdp/ao_object_setter.d +++ b/src/sdp/ao_object_setter.d @@ -15,6 +15,7 @@ template ObjectSetter() { bool bullet = false; } struct BlockAttrib { + string syntax = ""; } struct Comment { // no .attrib and no .obj_cite_number @@ -89,6 +90,23 @@ template ObjectSetter() { // object_set.node_structure.node = node; return object_set; } + auto contents_endnote( + in string object, + ) { + auto m = (matchFirst(object, rgx.note_ref)); + string notenumber = to!string(m.captures[1]); + string anchor_tag = "note_" ~ notenumber; + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "endnote"; + object_set.object = object.strip; + object_set.obj_cite_number = ""; + object_set.para_attrib.indent_start = 0; + object_set.para_attrib.indent_rest = 0; + object_set.para_attrib.bullet = false; + return object_set; + } auto contents_block( in string type, in string object, @@ -104,6 +122,22 @@ template ObjectSetter() { // object_set.node_structure.node = node; return object_set; } + auto contents_block_code( + in string type, + in string object, + in string attrib_language_syntax, + in int obj_cite_number + ) { + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "block"; + object_set.is_a = type; + object_set.block_attrib.syntax = attrib_language_syntax; + object_set.object = object; + object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + // object_set.node_structure.node = node; + return object_set; + } auto contents_block_obj_cite_number_string( in string type, in string object, diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 15f9ed9..cd97a02 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -149,6 +149,7 @@ template RgxInit() { static inline_text_and_note_square_sp = ctRegex!(`(.+?)~\[[*+]+\s+(.+?)\]~`, "mg"); static inline_text_and_note_square = ctRegex!(`(.+?)~\[\s*(.+?)\]~`, "mg"); static inline_note_square_delimiters = ctRegex!(`(~\[\s*)(.+?)(\]~)`, "mg"); + static note_ref = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg"); // {^{73.}^}#noteref_73 /+ inline markup book index +/ static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m"); static book_index_open = ctRegex!(`^=\{\s*([^}]+?)$`); -- cgit v1.2.3