From aae005b24ce816d89bcda6e72de2cdeadcf7ded0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 17 Sep 2016 16:45:36 -0400 Subject: heading anchor_tags and cleaning --- org/ao_abstract_doc_source.org | 285 ++++++++++++++++++++++++++++++++--------- org/ao_defaults.org | 12 +- org/ao_output_debugs.org | 32 ++++- org/ao_read_source_files.org | 10 +- 4 files changed, 270 insertions(+), 69 deletions(-) (limited to 'org') diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 020d9ed..f82c480 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -50,6 +50,7 @@ mixin InternalMarkup; auto rgx = Rgx(); ObjComposite[] contents_the_objects; string[string] an_object, processing; +string[] anchor_tags; auto set_abstract_object = ObjectAbstractSet(); auto note_section = NotesSection(); /+ enum +/ @@ -153,13 +154,12 @@ line_occur = [ ]; auto type = flags_type_init; mixin ScreenTxtColors; -int tell_lo(int obj_cite_number, in char[] line) { +void tell_lo(int obj_cite_number, in char[] line) { writefln( "* %s %s", to!string(obj_cite_number), to!string(line) ); - return 0; } string[string] obj_cite_number_poem = [ "start" : "", @@ -254,7 +254,7 @@ if (!line.empty) { *** [#A] separate regular markup text from code blocks [+5] **** code blocks :block:code: -#+name: abs_in_loop_body_00 +#+name: abs_in_loop_body_00_code_block #+BEGIN_SRC d if (type["code"] == TriState.on) { /+ block object: code +/ @@ -264,9 +264,9 @@ if (type["code"] == TriState.on) { **** non code objects (other blocks or regular text) [+4] :non_code: -#+name: abs_in_loop_body_00 +#+name: abs_in_loop_body_00_non_code_block #+BEGIN_SRC d -} else if (!matchFirst(line, rgx.skip_code_block_from_regular_parse)) { +} else if (!matchFirst(line, rgx.skip_from_regular_parse)) { /+ object other than "code block" object (includes regular text paragraph, headings & blocks other than code) +/ #+END_SRC @@ -562,8 +562,10 @@ if ((type["heading"] == State.on) heading_pointer, an_object["is"] ); // heading - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); // tuple this with anchor tags? + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); ++heading_pointer; @@ -572,8 +574,10 @@ if ((type["heading"] == State.on) an_object["substantive"], an_object["attrib"], obj_cite_number, + anchor_tags, + to!string(an_object["lev"]), to!int(an_object["lev_markup_number"]), - to!int(an_object["lev_collapsed_number"]) + to!int(an_object["lev_collapsed_number"]), ); // track previous heading and make assertions debug(objectrelated1) { // check @@ -610,8 +614,10 @@ if ((type["heading"] == State.on) heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -700,7 +706,8 @@ debug(objectrelated2) { // check * references / bibliography * book index +/ -obj_im.obj_inline_markup("doc_end_reset", "", dochead_make_aa); +// TODO FIGURE OUT, you need this possibility +// obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", "", dochead_make_aa); #+END_SRC *** [#B] endnotes :endnotes: @@ -833,7 +840,7 @@ auto header_set_common( #+name: abs_functions #+BEGIN_SRC d -auto check_obj_cite_number_status(char[] line, ref int[string] type) { +void check_obj_cite_number_status(char[] line, ref int[string] type) { if ((!line.empty) && (type["obj_cite_number_status_multi_obj"] == TriState.off)) { /+ not multi-line object, check whether obj_cite_number is on or turned off +/ if (matchFirst(line, rgx.obj_cite_number_block_marks)) { @@ -874,7 +881,6 @@ auto check_obj_cite_number_status(char[] line, ref int[string] type) { } } } - return 0; } #+END_SRC @@ -884,14 +890,14 @@ auto check_obj_cite_number_status(char[] line, ref int[string] type) { #+name: abs_functions #+BEGIN_SRC d -auto start_block( +void start_block( char[] line, ref int[string] type, string[string] obj_cite_number_poem ) { #+END_SRC -**** block curly open :curly: +**** block (various) curly open :curly: #+name: abs_functions #+BEGIN_SRC d @@ -966,7 +972,7 @@ auto start_block( type["curly_table"] = TriState.on; #+END_SRC -**** block tic open :tic: +**** block (various) tic open :tic: #+name: abs_functions #+BEGIN_SRC d @@ -1045,7 +1051,6 @@ auto start_block( #+name: abs_functions #+BEGIN_SRC d - return 0; } #+END_SRC @@ -1054,7 +1059,7 @@ auto start_block( #+name: abs_functions #+BEGIN_SRC d -auto code_block( +void code_block( char[] line, ref string[string] an_object, ref int[string] type @@ -1088,7 +1093,6 @@ auto code_block( an_object["obj"] ~= line ~= "\n"; // code (tic) line } } - return 0; } #+END_SRC @@ -1308,7 +1312,7 @@ why extra object stuff only in poem/verse? #+name: abs_functions #+BEGIN_SRC d -auto poem_block( +void poem_block( char[] line, ref string[string] an_object, ref int[string] type, @@ -1340,14 +1344,16 @@ auto poem_block( } if (an_object.length > 0) { debug(poem) { // poem (curly) close - tell_lo( + writeln( obj_cite_number, an_object["obj"] ); } an_object["is"] = "verse"; - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1395,8 +1401,10 @@ auto poem_block( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1426,12 +1434,14 @@ auto poem_block( if (an_object.length > 0) { debug(poem) { // poem (tic) close writeln(__LINE__); - tell_lo(obj_cite_number, line); + writeln(obj_cite_number, line); } processing.remove("verse"); an_object["is"] = "verse"; - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1479,8 +1489,10 @@ auto poem_block( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1496,7 +1508,6 @@ auto poem_block( } } } - return 0; } #+END_SRC @@ -1504,7 +1515,7 @@ auto poem_block( #+name: abs_functions #+BEGIN_SRC d -auto group_block( +void group_block( char[] line, ref string[string] an_object, ref int[string] type @@ -1538,7 +1549,6 @@ auto group_block( an_object["obj"] ~= line ~= "\n"; // build group array (or string) } } - return 0; } #+END_SRC @@ -1546,7 +1556,7 @@ auto group_block( #+name: abs_functions #+BEGIN_SRC d -auto block_block( +void block_block( char[] line, ref string[string] an_object, ref int[string] type @@ -1580,7 +1590,6 @@ auto block_block( an_object["obj"] ~= line ~= "\n"; // build block array (or string) } } - return 0; } #+END_SRC @@ -1588,7 +1597,7 @@ auto block_block( #+name: abs_functions #+BEGIN_SRC d -auto quote_block(char[] line, ref string[string] an_object, ref int[string] type) { +void quote_block(char[] line, ref string[string] an_object, ref int[string] type) { if (type["curly_quote"] == TriState.on) { if (matchFirst(line, rgx.block_curly_quote_close)) { debug(quote) { // quote (curly) close @@ -1618,7 +1627,6 @@ auto quote_block(char[] line, ref string[string] an_object, ref int[string] type an_object["obj"] ~= line ~= "\n"; // build quote array (or string) } } - return 0; } #+END_SRC @@ -1626,7 +1634,7 @@ auto quote_block(char[] line, ref string[string] an_object, ref int[string] type #+name: abs_functions #+BEGIN_SRC d -auto table_block(char[] line, ref string[string] an_object, ref int[string] type) { +void table_block(char[] line, ref string[string] an_object, ref int[string] type) { if (type["curly_table"] == TriState.on) { if (matchFirst(line, rgx.block_curly_table_close)) { debug(table) { // table (curly) close @@ -1656,7 +1664,6 @@ auto table_block(char[] line, ref string[string] an_object, ref int[string] type an_object["obj"] ~= line ~= "\n"; // build table array (or string) } } - return 0; } #+END_SRC @@ -1664,7 +1671,7 @@ auto table_block(char[] line, ref string[string] an_object, ref int[string] type #+name: abs_functions #+BEGIN_SRC d -auto block_flag_line_empty( +void block_flag_line_empty( char[] line, ref string[string] an_object, ref ObjComposite[] contents_the_objects, @@ -1702,8 +1709,10 @@ auto block_flag_line_empty( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1762,8 +1771,10 @@ auto block_flag_line_empty( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1794,8 +1805,10 @@ auto block_flag_line_empty( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1825,8 +1838,10 @@ auto block_flag_line_empty( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1857,8 +1872,10 @@ auto block_flag_line_empty( heading_pointer-1, an_object["is"] ); - an_object["substantive"] = - obj_im.obj_inline_markup(an_object["is"], an_object["obj"], dochead_make_aa); + auto substantive_object_and_anchor_tags_tuple = + obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; + anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], node); contents_the_objects ~= @@ -1874,7 +1891,6 @@ auto block_flag_line_empty( type["blocks"] = TriState.off; type["quote"] = TriState.off; } - return 0; } #+END_SRC @@ -2678,15 +2694,149 @@ struct ObjInlineMarkup { // struct ObjInlineMarkup : AssertObjInlineMarkup { auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; - string obj_inline_markup(string obj_is_, string obj_raw, string[string][string] dochead_make_aa) + auto obj_inline_markup_and_anchor_tags(string[string] obj_, string[string][string] dochead_make_aa) in { } body { - obj_txt["munge"]=obj_raw.dup; - obj_txt["munge"]=(match(obj_is_, ctRegex!(`verse|code`))) + obj_txt["munge"]=obj_["obj"].dup; + obj_txt["munge"]=(match(obj_["is"], ctRegex!(`verse|code`))) ? obj_txt["munge"] : strip(obj_txt["munge"]); - switch (obj_is_) { + static __gshared string[] anchor_tags_ = []; + switch (obj_["is"]) { case "heading": + static __gshared string anchor_tag = ""; + if (dochead_make_aa["make"]["num_top"].length > 0) { + if (!(match(obj_txt["munge"], rgx.heading_anchor_tag))) { + static __gshared uint heading_num_top_level=9; + static __gshared uint heading_num_depth=2; + static __gshared uint heading_num_0 = 0; + static __gshared uint heading_num_1 = 0; + static __gshared uint heading_num_2 = 0; + static __gshared uint heading_num_3 = 0; + static __gshared string heading_number_auto_composite = ""; + if (heading_num_top_level==9) { + if (dochead_make_aa["make"]["num_depth"].length > 0) { + heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]); + } + switch (dochead_make_aa["make"]["num_top"]) { + case "A": + break; + case "B": + heading_num_top_level=1; + break; + case "C": + heading_num_top_level=2; + break; + case "D": + heading_num_top_level=3; + break; + case "1": + heading_num_top_level=4; + break; + case "2": + heading_num_top_level=5; + break; + case "3": + heading_num_top_level=6; + break; + case "4": + heading_num_top_level=7; + break; + default: + break; + } + } + /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ + if (heading_num_top_level > to!uint(obj_["lev_markup_number"])) { + heading_num_0 = 0; + heading_num_1 = 0; + heading_num_2 = 0; + heading_num_3 = 0; + } else if (heading_num_top_level == to!uint(obj_["lev_markup_number"])) { + heading_num_0 ++; + heading_num_1 = 0; + heading_num_2 = 0; + heading_num_3 = 0; + } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 1)) { + heading_num_1 ++; + heading_num_2 = 0; + heading_num_3 = 0; + } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 2)) { + heading_num_2 ++; + heading_num_3 = 0; + } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 3)) { + heading_num_3 ++; + } else { + } + if (heading_num_3 > 0) { + heading_number_auto_composite = + (heading_num_depth == 3) + ? ( to!string(heading_num_0) ~ "." ~ + to!string(heading_num_1) ~ "." ~ + to!string(heading_num_2) ~ "." ~ + to!string(heading_num_3) + ) + : ""; + } else if (heading_num_2 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 2) + && (heading_num_depth <= 3)) + ? ( to!string(heading_num_0) ~ "." ~ + to!string(heading_num_1) ~ "." ~ + to!string(heading_num_2) + ) + : ""; + } else if (heading_num_1 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 1) + && (heading_num_depth <= 3)) + ? ( to!string(heading_num_0) ~ "." ~ + to!string(heading_num_1) + ) + : ""; + } else if (heading_num_0 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 0) + && (heading_num_depth <= 3)) + ? (to!string(heading_num_0)) + : ""; + } else { + heading_number_auto_composite = ""; + } + debug(heading_number_auto) { + writeln(heading_number_auto_composite); + } + if (!empty(heading_number_auto_composite)) { + obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, + "$1~$2 " ~ heading_number_auto_composite ~ ". "); + obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, + "$1~" ~ heading_number_auto_composite ~ " "); + } + } + } + // WORK ON, you still need to ensure that level 1 anchor_tags are unique + if (!(match(obj_txt["munge"], rgx.heading_anchor_tag))) { // if (anchor_tags_.length == 0) { + if (match(obj_txt["munge"], rgx.heading_identify_anchor_tag)) { + if (auto m = match(obj_txt["munge"], rgx.heading_extract_named_anchor_tag)) { + obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, + "$1~" ~ toLower(m.captures[1]) ~ "_" ~ m.captures[2] ~ " "); + } else if (auto m = match(obj_txt["munge"], rgx.heading_extract_unnamed_anchor_tag)) { + obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, + "$1~" ~ "s" ~ m.captures[1] ~ " "); + } + } else if (obj_["lev"] == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1" + static __gshared uint heading_num_lev1 = 0; + heading_num_lev1 ++; + obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, + "$1~" ~ "x" ~ to!string(heading_num_lev1) ~ " "); + } + } + if (auto m = match(obj_txt["munge"], rgx.heading_anchor_tag)) { + anchor_tag = m.captures[1]; + anchor_tags_ ~=anchor_tag; + } else if (obj_["lev"] == "1") { + writeln("heading anchor tag missing: ", obj_txt["munge"]); + } obj_txt["munge"]=munge.heading(obj_txt["munge"]); break; case "para": @@ -2719,7 +2869,12 @@ struct ObjInlineMarkup { default: break; } - return obj_txt["munge"]; + auto t = tuple( + obj_txt["munge"], + anchor_tags_, + ); + anchor_tags_=[]; + return t; } invariant() { } @@ -2994,6 +3149,8 @@ struct BookIndexReportSection { "Book Index", attrib, obj_cite_number, + [], + to!string(lev), to!int(lev_markup_number), to!int(lev_collapsed_number) ); @@ -3009,6 +3166,8 @@ struct BookIndexReportSection { "Index", attrib, obj_cite_number, + ["book_index"], + to!string(lev), to!int(lev_markup_number), to!int(lev_collapsed_number) ); @@ -3180,6 +3339,8 @@ struct NotesSection { "Endnotes", attrib, obj_cite_number, + [], + to!string(lev), to!int(lev_markup_number), to!int(lev_collapsed_number) ); @@ -3195,6 +3356,8 @@ struct NotesSection { "Endnotes", attrib, obj_cite_number, + ["endnotes"], + to!string(lev), to!int(lev_markup_number), to!int(lev_collapsed_number) ); @@ -3785,7 +3948,7 @@ set abstracted objects for downstream processing #+name: ao_structs #+BEGIN_SRC d struct HeadingAttrib { - int lev = 9; // use of enum should make this redundant, remove + string lev = "9"; int lev_markup_number = 9; int lev_collapsed_number = 9; } @@ -3813,6 +3976,7 @@ struct ObjComposite { string is_a = ""; string object = ""; string obj_cite_number = ""; // not used for calculations? output only? else int + string[] anchor_tags = []; HeadingAttrib heading_attrib; ParaAttrib para_attrib; BlockAttrib block_attrib; @@ -3824,7 +3988,6 @@ struct ObjCompositeArr { #+END_SRC ** object setter :set: - *** comment :comment: #+name: ao_object_setter @@ -3847,6 +4010,8 @@ auto contents_heading( in string object, in string attrib, in int obj_cite_number, + in string[] tags, + in string lev, in int lev_markup_number, in int lev_collapsed_number, ) { @@ -3856,6 +4021,8 @@ auto contents_heading( object_set.is_a = "heading"; object_set.object = object; object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + object_set.anchor_tags ~= tags; + object_set.heading_attrib.lev = lev; object_set.heading_attrib.lev_markup_number = lev_markup_number; object_set.heading_attrib.lev_collapsed_number = lev_collapsed_number; // object_set.node_structure.node = node; @@ -4007,6 +4174,8 @@ template SiSUdocAbstraction() { foreach (line; markup_sourcefile_content) { /+ ↓ markup document/text line by line +/ <> + <> + <> <> <> <> diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 3ea0a6f..b4ea917 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -94,6 +94,7 @@ template SiSUregisters() { "home_button_text" : "", "italics" : "", "num_top" : "", + "num_depth" : "", "substitute" : "", "texpdf_font" : "" ] @@ -219,7 +220,7 @@ template SiSUregisters() { "home_button_image", "home_button_text", "footer", "headings", - "num_top", + "num_top", "num_depth", "breaks", "substitute", "bold", @@ -597,7 +598,7 @@ static native_subhead_classify = ctRegex!(`^(?:topic_register|subject|k static native_subhead_identifier = ctRegex!(`^(?:oclc|pg|isbn)$`, "m"); static native_subhead_notes = ctRegex!(`^(?:abstract|description)$`, "m"); static native_subhead_publisher = ctRegex!(`^(?:name)$`, "m"); -static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_image|home_button_text|footer|headings|num_top|breaks|substitute|bold|italics|emphasis|texpdf_font|css)$`, "m"); +static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_image|home_button_text|footer|headings|num_top|num_depth|breaks|substitute|bold|italics|emphasis|texpdf_font|css)$`, "m"); #+END_SRC ** heading & paragraph operators :paragraph:operator: @@ -608,6 +609,11 @@ static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_ static heading_a = ctRegex!(`^:?[A][~] `, "m"); static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?) `); static heading_marker = ctRegex!(`^:?([A-D1-4])[~]`); +static heading_anchor_tag = ctRegex!(`^:?[A-D1-4][~]([a-z0-9_.-]+) `,"i"); +static heading_identify_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(?:(?:(?:chapter|article|section|clause)\s+[0-9.]+)|(?:[0-9.]+))`,"i"); // unless dob.obj =~/^:?[A-D1-4]~\s+(?:|(?:chapter|article|section|clause)\s+)([0-9.]+)/i +static heading_extract_named_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(chapter|article|section|clause)\s+([0-9.]+)`,"i"); +static heading_extract_unnamed_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+([0-9.]+)`); +static heading_marker_missing_tag = ctRegex!(`^:?([A-D1-4])[~] `); static heading_title = ctRegex!(`^:?[A-D1-4][~][a-z0-9_.-]*[?]?\s+(.+?)$`); static heading_all = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+(.+?)$`); // test, particularly [2] name/hashtag which may or may not be, does this affect title [3] static heading_biblio = ctRegex!(`^:?(1)[~][!](biblio(?:graphy)?|references?)`); @@ -761,7 +767,7 @@ static obj_cite_number_block_marks = ctRegex!(`^--[+~-]#$`); #+name: ao_rgx #+BEGIN_SRC d /+ ignore outside code blocks +/ -static skip_code_block_from_regular_parse = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); // not structural info +static skip_from_regular_parse = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); // not structural info #+END_SRC ** line & page breaks :break: diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org index 4b79a54..86728e1 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -62,8 +62,7 @@ debug(parent) { if (obj.use == "content") { if (obj.is_a == "heading") { writefln( - "%s%s node: %s heading: %s %s", - scr_txt_marker["cyan"], + "%s node: %s heading: %s %s", obj.obj_cite_number, obj.node, obj.lev_markup_number, @@ -319,6 +318,32 @@ debug(biblio) { #+END_SRC +** anchor tags + +#+name: ao_output_debugs +#+BEGIN_SRC d +debug(anchor) { + writefln( + "%s\n%s:%s", + "-------------------------------", + __FILE__, + __LINE__, + ); + foreach (obj; contents) { + if (obj.is_a == "heading") { + writefln( + "%s~ [%s] %s %s", + obj.heading_attrib.lev, + obj.obj_cite_number, + obj.anchor_tags, + // "[", obj["is"], "] ", + obj.object + ); + } + } +} +#+END_SRC + ** (headings) :headings: #+name: ao_output_debugs @@ -398,8 +423,7 @@ debug(headings) { foreach (obj; contents) { if (obj.is_a == "heading") { writefln( - "%s%s~ [%s] %s", - scr_txt_marker["yellow"], + "%s~ [%s] %s", obj.heading_attrib.lev, obj.obj_cite_number, // "[", obj["is"], "] ", diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index c1736cf..233599a 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -14,7 +14,6 @@ [[./sdp.org][sdp]] [[./][org/]] * get config file :config: - ** [#A] read config file, source string :string: *** config file (conf.sdl & sisu_document_make) :file:config: @@ -120,7 +119,6 @@ final private auto configSDLang(string conf_sdl) { #+END_SRC * get markup source, read file :source:markup: - ** [#A] read file, source string :string: #+name: ao_markup_source_raw @@ -191,9 +189,13 @@ catch (ErrnoException ex) { #+name: ao_markup_source_raw #+BEGIN_SRC d final private char[][] header0Content1(in string src_text) { - /+ split string on first match of "^:?A~\s" into [header, content] tuple +/ + /+ split string on _first_ match of "^:?A~\s" into [header, content] tuple +/ char[][] header_and_content = - split(cast(char[]) src_text, rgx.heading_a); + split(cast(char[]) src_text, rgx.heading_a); // this splits on each occurance of "^:?A~\s" (does not recognize when it appears in a code block) + assert(header_and_content.length == 2, + "document markup is broken, header body split == " ~ to!string(header_and_content.length) ~ + "; (header / body array split should == 2 (split is on level A~))" + ); return header_and_content; } #+END_SRC -- cgit v1.2.3