diff options
Diffstat (limited to 'org/ao_abstract_doc_source.org')
-rw-r--r-- | org/ao_abstract_doc_source.org | 849 |
1 files changed, 603 insertions, 246 deletions
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 7aa8a0a..0efc339 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -44,7 +44,10 @@ mixin InternalMarkup; #+BEGIN_SRC d /+ initialize +/ auto rgx = Rgx(); -ObjComposite[] contents_the_objects; +ObjComposite[] the_document_head_section; +ObjComposite[][string] the_table_of_contents_section; +ObjComposite[] the_document_body_section; +ObjComposite[] the_bibliography_section; string[string] an_object, processing; string[] anchor_tags; string segment_object_belongs_to; @@ -109,7 +112,10 @@ scope(success) { scope(failure) { } scope(exit) { - destroy(contents_the_objects); + destroy(the_document_head_section); + destroy(the_table_of_contents_section); + destroy(the_document_body_section); + destroy(the_bibliography_section); destroy(an_object); destroy(processing); destroy(biblio_arr_json); @@ -226,21 +232,13 @@ if (!line.empty) { #+name: abs_in_loop_body_00_code_block #+BEGIN_SRC d -if (type["code"] == TriState.on) { - /+ block object: code +/ - _code_block_(line, an_object, type); - continue; +/+ block object: code +/ +_code_block_(line, an_object, type); +continue; #+END_SRC **** non code objects (other blocks or regular text) [+4] :non_code: -#+name: abs_in_loop_body_00_non_code_block -#+BEGIN_SRC d -} 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 - ***** within block group [+1] :block:active: ****** within block group: biblio :biblio: @@ -312,15 +310,9 @@ if ((matchFirst(line, rgx.heading_biblio) ***** not identified as being within block group (could still be, or not) [+3] -#+name: abs_in_loop_body_non_code_obj -#+BEGIN_SRC d -} else { - /+ not within a block group +/ -#+END_SRC - ****** assert -#+name: abs_in_loop_body_open_block_obj +#+name: abs_in_loop_body_open_block_obj_assert #+BEGIN_SRC d assert( (type["blocks"] == TriState.off) @@ -334,170 +326,170 @@ assertions_flag_types_block_status_none_or_closed(type); #+name: abs_in_loop_body_open_block_obj #+BEGIN_SRC d -if (matchFirst(line, rgx.block_open)) { - if (matchFirst(line, (rgx.block_poem_open))) { - /+ poem to verse exceptions! +/ - object_reset(an_object); - processing.remove("verse"); - obj_cite_number_poem["start"] = to!string(obj_cite_number); - } - _start_block_(line, type, obj_cite_number_poem); - continue; +if (matchFirst(line, (rgx.block_poem_open))) { + /+ poem to verse exceptions! +/ + object_reset(an_object); + processing.remove("verse"); + obj_cite_number_poem["start"] = to!string(obj_cite_number); +} +_start_block_(line, type, obj_cite_number_poem); +continue; #+END_SRC ****** line not empty [+2] - -#+name: abs_in_loop_body_not_block_obj -#+BEGIN_SRC d -} else if (!line.empty) { - /+ line not empty +/ - /+ non blocks (headings, paragraphs) & closed blocks +/ -#+END_SRC - ******* asserts :assert: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d +assert( + !line.empty, + "line tested, line not empty surely" +); +assert( + (type["blocks"] == TriState.off) + || (type["blocks"] == TriState.closing), + "code block status: none or closed" +); +if (type["blocks"] == TriState.closing) { + // blocks closed, unless followed by book index + debug(check) { // block + writeln(__LINE__); + writeln(line); + } assert( - !line.empty, - "line tested, line not empty surely" - ); - assert( - (type["blocks"] == TriState.off) - || (type["blocks"] == TriState.closing), - "code block status: none or closed" + matchFirst(line, rgx.book_index) + || matchFirst(line, rgx.book_index_open) + || type["book_index"] == State.on ); - if (type["blocks"] == TriState.closing) { - // blocks closed, unless followed by book index - debug(check) { // block - writeln(__LINE__); - writeln(line); - } - assert( - matchFirst(line, rgx.book_index) - || matchFirst(line, rgx.book_index_open) - || type["book_index"] == State.on - ); - } +} #+END_SRC ******* book index :bookindex: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - if ((matchFirst(line, rgx.book_index)) - || (matchFirst(line, rgx.book_index_open)) - || (type["book_index"] == State.on )) { - /+ book_index +/ - _book_index_(line, book_idx_tmp, an_object, type); +if ((matchFirst(line, rgx.book_index)) +|| (matchFirst(line, rgx.book_index_open)) +|| (type["book_index"] == State.on )) { + /+ book_index +/ + _book_index_(line, book_idx_tmp, an_object, type); #+END_SRC ******* not book index [+1] #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - } else { - /+ not book_index +/ +} else { + /+ not book_index +/ #+END_SRC ******** matched: comment :comment:match: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - if (auto m = matchFirst(line, rgx.comment)) { - /+ matched comment +/ - debug(comment) { - writeln(line); - } - an_object["obj"] ~= line ~= "\n"; - contents_the_objects ~= - set_abstract_object.contents_comment(strip(an_object["obj"])); - _header_set_common_(line_occur, an_object, type); - processing.remove("verse"); - ++counter; + if (auto m = matchFirst(line, rgx.comment)) { + /+ matched comment +/ + debug(comment) { + writeln(line); + } + an_object["obj"] ~= line ~= "\n"; + the_document_body_section ~= + set_abstract_object.contents_comment(strip(an_object["obj"])); + _common_reset_(line_occur, an_object, type); + processing.remove("verse"); + ++counter; #+END_SRC ******** flag not set & line not exist: heading or para :heading:paragraph: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - } else if (((line_occur["para"] == State.off) + } else if (((line_occur["para"] == State.off) + && (line_occur["heading"] == State.off)) + && ((type["para"] == State.off) + && (type["heading"] == State.off))) { + /+ heading or para but neither flag nor line exists +/ + if ((dochead_make_aa["make"]["headings"].length > 2) + && (type["make_headings"] == State.off)) { + /+ heading found +/ + _heading_found_(line, dochead_make_aa["make"]["headings"], heading_match_str, heading_match_rgx, type); + } + if ((type["make_headings"] == State.on) + && ((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((type["para"] == State.off) && (type["heading"] == State.off))) { - /+ heading or para but neither flag nor line exists +/ - if ((dochead_make_aa["make"]["headings"].length > 2) - && (type["make_headings"] == State.off)) { - /+ heading found +/ - _heading_found_(line, dochead_make_aa["make"]["headings"], heading_match_str, heading_match_rgx, type); - } - if ((type["make_headings"] == State.on) - && ((line_occur["para"] == State.off) - && (line_occur["heading"] == State.off)) - && ((type["para"] == State.off) - && (type["heading"] == State.off))) { - /+ heading make set +/ - _heading_make_set_(line, line_occur, heading_match_rgx, type); - } - if (matchFirst(line, rgx.heading)) { - /+ heading match +/ - _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); - } + /+ heading make set +/ + _heading_make_set_(line, line_occur, heading_match_rgx, type); + } + /+ TODO node info: all headings identified at this point, + - extract node info here?? + - how long can it wait? + - should be incorporated in composite objects + - should happen before endnote links set (they need to be moved down?) + // node_construct.node_emitter_heading segment anchor tag + +/ + if (matchFirst(line, rgx.heading)) { + /+ heading match +/ + _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); + } #+END_SRC ******** line exist: heading :heading: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - } else if (line_occur["heading"] > State.off) { - /+ heading +/ - debug(heading) { // heading - writeln(line); - } - an_object["obj"] ~= line ~= "\n"; - ++line_occur["heading"]; + } else if (line_occur["heading"] > State.off) { + /+ heading +/ + debug(heading) { // heading + writeln(line); + } + an_object["obj"] ~= line ~= "\n"; + ++line_occur["heading"]; #+END_SRC ******** line exist: para :para: #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d - } else if (line_occur["para"] > State.off) { - /+ paragraph +/ - debug(para) { - writeln(line); - } - an_object["obj"] ~= line; - ++line_occur["para"]; + } else if (line_occur["para"] > State.off) { + /+ paragraph +/ + debug(para) { + writeln(line); } + an_object["obj"] ~= line; + ++line_occur["para"]; } +} #+END_SRC ****** line empty, with block flag -#+name: abs_in_loop_body_not_block_obj +#+name: abs_in_loop_body_not_block_obj_line_empty_blocks_flags #+BEGIN_SRC d -} else if (type["blocks"] == TriState.closing) { - /+ line empty, with blocks flag +/ - _block_flag_line_empty_(line, an_object, contents_the_objects, bookindex_unordered_hashes, obj_cite_number, _node, counter, type, obj_cite_number_poem, dochead_make_aa); // watch +_block_flag_line_empty_( + line, + an_object, + the_document_body_section, + bookindex_unordered_hashes, + obj_cite_number, + _node, + counter, + type, + obj_cite_number_poem, + dochead_make_aa +); // watch #+END_SRC ****** line empty [+1] -#+name: abs_in_loop_body_not_block_obj -#+BEGIN_SRC d -} else { - /+ line empty +/ -#+END_SRC - ******* assert line empty :assert: #+name: abs_in_loop_body_not_block_obj_line_empty #+BEGIN_SRC d -/+ line.empty, post contents, empty variables: +/ assert( line.empty, "line should be empty" @@ -530,6 +522,13 @@ if ((type["heading"] == State.on) } else if (to!int(an_object["lev_markup_number"]) < 4) { segment_object_belongs_to = ""; } + the_table_of_contents_section = obj_im.table_of_contents_gather_headings( + an_object, + dochead_make_aa, + segment_object_belongs_to, + obj_cite_number, + the_table_of_contents_section, + ); _node = node_construct.node_emitter_heading( an_object["lev_markup_number"], @@ -547,7 +546,7 @@ if ((type["heading"] == State.on) writeln(an_object["lev_markup_number"]); writeln(segment_object_belongs_to); } - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_heading( an_object["substantive"], an_object["attrib"], @@ -564,7 +563,7 @@ if ((type["heading"] == State.on) // writeln(contents_am[counter]["obj_cite_number"], " ", contents_am[counter]["obj"]); // writeln(m.hit, "\n"); } - _header_set_common_(line_occur, an_object, type); + _common_reset_(line_occur, an_object, type); an_object.remove("lev"); an_object.remove("lev_markup_number"); // an_object["lev_markup_number"]="9"; @@ -599,7 +598,7 @@ if ((type["heading"] == State.on) 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 ~= + the_document_body_section ~= set_abstract_object.contents_para( an_object["is"], an_object["substantive"], @@ -608,16 +607,11 @@ if ((type["heading"] == State.on) indent, bullet ); - // contents_the_objects ~= - // set_abstract_object.contents_para( - // an_object, - // obj_cite_number, - // indent, - // bullet - // ); - _header_set_common_(line_occur, an_object, type); - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + _common_reset_(line_occur, an_object, type); + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = false; processing.remove("verse"); ++counter; @@ -632,29 +626,22 @@ if ((type["heading"] == State.on) *** close non code objects (regular text) -#+name: abs_in_loop_body_00_closed -#+BEGIN_SRC d - } // close else for line empty - } // close else for not the above -} // close after non code, other blocks or regular text -#+END_SRC - *** regular text objects :text:paragraph: #+name: abs_in_loop_body_01 #+BEGIN_SRC d -/+ unless (contents_the_objects.length == 0) ? +/ -if (contents_the_objects.length > 0) { - if (((contents_the_objects[$-1].is_a == "para") - || (contents_the_objects[$-1].is_a == "heading")) +/+ unless (the_document_body_section.length == 0) ? +/ +if (the_document_body_section.length > 0) { + if (((the_document_body_section[$-1].is_a == "para") + || (the_document_body_section[$-1].is_a == "heading")) && (counter-1 > previous_count)) { - if (match(contents_the_objects[$-1].object, + if (match(the_document_body_section[$-1].object, rgx.inline_notes_delimiter_al_regular_number_note)) { - previous_count=contents_the_objects.length -1; + previous_count=the_document_body_section.length -1; note_section.gather_notes_for_endnote_section( - contents_the_objects, + the_document_body_section, segment_object_belongs_to, - contents_the_objects.length -1 + the_document_body_section.length -1 ); } } @@ -680,28 +667,71 @@ debug(objectrelated2) { // check // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", "", dochead_make_aa); #+END_SRC -*** [#B] endnotes :endnotes: +*** document sections +**** DONE [#B] toc, table of contents section (scroll & seg) :contents: + +#+name: abs_post +#+BEGIN_SRC d +debug(toc) { + writefln( + "%s %s", + __LINE__, + the_table_of_contents_section["seg"].length + ); + foreach (toc_linked_heading; the_table_of_contents_section["seg"]) { + writeln(toc_linked_heading.object); + } +} +#+END_SRC + +**** DONE endnotes section (scroll & seg) :endnotes: #+name: abs_post #+BEGIN_SRC d auto en_tuple = note_section.endnote_objects(obj_cite_number); static assert(!isTypeTuple!(en_tuple)); -auto endnotes_section = en_tuple[0]; +auto the_endnotes_section = en_tuple[0]; obj_cite_number = en_tuple[1]; debug(endnotes) { writefln( "%s %s", __LINE__, - endnotes_section.length + the_endnotes_section["seg"].length ); - foreach (n; endnotes_section) { - writeln(n); + foreach (o; the_endnotes_section["seg"]) { + writeln(o); } } #+END_SRC -*** [#B] bibliography :bibliography: +**** glossary section? + +**** TODO [#B] bibliography section (objects) :bibliography: + +#+name: abs_post +#+BEGIN_SRC d +the_bibliography_section ~= + set_abstract_object.contents_heading( + "Bibliography", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); +the_bibliography_section ~= + set_abstract_object.contents_heading( + "Bibliography", // nugget/object + "", // attrib + 0, // obj_cite_number + ["bibliography"], // anchor tag + "1", // lev + 4, // lev_markup_number + 2, // lev_collapsed_number + ); +#+END_SRC #+name: abs_post #+BEGIN_SRC d @@ -712,51 +742,126 @@ auto biblio_ordered = biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json); #+END_SRC -*** [#B] bookindex :book:index: +***** format biblio string + +#+name: abs_post +#+BEGIN_SRC d +string out_; +foreach (entry; biblio_ordered) { + out_ = format( + "%s \"%s\"%s%s%s%s%s%s%s%s%s.", + ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str), + entry["fulltitle"].str, + ((entry["journal"].str.empty) ? "" : ", /{" ~ entry["journal"].str ~ "}/"), + ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str), + ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str), + ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""), + ", " ~ entry["year"].str, + ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str), + ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str), + ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str), + ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"), + ); + the_bibliography_section ~= + set_abstract_object.contents_para( + "bibliography", + out_, // nugget/object + "", // attrib + 0, // obj_cite_number + ([ "hang_position" : "0", "base_position" : "1", ]), // indent + false + ); +} +#+END_SRC + +#+name: abs_post +#+BEGIN_SRC d +debug(bibliosection) { + foreach (o; the_bibliography_section) { + writeln(o.object); + } +} +#+END_SRC + +***** bibliography components + +auto biblio_entry_tags_jsonstr = `{ + "is" : "", + "sortby_deemed_author_year_title" : "", + "deemed_author" : "", + "author_raw" : "", + "author" : "", + "author_arr" : [ "" ], + "editor_raw" : "", + "editor" : "", + "editor_arr" : [ "" ], + "title" : "", + "subtitle" : "", + "fulltitle" : "", + "language" : "", + "trans" : "", + "src" : "", + "journal" : "", + "in" : "", + "volume" : "", + "edition" : "", + "year" : "", + "place" : "", + "publisher" : "", + "url" : "", + "pages" : "", + "note" : "", + "short_name" : "", + "id" : "" +}`; // is: book, article, magazine, newspaper, blog, other + +**** DONE [#B] bookindex section (scroll & seg) :book:index: #+name: abs_post #+BEGIN_SRC d auto bi = BookIndexReportSection(); auto bi_tuple = - bi.bookindex_build_section(bookindex_unordered_hashes, obj_cite_number, segment_object_belongs_to); + bi.bookindex_build_section( + bookindex_unordered_hashes, + obj_cite_number, + segment_object_belongs_to + ); static assert(!isTypeTuple!(bi_tuple)); -auto bookindex_section = bi_tuple[0]; +auto the_bookindex_section = bi_tuple[0]; obj_cite_number = bi_tuple[1]; debug(bookindex) { // bookindex - foreach (bi_entry; bookindex_section) { + foreach (bi_entry; the_bookindex_section["seg"]) { writeln(bi_entry); } } #+END_SRC -*** [#B] document :document: +*** [#B] the document :document: #+name: abs_post #+BEGIN_SRC d -auto document_the = - contents_the_objects ~ endnotes_section ~ bookindex_section; +the_document_head_section ~= the_document_body_section[0]; +the_document_body_section=the_document_body_section[1..$]; +auto document_the = [ + "head": the_document_head_section, + "toc_seg": the_table_of_contents_section["seg"], + "toc_scroll": the_table_of_contents_section["scroll"], + "body": the_document_body_section, + "endnotes_seg": the_endnotes_section["seg"], + "endnotes_scroll": the_endnotes_section["scroll"], + // "glossary": the_glossary_section, // TODO + "bibliography": the_bibliography_section, + "bookindex_scroll": the_bookindex_section["scroll"], + "bookindex_seg": the_bookindex_section["seg"], +]; #+END_SRC *** misc heading #+name: abs_post -destroy(contents_the_objects); -destroy(endnotes_section); -destroy(bookindex_section); -// struct Document { -// char content; -// char head_make; -// char head_meta; -// char bookindex_section; -// char biblio; -// } -// struct Document { -// char content; -// char head_make; -// char head_meta; -// char bookindex_section; -// char biblio; -// } +destroy(the_document_body_section); +destroy(the_endnotes_section); +destroy(the_bookindex_section); #+END_SRC *** [#A] return document tuple :return:tuple: @@ -793,12 +898,11 @@ auto object_reset(ref string[string] an_object) { #+name: abs_functions_header_set_common #+BEGIN_SRC d -auto _header_set_common_( +auto _common_reset_( ref int[string] line_occur, ref string[string] an_object, ref int[string] type ) { - // line_occur["header"] = State.off; line_occur["heading"] = State.off; line_occur["para"]= State.off; type["heading"] = State.off; @@ -1331,7 +1435,7 @@ void _poem_block_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1353,7 +1457,7 @@ void _poem_block_( obj_cite_number = obj_cite_number_emit(type["obj_cite_number_status"]); type["verse_new"] = State.off; - } else if (matchFirst(line, rgx.line_delimiter_only)) { + } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) { verse_line = TriState.off; type["verse_new"] = State.on; } @@ -1383,7 +1487,7 @@ void _poem_block_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1420,7 +1524,7 @@ void _poem_block_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1441,7 +1545,7 @@ void _poem_block_( obj_cite_number = obj_cite_number_emit(type["obj_cite_number_status"]); type["verse_new"] = State.off; - } else if (matchFirst(line, rgx.line_delimiter_only)) { + } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) { type["verse_new"] = State.on; verse_line = TriState.off; } @@ -1472,7 +1576,7 @@ void _poem_block_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1659,7 +1763,7 @@ void _table_block_( void _block_flag_line_empty_( char[] line, ref string[string] an_object, - ref ObjComposite[] contents_the_objects, + ref ObjComposite[] the_document_body_section, ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, ref string _node, @@ -1701,7 +1805,7 @@ void _block_flag_line_empty_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block_code( an_object["is"], an_object["substantive"], @@ -1730,7 +1834,7 @@ void _block_flag_line_empty_( an_object["is"] // "verse" ); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block_obj_cite_number_string( "poem", "", @@ -1765,7 +1869,7 @@ void _block_flag_line_empty_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1800,7 +1904,7 @@ void _block_flag_line_empty_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1834,7 +1938,7 @@ void _block_flag_line_empty_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1869,7 +1973,7 @@ void _block_flag_line_empty_( 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 ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -2114,8 +2218,10 @@ auto _heading_matched_( 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, dochead_meta_aa["title"]["main"]); - an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); + an_object["obj"]=replaceFirst(an_object["obj"], + rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ",")); + an_object["obj"]=replaceFirst(an_object["obj"], + rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); collapsed_lev["h0"] = 1; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); @@ -2265,8 +2371,10 @@ auto _para_match_( } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = true; } else if (auto m = matchFirst(line, rgx.para_indent_hang)) { debug(paraindenthang) { // para indent hang @@ -2274,8 +2382,10 @@ auto _para_match_( } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = to!string(m.captures[1]); - indent["base_position"] = to!string(m.captures[2]); + indent=[ + "hang_position" : to!string(m.captures[1]), + "base_position" : to!string(m.captures[2]), + ]; bullet = false; } else if (auto m = matchFirst(line, rgx.para_bullet_indent)) { debug(parabulletindent) { // para bullet indent @@ -2283,15 +2393,19 @@ auto _para_match_( } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = to!string(m.captures[1]); - indent["base_position"] = "0"; + indent=[ + "hang_position" : to!string(m.captures[1]), + "base_position" : "0", + ]; bullet = true; } else { // !line.empty type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = false; } ++line_occur["para"]; @@ -2423,6 +2537,7 @@ struct ObjInlineMarkupMunge { obj_txt["munge"]=obj_txt_in; 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"]); debug(munge) { writeln(__LINE__); @@ -2527,7 +2642,10 @@ struct ObjInlineMarkup { #+name: ao_emitters_obj_inline_markup_and_anchor_tags #+BEGIN_SRC d - auto obj_inline_markup_and_anchor_tags(string[string] obj_, 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_["obj"].dup; @@ -2590,6 +2708,156 @@ struct ObjInlineMarkup { } #+END_SRC +***** table of contents objects :markup:inline: + +#+name: ao_emitters_obj_inline_markup_table_of_contents +#+BEGIN_SRC d + auto _clean_heading_toc_( + char[] heading_toc_, + ) { + auto m = matchFirst(cast(char[]) heading_toc_, rgx.heading); + heading_toc_ = m.post; + return heading_toc_; + }; + auto table_of_contents_gather_headings( + string[string] obj_, + string[string][string] dochead_make_aa, + string segment_object_belongs_to, + int obj_cite_number, + ObjComposite[][string] the_table_of_contents_section, + ) + in { } + body { + char[] heading_toc_ = to!(char[])(obj_["obj"].dup.strip); + heading_toc_ = _clean_heading_toc_(heading_toc_); + auto attrib=""; + string toc_txt_; + string[string] indent; + auto set_abstract_object = ObjectAbstractSet(); + if (to!int(obj_["lev_markup_number"]) > 0) { + toc_txt_ = format( + "{ %s }#%s", + heading_toc_, + obj_cite_number, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + toc_txt_ = format( + "{ %s }#%s", + heading_toc_, + obj_cite_number, + ); + the_table_of_contents_section["scroll"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + } else { + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + the_table_of_contents_section["scroll"] ~= + set_abstract_object.contents_para( + "toc", + "Table of Contents", + "", // attrib + 0, + indent, + false + ); + } + switch (to!int(obj_["lev_markup_number"])) { + case 0: + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + "{ Table of Contents }../toc.fn_suffix", + "", // attrib + 0, + indent, + false + ); + break; + case 1: .. case 3: + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + toc_txt_ = format( + "%s", + heading_toc_, + ); + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + case 4: + toc_txt_ = format( + "{ %s }../%s.fn_suffix", + heading_toc_, + segment_object_belongs_to, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + case 5: .. case 7: + toc_txt_ = format( + "{ %s }../%s.fn_suffix#%s", + heading_toc_, + segment_object_belongs_to, + obj_cite_number, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + default: + break; + } + return the_table_of_contents_section; + } + invariant() { + } +#+END_SRC + ***** private: #+name: ao_emitters_obj_inline_markup_private @@ -3271,15 +3539,25 @@ struct BookIndexReportSection { auto set_abstract_object = ObjectAbstractSet(); auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; - string bi_tmp; - ObjComposite[] bookindex_section; + string bi_tmp_seg, bi_tmp_scroll; + ObjComposite[][string] bookindex_section; // writeln(mainkeys.length); // B~ Book Index attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; - bookindex_section ~= + bookindex_section["scroll"] ~= + set_abstract_object.contents_heading( + "Book Index", + attrib, + obj_cite_number, + [], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + bookindex_section["seg"] ~= set_abstract_object.contents_heading( "Book Index", attrib, @@ -3296,7 +3574,17 @@ struct BookIndexReportSection { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; - bookindex_section ~= + bookindex_section["scroll"] ~= + set_abstract_object.contents_heading( + "Index", + attrib, + obj_cite_number, + ["book_index"], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + bookindex_section["seg"] ~= set_abstract_object.contents_heading( "Index", attrib, @@ -3309,35 +3597,43 @@ struct BookIndexReportSection { ++obj_cite_number; ++mkn; foreach (mainkey; mainkeys) { - bi_tmp = "!{" ~ mainkey ~ "}! "; + bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; + bi_tmp_seg = "!{" ~ mainkey ~ "}! "; // bi_tmp = "_0_1 !{" ~ mainkey ~ "}! "; foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= (segment_object_belongs_to.empty) + bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_seg ~= (segment_object_belongs_to.empty) ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#" ~ go ~ ", "); + : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } - bi_tmp ~= " \\\\\n "; + bi_tmp_scroll ~= " \\\\\n "; + bi_tmp_seg ~= " \\\\\n "; bookindex_unordered_hashes[mainkey].remove("_a"); auto subkeys = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { - bi_tmp ~= subkey ~ ", "; + bi_tmp_scroll ~= subkey ~ ", "; + bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= (segment_object_belongs_to.empty) + bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_seg ~= (segment_object_belongs_to.empty) ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#" ~ go ~ ", "); + : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } - bi_tmp ~= " \\\\\n "; + bi_tmp_scroll ~= " \\\\\n "; + bi_tmp_seg ~= " \\\\\n "; ++skn; } - bi_tmp = replaceFirst(bi_tmp, rgx.trailing_linebreak, ""); + bi_tmp_scroll = replaceFirst(bi_tmp_scroll, rgx.trailing_linebreak, ""); + bi_tmp_seg = replaceFirst(bi_tmp_seg, rgx.trailing_linebreak, ""); type="para"; attrib=""; - indent["hang_position"] = "0"; - indent["base_position"] = "1"; - attrib=""; + indent=[ + "hang_position" : "0", + "base_position" : "1", + ]; // bookindex_section ~= // set_abstract_object.contents_para( // obj, @@ -3345,10 +3641,19 @@ struct BookIndexReportSection { // indent, // false // ); - bookindex_section ~= + bookindex_section["scroll"] ~= set_abstract_object.contents_para( type, - bi_tmp, + bi_tmp_scroll, + attrib, + obj_cite_number, + indent, + false + ); + bookindex_section["seg"] ~= + set_abstract_object.contents_para( + type, + bi_tmp_seg, attrib, obj_cite_number, indent, @@ -3374,7 +3679,7 @@ struct BookIndexReportSection { #+name: ao_emitters_endnotes #+BEGIN_SRC d struct NotesSection { - string object_notes; + string[string] object_notes; long previous_count; int mkn; auto rgx = Rgx(); @@ -3408,15 +3713,22 @@ struct NotesSection { rgx.inline_notes_delimiter_al_regular_number_note)) { debug(endnotes_build) { writeln( - "{^{", m.captures[1], ".}^}[../", segment_object_belongs_to, ".fn_suffix]#noteref_\n ", m.captures[1], " ", + "{^{", m.captures[1], ".}^}../", segment_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) // writeln("{^{", m.captures[1], ".}^}#", contents_am[counter]["obj_cite_number"], " ", m.captures[2]); } - object_notes ~= (segment_object_belongs_to.empty) + // TODO NEXT you need anchor for segments at this point -> + object_notes["seg"] ~= + "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1] ~ " " ~ m.captures[2] ~ "』"; + object_notes["seg"] ~= (segment_object_belongs_to.empty) ? ("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ m.captures[1] ~ " " ~ m.captures[2] ~ "』") - : ("{^{" ~ m.captures[1] ~ ".}^}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#noteref_" ~ + : ("{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~ m.captures[1] ~ " " ~ m.captures[2] ~ "』"); + object_notes["scroll"] ~= + "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1] ~ " " ~ m.captures[2] ~ "』"; } return object_notes; } @@ -3430,9 +3742,13 @@ struct NotesSection { in { } body { - string[] endnotes_; + string[][string] endnotes_; if (object_notes.length > 1) { - endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; + endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1]; + endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1]; + } else { + endnotes_["seg"] = []; + endnotes_["scroll"] = []; } return endnotes_; } @@ -3447,7 +3763,7 @@ struct NotesSection { } body { auto set_abstract_object = ObjectAbstractSet(); - ObjComposite[] endnotes_section; + ObjComposite[][string] the_endnotes_section; auto endnotes_ = gathered_notes(); // auto endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; string type; @@ -3459,7 +3775,17 @@ struct NotesSection { lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; - endnotes_section ~= + the_endnotes_section["seg"] ~= + set_abstract_object.contents_heading( + "Endnotes", + attrib, + obj_cite_number, + [], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( "Endnotes", attrib, @@ -3476,7 +3802,17 @@ struct NotesSection { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; - endnotes_section ~= + the_endnotes_section["seg"] ~= + set_abstract_object.contents_heading( + "Endnotes", + attrib, + obj_cite_number, + ["endnotes"], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( "Endnotes", attrib, @@ -3488,7 +3824,7 @@ struct NotesSection { ); ++obj_cite_number; ++mkn; - foreach (endnote; endnotes_) { + foreach (endnote; endnotes_["seg"]) { attrib=""; // endnotes ~= // set_abstract_object.contents_para( @@ -3497,13 +3833,15 @@ struct NotesSection { // indent, // false // ); - endnotes_section ~= - set_abstract_object.contents_endnote( - endnote, - ); - ++mkn; + the_endnotes_section["seg"] ~= + set_abstract_object.contents_endnote(endnote); + } + foreach (endnote; endnotes_["scroll"]) { + attrib=""; + the_endnotes_section["scroll"] ~= + set_abstract_object.contents_endnote(endnote); } - auto t = tuple(endnotes_section, obj_cite_number); + auto t = tuple(the_endnotes_section, obj_cite_number); return t; } #+END_SRC @@ -4264,8 +4602,8 @@ auto contents_para( object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); object_set.para_attrib.indent_start = 0; // indent["hang_position"]; object_set.para_attrib.indent_rest = 0; // indent["base_position"]; - object_set.para_attrib.bullet = false; - // object_set.node_structure.node = _node; + object_set.para_attrib.bullet = false; // bullet; + // object_set.node_structure.node = _node; return object_set; } #+END_SRC @@ -4389,13 +4727,31 @@ template SiSUdocAbstraction() { foreach (line; markup_sourcefile_content) { /+ ↓ markup document/text line by line +/ <<abs_in_loop_body_00>> - <<abs_in_loop_body_00_code_block>> - <<abs_in_loop_body_00_non_code_block>> + if (type["code"] == TriState.on) { + <<abs_in_loop_body_00_code_block>> + } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { + /+ object other than "code block" object + (includes regular text paragraph, headings & blocks other than code) +/ <<abs_in_loop_body_non_code_obj>> - <<abs_in_loop_body_open_block_obj>> - <<abs_in_loop_body_not_block_obj>> + } else { + /+ not within a block group +/ + <<abs_in_loop_body_open_block_obj_assert>> + if (matchFirst(line, rgx.block_open)) { + <<abs_in_loop_body_open_block_obj>> + } else if (!line.empty) { + /+ line not empty +/ + /+ non blocks (headings, paragraphs) & closed blocks +/ + <<abs_in_loop_body_not_block_obj>> + } else if (type["blocks"] == TriState.closing) { + /+ line empty, with blocks flag +/ + <<abs_in_loop_body_not_block_obj_line_empty_blocks_flags>> + } else { + /+ line empty +/ + /+ line.empty, post contents, empty variables: +/ <<abs_in_loop_body_not_block_obj_line_empty>> - <<abs_in_loop_body_00_closed>> + } // close else for line empty + } // close else for not the above + } // close after non code, other blocks or regular text <<abs_in_loop_body_01>> } /+ ← closed: loop markup document/text line by line +/ /+ ↓ post loop markup document/text +/ @@ -4424,6 +4780,7 @@ template SiSUdocAbstraction() { <<ao_emitters_obj_inline_markup_munge>> <<ao_emitters_obj_inline_markup>> <<ao_emitters_obj_inline_markup_and_anchor_tags>> + <<ao_emitters_obj_inline_markup_table_of_contents>> <<ao_emitters_obj_inline_markup_private>> <<ao_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags>> <<ao_emitters_obj_inline_markup_close>> |