diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-02-10 08:24:05 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 096fb733867a947752a32b091f5ad92ec7c433cc (patch) | |
tree | e2fd946895a889880ef8e3ed5dd834635d047ccd /src | |
parent | output, sisupod & a few switches (diff) |
0.13.0 batch processing, reset values for each document (footnotes, bookindex, biblio etc.)
Diffstat (limited to 'src')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 127 |
1 files changed, 90 insertions, 37 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 119a718..a0dccbe 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -6,8 +6,8 @@ template SiSUdocAbstraction() { /+ ↓ abstraction imports +/ import - ao_object_setter, ao_defaults, + ao_object_setter, ao_rgx, output_hub; private import @@ -44,7 +44,6 @@ template SiSUdocAbstraction() { string anchor_tag_; string segment_anchor_tag_that_object_belongs_to; string segment_anchor_tag_that_object_belongs_to_uri; - auto note_section = NotesSection(); /+ enum +/ enum State { off, on } enum TriState { off, on, closing } @@ -69,8 +68,8 @@ template SiSUdocAbstraction() { int bib_entry; /+ counters +/ int cntr, previous_count, previous_length; + bool reset_note_numbers=true; int[string] line_occur; - string[] html_segnames=["toc"]; int html_segnames_ptr=0; int html_segnames_ptr_cntr=0; int verse_line, heading_ptr; @@ -224,13 +223,6 @@ template SiSUdocAbstraction() { /+ book index variables +/ string book_idx_tmp; string[][string][string] bookindex_unordered_hashes; - auto bookindex_extract_hash = BookIndexNuggetHash(); - string[][string][string] bkidx_hash( - string bookindex_section, - int obj_cite_number - ) { - return bookindex_extract_hash.bookindex_nugget_hash(bookindex_section, obj_cite_number); - } /+ node +/ ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; auto node_construct = NodeStructureMetadata(); @@ -261,6 +253,8 @@ template SiSUdocAbstraction() { destroy(an_object); destroy(processing); destroy(biblio_arr_json); + previous_length=0; + reset_note_numbers=true; } mixin SiSUrgxInitFlags; mixin SiSUnode; @@ -348,7 +342,10 @@ template SiSUdocAbstraction() { ]; auto mkup = InlineMarkup(); auto munge = ObjInlineMarkupMunge(); + auto note_section = NotesSection(); + auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string] lev4_subtoc; + string[] html_segnames=["toc"]; /+ abstraction init ↑ +/ /+ ↓ loop markup document/text line by line +/ srcDocLoop: @@ -696,6 +693,7 @@ template SiSUdocAbstraction() { } else if (type["blocks"] == TriState.closing) { /+ line empty, with blocks flag +/ _block_flag_line_empty_( + bookindex_extract_hash, line, an_object, the_document_body_section, @@ -726,7 +724,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "heading"; an_object_key="body_nugget"; auto substantive_object_and_anchor_tags_tuple = @@ -794,7 +792,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "para"; auto comp_obj_heading = node_construct.node_location_emitter( @@ -996,6 +994,7 @@ template SiSUdocAbstraction() { segment_anchor_tag_that_object_belongs_to, opt_action_bool, ); + destroy(bookindex_unordered_hashes); static assert(!isTypeTuple!(bi_tuple)); auto the_bookindex_section = bi_tuple[0]; obj_cite_number = bi_tuple[1]; @@ -1552,6 +1551,7 @@ template SiSUdocAbstraction() { document_section_keys_sequenced["seg"] ~= "tail"; document_section_keys_sequenced["scroll"] ~= "tail"; } + auto segnames = html_segnames.dup; destroy(the_document_head_section); destroy(the_table_of_contents_section); destroy(the_document_body_section); @@ -1560,10 +1560,23 @@ template SiSUdocAbstraction() { destroy(the_bibliography_section); destroy(the_bookindex_section); destroy(the_blurb_section); + destroy(html_segnames); + destroy(bookindex_unordered_hashes); + destroy(an_object); + biblio_arr_json = []; + obj_cite_number=0; + obj_cite_number_=0; + html_segnames_ptr=0; + html_segnames_ptr_cntr=0; + content_non_header = "8"; + dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; auto t = tuple( document_the, document_section_keys_sequenced, - html_segnames, + segnames, images, ); return t; @@ -2347,7 +2360,8 @@ template SiSUdocAbstraction() { } } } - void _block_flag_line_empty_( + void _block_flag_line_empty_(B)( + B bookindex_extract_hash, char[] line, ref string[string] an_object, ref ObjGenericComposite[] the_document_body_section, @@ -2375,7 +2389,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "code"; auto comp_obj_location = node_construct.node_location_emitter( @@ -2407,7 +2421,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "verse"; // check also auto comp_obj_location = node_construct.node_location_emitter( @@ -2436,7 +2450,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "table"; auto comp_obj_location = node_construct.node_location_emitter( @@ -2470,7 +2484,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "group"; auto comp_obj_location = node_construct.node_location_emitter( @@ -2503,7 +2517,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "block"; auto comp_obj_location = node_construct.node_location_emitter( @@ -2537,7 +2551,7 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "quote"; auto comp_obj_location = node_construct.node_location_emitter( @@ -3020,6 +3034,7 @@ template SiSUdocAbstraction() { string obj_txt_out, tail, note; auto rgx = Rgx(); auto mkup = InlineMarkup(); + int stage_reset_note_numbers = true; private auto initialize_note_numbers() { n_foot = 0; n_foot_reg = 0; @@ -3031,14 +3046,17 @@ template SiSUdocAbstraction() { static assert(is(typeof(obj_txt_in) == string)); } /+ url matched +/ - if (auto m = matchAll(obj_txt_in, rgx.inline_url)) { + if (match(obj_txt_in, rgx.inline_url)) { /+ link: naked url: http://url +/ if (match(obj_txt_in, rgx.inline_link_naked_url)) { obj_txt_in = replaceAll( obj_txt_in, rgx.inline_link_naked_url, - ("$1" ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "$3") // ("$1{ $2 }$2$3") + ("$1" + ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ "$3") // ("$1{ $2 }$2$3") ); } /+ link with helper for endnote including the url: @@ -3051,13 +3069,21 @@ template SiSUdocAbstraction() { replaceAll( obj_txt_in, rgx.inline_link_endnote_url_helper_punctuated, - (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") + (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") ); obj_txt_in = replaceAll( obj_txt_in, rgx.inline_link_endnote_url_helper, - (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ " }~") // ("{ $1 }$2~{ { $2 }$2 }~") + (mkup.lnk_o ~ " $1 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ " }~") // ("{ $1 }$2~{ { $2 }$2 }~") ); } /+ link with regular markup: @@ -3068,13 +3094,16 @@ template SiSUdocAbstraction() { replaceAll( obj_txt_in, rgx.inline_link_markup_regular, - ("$1" ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c ~ mkup.url_o ~ "$3" ~ mkup.url_c ~ "$4") // ("$1{ $2 }$3$4") + ("$1" + ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c + ~ mkup.url_o ~ "$3" ~ mkup.url_c + ~ "$4") // ("$1{ $2 }$3$4") ); } } return obj_txt_in; } - string footnotes_endnotes_markup_and_number_or_stars(Ot)(Ot obj_txt_in) { // here endnotes are marked up + string footnotes_endnotes_markup_and_number_or_stars(Ot)(Ot obj_txt_in, bool reset_note_numbers) { // here endnotes are marked up debug(asserts){ static assert(is(typeof(obj_txt_in) == string)); } @@ -3085,8 +3114,18 @@ template SiSUdocAbstraction() { rgx.inline_notes_curly, (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) ); + if (!(stage_reset_note_numbers) && reset_note_numbers) { + stage_reset_note_numbers = true; + } if (match(obj_txt_in, rgx.inline_notes_al_gen)) { if (auto m = matchAll(obj_txt_in, rgx.inline_text_and_note_al_)) { + if (stage_reset_note_numbers) { + n_foot = 0; + n_foot_reg = 0; + n_foot_sp_asterisk = 0; + n_foot_sp_plus = 0; + } + stage_reset_note_numbers = false; foreach(n; m) { if (match(to!string(n.hit), rgx.inline_al_delimiter_open_symbol_star)) { ++n_foot_sp_asterisk; @@ -3117,8 +3156,12 @@ template SiSUdocAbstraction() { } return obj_txt_out; } - private auto object_notes_(string obj_txt_in) - in { } + private auto object_notes_(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) + in { + debug(asserts){ + assert(is(typeof(obj_txt_in) == string)); + } + } body { obj_txt_out = ""; tail = ""; @@ -3135,10 +3178,10 @@ template SiSUdocAbstraction() { (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) ); /+ url matched +/ - if (auto m = matchAll(obj_txt_in, rgx.inline_url)) { + if (match(obj_txt_in, rgx.inline_url)) { obj_txt_in = url_links(obj_txt_in); } - obj_txt_out = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in); + obj_txt_out = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); debug(footnotes) { writeln(obj_txt_out, tail); } @@ -3171,7 +3214,7 @@ template SiSUdocAbstraction() { } return obj_txt["munge"]; } - string heading(Ot)(Ot obj_txt_in) + string heading(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) in { debug(asserts){ static assert(is(typeof(obj_txt_in) == string)); @@ -3182,7 +3225,7 @@ template SiSUdocAbstraction() { obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); obj_txt["munge"]=strip(obj_txt["munge"]); - obj_txt["munge"]=object_notes_(obj_txt["munge"]); + obj_txt["munge"]=object_notes_(obj_txt["munge"], reset_note_numbers); debug(munge) { writeln(__LINE__); writeln(obj_txt_in); @@ -3312,7 +3355,8 @@ template SiSUdocAbstraction() { } else if (obj_["lev"] == "1") { writeln("heading anchor tag missing: ", obj_txt["munge"]); } - obj_txt["munge"]=munge.heading(obj_txt["munge"]); + obj_txt["munge"]=munge.heading(obj_txt["munge"], reset_note_numbers); + reset_note_numbers=false; break; case "para": obj_txt["munge"]=munge.para(obj_txt["munge"]); @@ -3345,8 +3389,8 @@ template SiSUdocAbstraction() { break; } auto t = tuple( - obj_txt["munge"], - anchor_tags_, + obj_txt["munge"], + anchor_tags_, ); anchor_tags_=[]; return t; @@ -4186,7 +4230,10 @@ template SiSUdocAbstraction() { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" + ~ mkup.mark_internal_site_lnk ~ "../" + ~ segment_anchor_tag_that_object_belongs_to + ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4203,7 +4250,10 @@ template SiSUdocAbstraction() { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" + ~ mkup.mark_internal_site_lnk ~ "../" + ~ segment_anchor_tag_that_object_belongs_to + ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4418,6 +4468,8 @@ template SiSUdocAbstraction() { body { JSONValue[] biblio_unsorted = _biblio_unsorted_complete_(biblio_unsorted_incomplete, bib_arr_json); + biblio_arr_json = []; + biblio_unsorted_incomplete = []; JSONValue[] biblio_sorted__ = biblio_sort(biblio_unsorted); biblio_debug(biblio_sorted__); debug(biblio0) { @@ -4466,6 +4518,7 @@ template SiSUdocAbstraction() { } JSONValue[] biblio_unsorted_array_of_json_objects = bib_arr_json.dup; + destroy(bib_arr_json); return biblio_unsorted_array_of_json_objects; } final private JSONValue[] biblio_sort(BJ)(BJ biblio_unordered) { |