From 245b9a3ba9917ee148726aa41a7c3397caf97895 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 15 Nov 2023 22:31:08 -0500 Subject: ocda, arrange structs, continue --- flake.lock | 6 +- org/ocda.org | 269 +++++++++++------------ src/doc_reform/meta/metadoc_from_src.d | 377 +++++++++++++++++---------------- 3 files changed, 319 insertions(+), 333 deletions(-) diff --git a/flake.lock b/flake.lock index 84bc414..2d0b3d2 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1700014976, - "narHash": "sha256-dSGpS2YeJrXW5aH9y7Abd235gGufY3RuZFth6vuyVtU=", + "lastModified": 1700108881, + "narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "592047fc9e4f7b74a4dc85d1b9f5243dfe4899e3", + "rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1", "type": "github" }, "original": { diff --git a/org/ocda.org b/org/ocda.org index 44a184a..b484299 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -429,6 +429,88 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return tag_assoc; } +struct retStruct_txt_by_line_common_reset { + int[string] line_occur; + string[string] this_object; + uint[string] pith; +} +struct retStruct_txt_by_line_block_start { + uint[string] pith; + uint[string] dochas; + string[string] object_number_poem; +} +struct retStruct_txt_by_line_block_generic { + uint[string] pith; + string[string] this_object; +} +struct retStruct_txt_by_line_block_poem { + int cntr; + uint[string] pith; + string[string] this_object; +} +struct retStruct_txt_by_line_block_biblio { + uint[string] pith; + int bib_entry; + string biblio_entry_str_json; + string[] biblio_arr_json; +} +struct retStruct_flow_book_index { + string[string] this_object; + uint[string] pith; + string book_idx_tmp; +} +struct retStruct_flow_heading_found { + string[string] heading_match_str; + Regex!(char)[string] heading_match_rgx; + uint[string] pith; +} +struct retStruct_flow_heading_make_set { + char[] line; + uint[string] pith; + string[string] this_object; +} +struct retStruct_flow_para_match { + uint[string] pith; + string[string] this_object; + string this_object_key; + int[string] indent; + bool bullet; + int[string] line_occur; +} +struct retStruct_flow_table_array_munge { + ObjGenericComposite table_object; + string[][] table_array; +} +struct retStruct_flow_table_of_contents_gather_headings { + ObjGenericComposite[] the_document_toc_section; + string[][string] lev4_subtoc; +} +struct retStruct_flow_bibliography { + JSONValue[] biblio_sorted; + JSONValue[] bib_arr_json; + string[] biblio_unsorted_incomplete; +} +struct retStruct_flow_table_closed_make_special_notation_table { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + OCNset obj_cite_digits; + ObjGenericComposite _comp_obj_heading; + int cntr; + uint[string] pith; +} +struct retStruct_flow_block_flag_line_empty { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + string[][string][string] bookindex_unordered_hashes; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_heading; + int cntr; + uint[string] pith; +} +struct retStruct_flow_table_substantive_munge { + ObjGenericComposite table_object; + string table_substantive; +} #+END_SRC ** docAbstraction @@ -2761,11 +2843,11 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio @safe auto doc_has() { return DocHas_(); } - struct retStruct { + struct retStruct_docAbstraction { ObjGenericComposite[][string] document_the; DocHas_ doc_has; } - retStruct ret; + retStruct_docAbstraction ret; { ret.document_the = document_the; ret.doc_has = doc_has; @@ -2779,7 +2861,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio #+NAME: docSortOut #+HEADER: :noweb yes #+BEGIN_SRC d -@system auto txt_by_line_common_reset_()( +@system retStruct_txt_by_line_common_reset txt_by_line_common_reset_()( int[string] line_occur, string[string] an_object, uint[string] pith, @@ -2788,12 +2870,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio line_occur["para"] = eN.bi.off; pith["txt_is"] = eN.txt_is.off; an_object = an_object.object_reset; - struct retStruct { - int[string] line_occur; - string[string] this_object; - uint[string] pith; - } - retStruct ret; + retStruct_txt_by_line_common_reset ret; { ret.line_occur = line_occur; ret.this_object = an_object; @@ -2801,7 +2878,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto txt_by_line_block_start()( +@safe retStruct_txt_by_line_block_start txt_by_line_block_start()( char[] line, uint[string] pith, uint[string] dochas, @@ -2986,12 +3063,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio pith["block_state"] = eN.blk_state.on; pith["block_delim"] = eN.blk_delim.tic; } - struct retStruct { - uint[string] pith; - uint[string] dochas; - string[string] object_number_poem; - } - retStruct ret; + retStruct_txt_by_line_block_start ret; { ret.pith = pith; ret.dochas = dochas; @@ -2999,7 +3071,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto txt_by_line_block_quote()( +@safe retStruct_txt_by_line_block_generic txt_by_line_block_quote()( char[] line, string[string] an_object, uint[string] pith, @@ -3038,18 +3110,14 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } -@safe auto txt_by_line_block_group()( +@safe retStruct_txt_by_line_block_generic txt_by_line_block_group()( char[] line, string[string] an_object, uint[string] pith, @@ -3088,18 +3156,14 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } -@safe auto txt_by_line_block_block()( +@safe retStruct_txt_by_line_block_generic txt_by_line_block_block()( char[] line, string[string] an_object, uint[string] pith, @@ -3138,18 +3202,14 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } -@safe auto txt_by_line_block_poem(CMM)( +@safe retStruct_txt_by_line_block_poem txt_by_line_block_poem(CMM)( char[] line, string[string] an_object, uint[string] pith, @@ -3391,12 +3451,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - int cntr; - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_poem ret; { ret.cntr = cntr; ret.pith = pith; @@ -3404,7 +3459,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto txt_by_line_block_code()( +@safe retStruct_txt_by_line_block_generic txt_by_line_block_code()( char[] line, string[string] an_object, uint[string] pith, @@ -3447,11 +3502,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; @@ -3526,12 +3577,12 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { + struct retStruct_txt_by_line_block_table { CMM conf_make_meta; uint[string] pith; string[string] this_object; } - retStruct ret; + retStruct_txt_by_line_block_table ret; { ret.conf_make_meta = conf_make_meta, ret.pith = pith; @@ -3539,7 +3590,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@system auto txt_by_line_block_biblio( +@system retStruct_txt_by_line_block_biblio txt_by_line_block_biblio( char[] line, uint[string] pith, int bib_entry, @@ -3677,13 +3728,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } header_tag_value = ""; } - struct retStruct { - uint[string] pith; - int bib_entry; - string biblio_entry_str_json; - string[] biblio_arr_json; - } - retStruct ret; + retStruct_txt_by_line_block_biblio ret; { ret.pith = pith; ret.bib_entry = bib_entry; @@ -3795,7 +3840,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return line; } -@system auto flow_table_closed_make_special_notation_table_(CMM)( +@system retStruct_flow_table_closed_make_special_notation_table flow_table_closed_make_special_notation_table_(CMM)( char[] line, string[string] an_object, ObjGenericComposite[] the_document_body_section, @@ -3840,15 +3885,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio object_reset(an_object); processing.remove("verse"); ++cntr; - struct retStruct { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - OCNset obj_cite_digits; - ObjGenericComposite _comp_obj_heading; - int cntr; - uint[string] pith; - } - retStruct ret; + retStruct_flow_table_closed_make_special_notation_table ret; { ret.this_object = an_object; ret.the_document_body_section = the_document_body_section; @@ -3859,7 +3896,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@system auto flow_block_flag_line_empty_(B,CMM,Ts)( +@system retStruct_flow_block_flag_line_empty flow_block_flag_line_empty_(B,CMM,Ts)( char[] line, string[string] an_object, B bookindex_extract_hash, @@ -4180,16 +4217,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio ++cntr; } } - struct retStruct { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - string[][string][string] bookindex_unordered_hashes; - OCNset obj_cite_digits; - ObjGenericComposite comp_obj_heading; - int cntr; - uint[string] pith; - } - retStruct ret; + retStruct_flow_block_flag_line_empty ret; { ret.this_object = an_object; ret.the_document_body_section = the_document_body_section; @@ -4201,7 +4229,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@system auto flow_book_index_(B)( +@system retStruct_flow_book_index flow_book_index_(B)( char[] line, string[string] an_object, string book_idx_tmp, @@ -4249,12 +4277,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - string[string] this_object; - uint[string] pith; - string book_idx_tmp; - } - retStruct ret; + retStruct_flow_book_index ret; { ret.this_object = an_object; ret.pith = pith; @@ -4262,7 +4285,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto flow_heading_found_()( +@safe retStruct_flow_heading_found flow_heading_found_()( char[] line, string[string] heading_match_str, string[] _make_unmarked_headings, @@ -4341,12 +4364,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } pith["make_headings"] = eN.bi.on; } - struct retStruct { - string[string] heading_match_str; - Regex!(char)[string] heading_match_rgx; - uint[string] pith; - } - retStruct ret; + retStruct_flow_heading_found ret; { ret.heading_match_str = heading_match_str; ret.heading_match_rgx = heading_match_rgx; @@ -4354,7 +4372,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto flow_heading_make_set_()( +@safe retStruct_flow_heading_make_set flow_heading_make_set_()( char[] line, int[string] line_occur, return ref Regex!(char)[string] heading_match_rgx, @@ -4408,12 +4426,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } } } - struct retStruct { - char[] line; - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_flow_heading_make_set ret; { ret.line = line; ret.pith = pith; @@ -4591,7 +4604,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio writeln(line.strip); } } - struct retStruct { + struct retStruct_flow_heading_matched { string[string] this_object; int[string] line_occur; string an_object_key; @@ -4600,7 +4613,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio uint[string] pith; CMM conf_make_meta; } - retStruct ret; + retStruct_flow_heading_matched ret; { ret.this_object = an_object; ret.line_occur = line_occur; @@ -4612,7 +4625,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return ret; } -@safe auto flow_para_match_()( +@safe retStruct_flow_para_match flow_para_match_()( char[] line, string[string] an_object, string an_object_key, @@ -4663,15 +4676,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } ++line_occur["para"]; } - struct retStruct { - uint[string] pith; - string[string] this_object; - string this_object_key; - int[string] indent; - bool bullet; - int[string] line_occur; - } - retStruct ret; + retStruct_flow_para_match ret; { ret.pith = pith; ret.this_object = an_object; @@ -4729,7 +4734,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio } return table_object; } -@safe auto flow_table_array_munge()( +@safe retStruct_flow_table_array_munge flow_table_array_munge()( ObjGenericComposite table_object, string[][] table_array, ) { @@ -4849,18 +4854,14 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio _table_substantive); } table_object.text = _table_substantive; - struct retStruct { - ObjGenericComposite table_object; - string[][] table_array; - } - retStruct ret; + retStruct_flow_table_array_munge ret; { ret.table_object = table_object; ret.table_array = table_array; } return ret; } -@system auto flow_table_substantive_munge()( +@system retStruct_flow_table_substantive_munge flow_table_substantive_munge()( ObjGenericComposite table_object, string table_substantive, ) { @@ -4880,18 +4881,14 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio _table_array = _get.table_array; // what do you do with this? how is this passed down? } } - struct retStruct { - ObjGenericComposite table_object; - string table_substantive; - } - retStruct ret; + retStruct_flow_table_substantive_munge ret; { ret.table_object = table_object; ret.table_substantive = table_substantive; // has anything been changed here? } return ret; } -@system auto flow_table_substantive_munge_special()( +@system retStruct_flow_table_substantive_munge flow_table_substantive_munge_special()( ObjGenericComposite table_object, string table_substantive, ) { @@ -4911,11 +4908,7 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio _table_array = _get.table_array; } } - struct retStruct { - ObjGenericComposite table_object; - string table_substantive; - } - retStruct ret; + retStruct_flow_table_substantive_munge ret; { ret.table_object = table_object; ret.table_substantive = table_substantive; @@ -5335,7 +5328,7 @@ static struct ObjInlineMarkup { heading_toc_ = (m.post).replaceAll(rgx.inline_notes_curly_gen, ""); return heading_toc_; }; - @safe auto flow_table_of_contents_gather_headings(CMM)( // + @safe retStruct_flow_table_of_contents_gather_headings flow_table_of_contents_gather_headings(CMM)( // string[string] obj_, CMM conf_make_meta, string[string] tag_in_seg, @@ -5418,11 +5411,7 @@ static struct ObjInlineMarkup { default: break; } - struct retStruct { - ObjGenericComposite[] the_document_toc_section; - string[][string] lev4_subtoc; - } - retStruct ret; + retStruct_flow_table_of_contents_gather_headings ret; { ret.the_document_toc_section = the_document_toc_section; ret.lev4_subtoc = lev4_subtoc; @@ -6300,7 +6289,7 @@ struct NotesSection { } /+ +/ struct Bibliography { - @system public auto flow_bibliography_()( + @system public retStruct_flow_bibliography flow_bibliography_()( string[] biblio_unsorted_incomplete, JSONValue[] bib_arr_json ) { @@ -6323,12 +6312,7 @@ struct Bibliography { cntr++; } } - struct retStruct { - JSONValue[] biblio_sorted; - JSONValue[] bib_arr_json; - string[] biblio_unsorted_incomplete; - } - retStruct ret; + retStruct_flow_bibliography ret; { ret.biblio_sorted = biblio_sorted__; ret.bib_arr_json = bib_arr_json; @@ -7218,6 +7202,7 @@ struct NodeStructureMetadata { break; } } +/+ abstraction functions assertions ↑ +/ #+END_SRC * template docSectKeysSeq diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 620f884..da8949e 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -54,7 +54,7 @@ +/ module doc_reform.meta.metadoc_from_src; template docAbstraction() { - /+ ↓ abstraction imports +/ + /+ ↓ abstraction imports +/ import std.algorithm, std.container, @@ -67,11 +67,11 @@ template docAbstraction() { doc_reform.meta.rgx, doc_reform.meta.metadoc_object_setter, doc_reform.meta.rgx; - /+ ↓ abstraction mixins +/ + /+ ↓ abstraction mixins +/ mixin ObjectSetter; mixin InternalMarkup; mixin spineRgxIn; - /+ ↓ abstraction struct init +/ + /+ ↓ abstraction struct init +/ @safe static auto eN() { struct _e { enum bi { @@ -436,7 +436,88 @@ template docAbstraction() { } return tag_assoc; } - /+ ↓ abstract marked up document +/ + struct retStruct_txt_by_line_common_reset { + int[string] line_occur; + string[string] this_object; + uint[string] pith; + } + struct retStruct_txt_by_line_block_start { + uint[string] pith; + uint[string] dochas; + string[string] object_number_poem; + } + struct retStruct_txt_by_line_block_generic { + uint[string] pith; + string[string] this_object; + } + struct retStruct_txt_by_line_block_poem { + int cntr; + uint[string] pith; + string[string] this_object; + } + struct retStruct_txt_by_line_block_biblio { + uint[string] pith; + int bib_entry; + string biblio_entry_str_json; + string[] biblio_arr_json; + } + struct retStruct_flow_book_index { + string[string] this_object; + uint[string] pith; + string book_idx_tmp; + } + struct retStruct_flow_heading_found { + string[string] heading_match_str; + Regex!(char)[string] heading_match_rgx; + uint[string] pith; + } + struct retStruct_flow_heading_make_set { + char[] line; + uint[string] pith; + string[string] this_object; + } + struct retStruct_flow_para_match { + uint[string] pith; + string[string] this_object; + string this_object_key; + int[string] indent; + bool bullet; + int[string] line_occur; + } + struct retStruct_flow_table_array_munge { + ObjGenericComposite table_object; + string[][] table_array; + } + struct retStruct_flow_table_of_contents_gather_headings { + ObjGenericComposite[] the_document_toc_section; + string[][string] lev4_subtoc; + } + struct retStruct_flow_bibliography { + JSONValue[] biblio_sorted; + JSONValue[] bib_arr_json; + string[] biblio_unsorted_incomplete; + } + struct retStruct_flow_table_closed_make_special_notation_table { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + OCNset obj_cite_digits; + ObjGenericComposite _comp_obj_heading; + int cntr; + uint[string] pith; + } + struct retStruct_flow_block_flag_line_empty { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + string[][string][string] bookindex_unordered_hashes; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_heading; + int cntr; + uint[string] pith; + } + struct retStruct_flow_table_substantive_munge { + ObjGenericComposite table_object; + string table_substantive; + } @system auto docAbstraction(CMM,Opt,Mf) ( char[][] markup_sourcefile_content, CMM conf_make_meta, @@ -445,7 +526,7 @@ template docAbstraction() { bool _new_doc ) { static auto rgx = RgxI(); - /+ ↓ abstraction init +/ + /+ ↓ abstraction init +/ scope(success) { } scope(failure) { @@ -465,9 +546,6 @@ template docAbstraction() { reset_note_numbers = true; lev_anchor_tag = ""; anchor_tag = ""; - // dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - // dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - // dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; } mixin spineNode; auto node_para_int_ = node_metadata_para_int; @@ -589,7 +667,7 @@ template docAbstraction() { string[][string] lev4_subtoc; string[][string] segnames = ["html": ["toc"], "epub": ["toc"]]; int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; - /+ abstraction init ↑ +/ + /+ abstraction init ↑ +/ enum Substitute { match, markup, } debug (substitutions) { writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); @@ -630,8 +708,9 @@ template docAbstraction() { } _loopMarkupSrcByLineStruct ret; srcDocLoopLineByLine_: - foreach (line; markup_sourcefile_content) { /+ ↓ markup document/text line by line +/ - // "line" variable can be empty but should never be null + foreach (line; markup_sourcefile_content) { + /+ ↓ markup document/text line by line +/ + // "line" variable can be empty but should never be null /+ scope +/ scope(exit) { } scope(failure) { @@ -659,9 +738,10 @@ template docAbstraction() { pith = _get.pith; } continue; - } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { /+ object other than "code block" object +/ - /+ (includes regular text paragraph, headings & blocks other than code) +/ - /+ heading, glossary, blurb, poem, group, block, quote, table +/ + } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { + /+ object other than "code block" object +/ + /+ (includes regular text paragraph, headings & blocks other than code) +/ + /+ heading, glossary, blurb, poem, group, block, quote, table +/ line = line.inline_markup_faces; // by text line (rather than by text object), linebreaks in para problematic if (line.matchFirst(rgx.heading_biblio) || (pith["section"] == eN.sect.bibliography @@ -1012,14 +1092,16 @@ template docAbstraction() { } continue; } - } else { /+ not within a block group +/ + } else { + /+ not within a block group +/ assert( (pith["block_state"] == eN.blk_state.off) || (pith["block_state"] == eN.blk_state.closing), "block status: none or closed" ); if (line.matchFirst(rgx.block_open)) { - if (line.matchFirst(rgx.block_poem_open)) { /+ poem to verse exceptions! +/ + if (line.matchFirst(rgx.block_poem_open)) { + /+ poem to verse exceptions! +/ object_reset(an_object); processing.remove("verse"); object_number_poem["start"] = obj_cite_digits.object_number.to!string; @@ -1033,7 +1115,8 @@ template docAbstraction() { } } continue; - } else if (!line.empty) { /+ line not empty - non blocks (headings, paragraphs) & closed blocks +/ + } else if (!line.empty) { + /+ line not empty - non blocks (headings, paragraphs) & closed blocks +/ assert( !line.empty, "line tested, line not empty surely:\n \"" ~ line ~ "\"" @@ -1058,7 +1141,8 @@ template docAbstraction() { } if (line.matchFirst(rgx.book_index_item) || line.matchFirst(rgx.book_index_item_open) - || pith["section"] == eN.sect.book_index) { /+ book_index +/ + || pith["section"] == eN.sect.book_index) { + /+ book_index +/ { auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action); { @@ -1067,9 +1151,11 @@ template docAbstraction() { book_idx_tmp = _get.book_idx_tmp; } } - } else { /+ not book_index +/ + } else { + /+ not book_index +/ an_object_key = "body_nugget"; - if (auto m = line.matchFirst(rgx.comment)) { /+ matched comment +/ + if (auto m = line.matchFirst(rgx.comment)) { + /+ matched comment +/ debug(comment) { writeln(line); } @@ -1096,7 +1182,8 @@ template docAbstraction() { && pith["txt_is"] == eN.txt_is.off ) { /+ heading or para but neither flag nor line exists +/ if ((conf_make_meta.make.headings.length > 2) - && (pith["make_headings"] == eN.bi.off)) { /+ heading found +/ + && (pith["make_headings"] == eN.bi.off)) { + /+ heading found +/ { auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); { @@ -1110,7 +1197,8 @@ template docAbstraction() { && (line_occur["para"] == eN.bi.off && line_occur["heading"] == eN.bi.off) && pith["txt_is"] == eN.txt_is.off - ) { /+ heading make set +/ + ) { + /+ heading make set +/ { auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); { @@ -1126,7 +1214,8 @@ template docAbstraction() { - should be incorporated in composite objects - should happen before endnote links set (they need to be moved down?) +/ - if (line.matchFirst(rgx.headings)) { /+ heading match +/ + if (line.matchFirst(rgx.headings)) { + /+ heading match +/ line = line._doc_header_and_make_substitutions_(conf_make_meta); { auto _get = line.flow_heading_matched_( @@ -1143,7 +1232,8 @@ template docAbstraction() { pith = _get.pith; } } - } else if (line_occur["para"] == eN.bi.off) { /+ para match +/ + } else if (line_occur["para"] == eN.bi.off) { + /+ para match +/ an_object_key = "body_nugget"; line = line ._doc_header_and_make_substitutions_(conf_make_meta) @@ -1160,13 +1250,15 @@ template docAbstraction() { } } } - } else if (line_occur["heading"] > eN.bi.off) { /+ heading +/ + } else if (line_occur["heading"] > eN.bi.off) { + /+ heading +/ debug(heading) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; ++line_occur["heading"]; - } else if (line_occur["para"] > eN.bi.off) { /+ paragraph +/ + } else if (line_occur["para"] > eN.bi.off) { + /+ paragraph +/ debug(para) { writeln(an_object_key, "-> ", line); } @@ -1177,7 +1269,8 @@ template docAbstraction() { ++line_occur["para"]; } } - } else if (pith["block_state"] == eN.blk_state.closing) { /+ line empty, with blocks flag +/ + } else if (pith["block_state"] == eN.blk_state.closing) { + /+ line empty, with blocks flag +/ { auto _get = line.flow_block_flag_line_empty_( an_object, @@ -1202,7 +1295,8 @@ template docAbstraction() { pith = _get.pith; } } - } else { /+ line.empty, post contents, empty variables: +/ + } else { + /+ line.empty, post contents, empty variables: +/ assert( line.empty, "\nline should be empty:\n \"" @@ -1219,7 +1313,8 @@ template docAbstraction() { } if (pith["txt_is"] == eN.txt_is.heading && line_occur["heading"] > eN.bi.off - ) { /+ heading object (current line empty) +/ + ) { + /+ heading object (current line empty) +/ obj_cite_digits = (an_object["lev_markup_number"].to!int == 0) ? ocn_emit(eN.ocn.reset) : ocn_emit(pith["ocn"]); @@ -1245,7 +1340,8 @@ template docAbstraction() { lev_anchor_tag = anchor_tag; tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; - if (lv0to3_tags.length > 0) { /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ + if (lv0to3_tags.length > 0) { + /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ foreach (lv0_to_lv3_html_tag; lv0to3_tags) { tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag; } @@ -1260,7 +1356,8 @@ template docAbstraction() { tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"]; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; - switch (an_object["lev_markup_number"].to!int) { /+ names used for epub markup segments A to D +/ + switch (an_object["lev_markup_number"].to!int) { + /+ names used for epub markup segments A to D +/ case 0: segn = "_the_title"; goto default; @@ -1416,9 +1513,9 @@ template docAbstraction() { ++cntr; // } else { // could be useful to test line variable should be empty and never null } - } // close else for line empty - } // close else for not the above - } // close after non code, other blocks or regular text + } // close else for line empty + } // close else for not the above + } // close after non code, other blocks or regular text /+ unless (the_document_body_section.length == 0) ? +/ if (the_document_body_section.length > 0) { if (((the_document_body_section[$-1].metainfo.is_a == "para") @@ -1432,7 +1529,8 @@ template docAbstraction() { && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) { pith["section"] = eN.sect.unset; } - if (the_document_body_section[$-1].metainfo.is_a == "verse") { /+ scan for endnotes for whole poem (each verse in poem) +/ + if (the_document_body_section[$-1].metainfo.is_a == "verse") { + /+ scan for endnotes for whole poem (each verse in poem) +/ foreach (i; previous_length .. the_document_body_section.length) { if (the_document_body_section[i].metainfo.is_a == "verse") { if ((the_document_body_section[i].text).match( @@ -1446,7 +1544,8 @@ template docAbstraction() { } } } - } else { /+ scan object for endnotes +/ + } else { + /+ scan object for endnotes +/ previous_length = the_document_body_section.length.to!int; if ((the_document_body_section[$-1].text).match( rgx.inline_notes_al_all_note @@ -2577,12 +2676,12 @@ template docAbstraction() { } } } - /+ TODO - - note create/insert heading object sole purpose eof close all open tags - sort out: - - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; - - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; - +/ + /+ TODO + - note create/insert heading object sole purpose eof close all open tags + sort out: + - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; + - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; + +/ comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "empty"; comp_obj_heading_.metainfo.is_of_section = "empty"; @@ -2744,18 +2843,18 @@ template docAbstraction() { @safe auto doc_has() { return DocHas_(); } - struct retStruct { + struct retStruct_docAbstraction { ObjGenericComposite[][string] document_the; DocHas_ doc_has; } - retStruct ret; + retStruct_docAbstraction ret; { ret.document_the = document_the; ret.doc_has = doc_has; } return ret; } /+ ← closed: abstract doc source +/ - @system auto txt_by_line_common_reset_()( + @system retStruct_txt_by_line_common_reset txt_by_line_common_reset_()( int[string] line_occur, string[string] an_object, uint[string] pith, @@ -2764,12 +2863,7 @@ template docAbstraction() { line_occur["para"] = eN.bi.off; pith["txt_is"] = eN.txt_is.off; an_object = an_object.object_reset; - struct retStruct { - int[string] line_occur; - string[string] this_object; - uint[string] pith; - } - retStruct ret; + retStruct_txt_by_line_common_reset ret; { ret.line_occur = line_occur; ret.this_object = an_object; @@ -2777,7 +2871,7 @@ template docAbstraction() { } return ret; } - @safe auto txt_by_line_block_start()( + @safe retStruct_txt_by_line_block_start txt_by_line_block_start()( char[] line, uint[string] pith, uint[string] dochas, @@ -2962,12 +3056,7 @@ template docAbstraction() { pith["block_state"] = eN.blk_state.on; pith["block_delim"] = eN.blk_delim.tic; } - struct retStruct { - uint[string] pith; - uint[string] dochas; - string[string] object_number_poem; - } - retStruct ret; + retStruct_txt_by_line_block_start ret; { ret.pith = pith; ret.dochas = dochas; @@ -2975,7 +3064,7 @@ template docAbstraction() { } return ret; } - @safe auto txt_by_line_block_quote()( + @safe retStruct_txt_by_line_block_generic txt_by_line_block_quote()( char[] line, string[string] an_object, uint[string] pith, @@ -3014,18 +3103,14 @@ template docAbstraction() { } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } - @safe auto txt_by_line_block_group()( + @safe retStruct_txt_by_line_block_generic txt_by_line_block_group()( char[] line, string[string] an_object, uint[string] pith, @@ -3064,18 +3149,14 @@ template docAbstraction() { } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } - @safe auto txt_by_line_block_block()( + @safe retStruct_txt_by_line_block_generic txt_by_line_block_block()( char[] line, string[string] an_object, uint[string] pith, @@ -3114,18 +3195,14 @@ template docAbstraction() { } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; } return ret; } - @safe auto txt_by_line_block_poem(CMM)( + @safe retStruct_txt_by_line_block_poem txt_by_line_block_poem(CMM)( char[] line, string[string] an_object, uint[string] pith, @@ -3367,12 +3444,7 @@ template docAbstraction() { } } } - struct retStruct { - int cntr; - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_poem ret; { ret.cntr = cntr; ret.pith = pith; @@ -3380,7 +3452,7 @@ template docAbstraction() { } return ret; } - @safe auto txt_by_line_block_code()( + @safe retStruct_txt_by_line_block_generic txt_by_line_block_code()( char[] line, string[string] an_object, uint[string] pith, @@ -3423,11 +3495,7 @@ template docAbstraction() { } } } - struct retStruct { - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_txt_by_line_block_generic ret; { ret.pith = pith; ret.this_object = an_object; @@ -3502,12 +3570,12 @@ template docAbstraction() { } } } - struct retStruct { + struct retStruct_txt_by_line_block_table { CMM conf_make_meta; uint[string] pith; string[string] this_object; } - retStruct ret; + retStruct_txt_by_line_block_table ret; { ret.conf_make_meta = conf_make_meta, ret.pith = pith; @@ -3515,7 +3583,7 @@ template docAbstraction() { } return ret; } - @system auto txt_by_line_block_biblio( + @system retStruct_txt_by_line_block_biblio txt_by_line_block_biblio( char[] line, uint[string] pith, int bib_entry, @@ -3653,13 +3721,7 @@ template docAbstraction() { } header_tag_value = ""; } - struct retStruct { - uint[string] pith; - int bib_entry; - string biblio_entry_str_json; - string[] biblio_arr_json; - } - retStruct ret; + retStruct_txt_by_line_block_biblio ret; { ret.pith = pith; ret.bib_entry = bib_entry; @@ -3771,7 +3833,7 @@ template docAbstraction() { } return line; } - @system auto flow_table_closed_make_special_notation_table_(CMM)( + @system retStruct_flow_table_closed_make_special_notation_table flow_table_closed_make_special_notation_table_(CMM)( char[] line, string[string] an_object, ObjGenericComposite[] the_document_body_section, @@ -3816,15 +3878,7 @@ template docAbstraction() { object_reset(an_object); processing.remove("verse"); ++cntr; - struct retStruct { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - OCNset obj_cite_digits; - ObjGenericComposite _comp_obj_heading; - int cntr; - uint[string] pith; - } - retStruct ret; + retStruct_flow_table_closed_make_special_notation_table ret; { ret.this_object = an_object; ret.the_document_body_section = the_document_body_section; @@ -3835,7 +3889,7 @@ template docAbstraction() { } return ret; } - @system auto flow_block_flag_line_empty_(B,CMM,Ts)( + @system retStruct_flow_block_flag_line_empty flow_block_flag_line_empty_(B,CMM,Ts)( char[] line, string[string] an_object, B bookindex_extract_hash, @@ -4156,16 +4210,7 @@ template docAbstraction() { ++cntr; } } - struct retStruct { - string[string] this_object; - ObjGenericComposite[] the_document_body_section; - string[][string][string] bookindex_unordered_hashes; - OCNset obj_cite_digits; - ObjGenericComposite comp_obj_heading; - int cntr; - uint[string] pith; - } - retStruct ret; + retStruct_flow_block_flag_line_empty ret; { ret.this_object = an_object; ret.the_document_body_section = the_document_body_section; @@ -4177,7 +4222,7 @@ template docAbstraction() { } return ret; } - @system auto flow_book_index_(B)( + @system retStruct_flow_book_index flow_book_index_(B)( char[] line, string[string] an_object, string book_idx_tmp, @@ -4225,12 +4270,7 @@ template docAbstraction() { } } } - struct retStruct { - string[string] this_object; - uint[string] pith; - string book_idx_tmp; - } - retStruct ret; + retStruct_flow_book_index ret; { ret.this_object = an_object; ret.pith = pith; @@ -4238,7 +4278,7 @@ template docAbstraction() { } return ret; } - @safe auto flow_heading_found_()( + @safe retStruct_flow_heading_found flow_heading_found_()( char[] line, string[string] heading_match_str, string[] _make_unmarked_headings, @@ -4317,12 +4357,7 @@ template docAbstraction() { } pith["make_headings"] = eN.bi.on; } - struct retStruct { - string[string] heading_match_str; - Regex!(char)[string] heading_match_rgx; - uint[string] pith; - } - retStruct ret; + retStruct_flow_heading_found ret; { ret.heading_match_str = heading_match_str; ret.heading_match_rgx = heading_match_rgx; @@ -4330,7 +4365,7 @@ template docAbstraction() { } return ret; } - @safe auto flow_heading_make_set_()( + @safe retStruct_flow_heading_make_set flow_heading_make_set_()( char[] line, int[string] line_occur, return ref Regex!(char)[string] heading_match_rgx, @@ -4384,12 +4419,7 @@ template docAbstraction() { } } } - struct retStruct { - char[] line; - uint[string] pith; - string[string] this_object; - } - retStruct ret; + retStruct_flow_heading_make_set ret; { ret.line = line; ret.pith = pith; @@ -4567,7 +4597,7 @@ template docAbstraction() { writeln(line.strip); } } - struct retStruct { + struct retStruct_flow_heading_matched { string[string] this_object; int[string] line_occur; string an_object_key; @@ -4576,7 +4606,7 @@ template docAbstraction() { uint[string] pith; CMM conf_make_meta; } - retStruct ret; + retStruct_flow_heading_matched ret; { ret.this_object = an_object; ret.line_occur = line_occur; @@ -4588,7 +4618,7 @@ template docAbstraction() { } return ret; } - @safe auto flow_para_match_()( + @safe retStruct_flow_para_match flow_para_match_()( char[] line, string[string] an_object, string an_object_key, @@ -4639,15 +4669,7 @@ template docAbstraction() { } ++line_occur["para"]; } - struct retStruct { - uint[string] pith; - string[string] this_object; - string this_object_key; - int[string] indent; - bool bullet; - int[string] line_occur; - } - retStruct ret; + retStruct_flow_para_match ret; { ret.pith = pith; ret.this_object = an_object; @@ -4705,7 +4727,7 @@ template docAbstraction() { } return table_object; } - @safe auto flow_table_array_munge()( + @safe retStruct_flow_table_array_munge flow_table_array_munge()( ObjGenericComposite table_object, string[][] table_array, ) { @@ -4825,18 +4847,14 @@ template docAbstraction() { _table_substantive); } table_object.text = _table_substantive; - struct retStruct { - ObjGenericComposite table_object; - string[][] table_array; - } - retStruct ret; + retStruct_flow_table_array_munge ret; { ret.table_object = table_object; ret.table_array = table_array; } return ret; } - @system auto flow_table_substantive_munge()( + @system retStruct_flow_table_substantive_munge flow_table_substantive_munge()( ObjGenericComposite table_object, string table_substantive, ) { @@ -4856,18 +4874,14 @@ template docAbstraction() { _table_array = _get.table_array; // what do you do with this? how is this passed down? } } - struct retStruct { - ObjGenericComposite table_object; - string table_substantive; - } - retStruct ret; + retStruct_flow_table_substantive_munge ret; { ret.table_object = table_object; ret.table_substantive = table_substantive; // has anything been changed here? } return ret; } - @system auto flow_table_substantive_munge_special()( + @system retStruct_flow_table_substantive_munge flow_table_substantive_munge_special()( ObjGenericComposite table_object, string table_substantive, ) { @@ -4887,19 +4901,15 @@ template docAbstraction() { _table_array = _get.table_array; } } - struct retStruct { - ObjGenericComposite table_object; - string table_substantive; - } - retStruct ret; + retStruct_flow_table_substantive_munge ret; { ret.table_object = table_object; ret.table_substantive = table_substantive; } return ret; } - /+ abstraction functions ↑ +/ - /+ ↓ abstraction function emitters +/ + /+ abstraction functions ↑ +/ + /+ ↓ abstraction function emitters +/ @safe pure struct OCNemitter { int ocn_digit, ocn_object_number, ocn_on_, ocn_off_, ocn_bkidx, ocn_bkidx_; string object_identifier; @@ -5311,7 +5321,7 @@ template docAbstraction() { heading_toc_ = (m.post).replaceAll(rgx.inline_notes_curly_gen, ""); return heading_toc_; }; - @safe auto flow_table_of_contents_gather_headings(CMM)( // + @safe retStruct_flow_table_of_contents_gather_headings flow_table_of_contents_gather_headings(CMM)( // string[string] obj_, CMM conf_make_meta, string[string] tag_in_seg, @@ -5394,11 +5404,7 @@ template docAbstraction() { default: break; } - struct retStruct { - ObjGenericComposite[] the_document_toc_section; - string[][string] lev4_subtoc; - } - retStruct ret; + retStruct_flow_table_of_contents_gather_headings ret; { ret.the_document_toc_section = the_document_toc_section; ret.lev4_subtoc = lev4_subtoc; @@ -6276,7 +6282,7 @@ template docAbstraction() { } /+ +/ struct Bibliography { - @system public auto flow_bibliography_()( + @system public retStruct_flow_bibliography flow_bibliography_()( string[] biblio_unsorted_incomplete, JSONValue[] bib_arr_json ) { @@ -6299,12 +6305,7 @@ template docAbstraction() { cntr++; } } - struct retStruct { - JSONValue[] biblio_sorted; - JSONValue[] bib_arr_json; - string[] biblio_unsorted_incomplete; - } - retStruct ret; + retStruct_flow_bibliography ret; { ret.biblio_sorted = biblio_sorted__; ret.bib_arr_json = bib_arr_json; @@ -7194,8 +7195,8 @@ template docAbstraction() { break; } } - /+ abstraction functions assertions ↑ +/ -} /+ ← closed: template docAbstraction +/ + /+ abstraction functions assertions ↑ +/ +} template docSectKeysSeq() { @safe auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { struct doc_sect_keys_seq { -- cgit v1.2.3