diff options
Diffstat (limited to 'org/ao_doc_abstraction.org')
-rw-r--r-- | org/ao_doc_abstraction.org | 760 |
1 files changed, 544 insertions, 216 deletions
diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org index aac99f7..e527f8c 100644 --- a/org/ao_doc_abstraction.org +++ b/org/ao_doc_abstraction.org @@ -162,18 +162,19 @@ template SiSUdocAbstraction() { <<abs_functions_header_set_common>> <<abs_functions_ocn_status>> <<abs_functions_block>> - <<abs_functions_block_code>> - <<abs_functions_block_biblio>> - // <<abs_functions_block_glossary>> + <<abs_functions_block_quote>> <<abs_functions_block_group>> <<abs_functions_block_block>> <<abs_functions_block_poem>> - <<abs_functions_block_quote>> + <<abs_functions_block_code>> <<abs_functions_block_table>> + <<abs_functions_block_biblio>> + // <<abs_functions_block_glossary>> <<abs_functions_block_line_status_empty>> <<abs_functions_book_index>> <<abs_functions_heading>> <<abs_functions_para>> + <<abs_functions_table>> /+ abstraction functions ↑ +/ /+ ↓ abstraction function emitters +/ <<ao_emitters_ocn>> @@ -846,6 +847,16 @@ if there is a blurb section you need to: #+END_SRC ***** in blocks [+1] :block:active: +****** in block: quote :quote: + +#+name: abs_in_loop_body_non_code_obj +#+BEGIN_SRC d +} else if (type["quote"] == TriState.on) { + /+ within block object: quote +/ + _quote_block_(line, an_object, type); + continue; +#+END_SRC + ****** in block: group :group: #+name: abs_in_loop_body_non_code_obj @@ -877,23 +888,13 @@ if there is a blurb section you need to: continue; #+END_SRC -****** in block: quote :quote: - -#+name: abs_in_loop_body_non_code_obj -#+BEGIN_SRC d -} else if (type["quote"] == TriState.on) { - /+ within block object: quote +/ - _quote_block_(line, an_object, type); - continue; -#+END_SRC - ****** in block: table :table: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d } else if (type["table"] == TriState.on) { /+ within block object: table +/ - _table_block_(line, an_object, type); + _table_block_(line, an_object, type, dochead_make_aa); continue; #+END_SRC @@ -2283,8 +2284,12 @@ void _start_block_(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d auto rgx = Rgx(); - if (line.matchFirst(rgx.block_curly_code_open)) { + string code_block_syntax = ""; + bool code_block_numbered = false; + if (auto m = line.matchFirst(rgx.block_curly_code_open)) { /+ curly code open +/ + code_block_syntax = (m.captures[1]) ? m.captures[1].to!string : ""; + code_block_numbered = (m.captures[2] == "#") ? true : false; debug(code) { // code (curly) open writefln( "* [code curly] %s", @@ -2341,7 +2346,7 @@ void _start_block_(L,T,N)( type["blocks"] = TriState.on; type["quote"] = TriState.on; type["curly_quote"] = TriState.on; - } else if (line.matchFirst(rgx.block_curly_table_open)) { + } else if (auto m = line.matchFirst(rgx.block_curly_table_open)) { /+ curly table open +/ debug(table) { // table (curly) open writefln( @@ -2349,17 +2354,28 @@ void _start_block_(L,T,N)( line ); } - type["blocks"] = TriState.on; - type["table"] = TriState.on; - type["curly_table"] = TriState.on; + an_object["table_head"] = m.captures[1].to!string; + an_object["block_type"] = "curly"; + type["blocks"] = TriState.on; + type["table"] = TriState.on; + type["curly_table"] = TriState.on; + } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { + /+ table: special table block markup syntax! +/ + an_object["table_head"] = m.captures[1].to!string; + an_object["block_type"] = "special"; + type["blocks"] = TriState.on; + type["table"] = TriState.on; + type["curly_table_special_markup"] = TriState.on; #+END_SRC ***** block (various) tic open :tic: #+name: abs_functions_block #+BEGIN_SRC d - } else if (line.matchFirst(rgx.block_tic_code_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { /+ tic code open +/ + code_block_syntax = (m.captures[1]) ? m.captures[1].to!string : ""; + code_block_numbered = (m.captures[2] == "#") ? true : false; debug(code) { // code (tic) open writefln( "* [code tic] %s", @@ -2415,7 +2431,7 @@ void _start_block_(L,T,N)( type["blocks"] = TriState.on; type["quote"] = TriState.on; type["tic_quote"] = TriState.on; - } else if (line.matchFirst(rgx.block_tic_table_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_table_open)) { /+ tic table open +/ debug(table) { // table (tic) open writefln( @@ -2423,9 +2439,11 @@ void _start_block_(L,T,N)( line ); } - type["blocks"] = TriState.on; - type["table"] = TriState.on; - type["tic_table"] = TriState.on; + an_object["table_head"] = m.captures[1].to!string; + an_object["block_type"] = "tic"; + type["blocks"] = TriState.on; + type["table"] = TriState.on; + type["tic_table"] = TriState.on; } #+END_SRC @@ -2701,6 +2719,53 @@ void _biblio_block_( } #+END_SRC +***** quote block :quote: + +#+name: abs_functions_block_quote +#+BEGIN_SRC d +void _quote_block_(L,O,T)( + return ref L line, + return ref O an_object, + return ref T type +) { + debug(asserts) { + static assert(is(typeof(line) == char[])); + static assert(is(typeof(an_object) == string[string])); + static assert(is(typeof(type) == int[string])); + } + auto rgx = Rgx(); + if (type["curly_quote"] == TriState.on) { + if (line.matchFirst(rgx.block_curly_quote_close)) { + debug(quote) { // quote (curly) close + writeln(line); + } + type["blocks"] = TriState.closing; + type["quote"] = TriState.closing; + type["curly_quote"] = TriState.off; + } else { + debug(quote) { + writeln(line); + } + an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) + } + } else if (type["tic_quote"] == TriState.on) { + if (line.matchFirst(rgx.block_tic_close)) { + debug(quote) { // quote (tic) close + writeln(line); + } + type["blocks"] = TriState.closing; + type["quote"] = TriState.closing; + type["tic_quote"] = TriState.off; + } else { + debug(quote) { + writeln(line); + } + an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) + } + } +} +#+END_SRC + ***** group block :group: #+name: abs_functions_block_group @@ -2820,47 +2885,50 @@ void _poem_block_(L,O,T,C,N,Ma)( auto rgx = Rgx(); if (type["curly_poem"] == TriState.on) { if (line.matchFirst(rgx.block_curly_poem_close)) { - an_object[an_object_key]="verse"; - debug(poem) { // poem (curly) close - writefln( - "* [poem curly] %s", - line - ); - } - if (processing.length > 0) { - an_object[an_object_key] = processing["verse"]; - } - debug(poem) { // poem (curly) close - writeln(__LINE__); - writefln( - "* %s %s", - obj_cite_number, - line - ); - } - if (an_object.length > 0) { - debug(poem) { // poem (curly) close - writeln( + if (an_object_key in an_object + || processing.length > 0) { + an_object[an_object_key] = ""; + debug(poem) { // poem (curly) close + writefln( + "* [poem curly] %s", + line + ); + } + if (processing.length > 0) { + an_object[an_object_key] = processing["verse"]; + } + debug(poem) { // poem (curly) close + writeln(__LINE__); + writefln( + "* %s %s", obj_cite_number, - an_object[an_object_key] + line ); } - an_object["is"] = "verse"; - auto substantive_obj_misc_tuple = - obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.use = "body"; - comp_obj_block.is_of = "block"; - comp_obj_block.is_a = "verse"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + if (an_object.length > 0) { + debug(poem) { // poem (curly) close + writeln( + obj_cite_number, + an_object[an_object_key] + ); + } + an_object["is"] = "verse"; + auto substantive_obj_misc_tuple = + obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + comp_obj_block = comp_obj_block.init; + comp_obj_block.use = "body"; + comp_obj_block.is_of = "block"; + comp_obj_block.is_a = "verse"; + comp_obj_block.ocn = obj_cite_number; + comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + } object_reset(an_object); processing.remove("verse"); ++cntr; @@ -2891,7 +2959,7 @@ void _poem_block_(L,O,T,C,N,Ma)( ); } processing.remove("verse"); - an_object["is"] = "verse"; + an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, @@ -2938,7 +3006,7 @@ void _poem_block_(L,O,T,C,N,Ma)( writeln(obj_cite_number, line); } processing.remove("verse"); - an_object["is"] = "verse"; + an_object["is"] = "verse"; auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; @@ -2983,7 +3051,7 @@ void _poem_block_(L,O,T,C,N,Ma)( ); } processing.remove("verse"); - an_object["is"] = "verse"; + an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3017,61 +3085,15 @@ void _poem_block_(L,O,T,C,N,Ma)( } #+END_SRC -***** quote block :quote: - -#+name: abs_functions_block_quote -#+BEGIN_SRC d -void _quote_block_(L,O,T)( - return ref L line, - return ref O an_object, - return ref T type -) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(type) == int[string])); - } - auto rgx = Rgx(); - if (type["curly_quote"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_quote_close)) { - debug(quote) { // quote (curly) close - writeln(line); - } - type["blocks"] = TriState.closing; - type["quote"] = TriState.closing; - type["curly_quote"] = TriState.off; - } else { - debug(quote) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) - } - } else if (type["tic_quote"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(quote) { // quote (tic) close - writeln(line); - } - type["blocks"] = TriState.closing; - type["quote"] = TriState.closing; - type["tic_quote"] = TriState.off; - } else { - debug(quote) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) - } - } -} -#+END_SRC - ***** table block :table: #+name: abs_functions_block_table #+BEGIN_SRC d -void _table_block_(L,O,T)( +void _table_block_(L,O,T,Ma)( return ref L line, return ref O an_object, - return ref T type + return ref T type, + return ref Ma dochead_make_aa ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -3093,6 +3115,27 @@ void _table_block_(L,O,T)( } an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) } + } else if (type["curly_table_special_markup"] == TriState.on) { + if (line.empty) { + type["blocks"] = TriState.off; + type["table"] = TriState.off; + type["curly_table_special_markup"] = TriState.off; + _table_closed_make_special_notation_table_( + line, + an_object, + the_document_body_section, + obj_cite_number, + comp_obj_heading, + cntr, + type, + dochead_make_aa + ); + } else { + debug(table) { + writeln(line); + } + an_object[an_object_key] ~= line ~= "\n"; + } } else if (type["tic_table"] == TriState.on) { if (line.matchFirst(rgx.block_tic_close)) { debug(table) { // table (tic) close @@ -3111,9 +3154,56 @@ void _table_block_(L,O,T)( } #+END_SRC -**** block end (close an open block): line empty, block flag :close: +**** special table notation, make: table + +process and use an_object["table_head"] (then empty it) +- present table header info in uniform way + - table_number_of_columns, int (count) + - table_column_widths, int[] column widths (as given or calculate average) + - show table walls, bool + +#+name: abs_functions_block_line_status_empty +#+BEGIN_SRC d +void _table_closed_make_special_notation_table_( + char[] line, + return ref string[string] an_object, + return ref ObjGenericComposite[] the_document_body_section, + return ref int obj_cite_number, + return ref ObjGenericComposite _comp_obj_heading, + return ref int cntr, + return ref int[string] type, + string[string][string] dochead_make_aa, +) { + comp_obj_block = comp_obj_block.init; + obj_cite_number = + ocn_emit(type["ocn_status"]); + auto comp_obj_location = + node_construct.node_location_emitter( + content_non_header, + segment_anchor_tag_that_object_belongs_to, + obj_cite_number, + cntr, + heading_ptr-1, + "table" + ); + an_object["is"] = "table"; + auto substantive_obj_misc_tuple = + obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", dochead_make_aa); + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block.ocn = obj_cite_number; + comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); + the_document_body_section ~= comp_obj_block; + object_reset(an_object); + processing.remove("verse"); + ++cntr; +} +#+END_SRC + +**** block end (close an open block): line empty, block flag _makes_ :close: -***** { line empty, make block +***** { line empty, _make block_ #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d @@ -3142,11 +3232,11 @@ void _block_flag_line_empty_(B)( assertions_flag_types_block_status_none_or_closed(type); #+END_SRC -***** make: group block +***** make: quote block #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d - if (type["group"] == TriState.closing) { + if (type["quote"] == TriState.closing) { obj_cite_number = ocn_emit(type["ocn_status"]); an_object["bookindex_nugget"] = @@ -3157,7 +3247,7 @@ void _block_flag_line_empty_(B)( obj_cite_number, segment_anchor_tag_that_object_belongs_to ); - an_object["is"] = "group"; + an_object["is"] = "quote"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3174,7 +3264,7 @@ void _block_flag_line_empty_(B)( comp_obj_block = comp_obj_block.init; comp_obj_block.use = "body"; comp_obj_block.is_of = "block"; - comp_obj_block.is_a = "group"; + comp_obj_block.is_a = "quote"; comp_obj_block.ocn = obj_cite_number; comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; comp_obj_block.text = an_object["substantive"]; @@ -3183,18 +3273,19 @@ void _block_flag_line_empty_(B)( comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; type["blocks"] = TriState.off; - type["group"] = TriState.off; + type["table"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; #+END_SRC -***** make: block +***** make: group block #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d - } else if (type["block"] == TriState.closing) { - obj_cite_number = ocn_emit(type["ocn_status"]); + } else if (type["group"] == TriState.closing) { + obj_cite_number = + ocn_emit(type["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = @@ -3203,7 +3294,7 @@ void _block_flag_line_empty_(B)( obj_cite_number, segment_anchor_tag_that_object_belongs_to ); - an_object["is"] = "block"; + an_object["is"] = "group"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3212,7 +3303,7 @@ void _block_flag_line_empty_(B)( cntr, heading_ptr-1, an_object["is"] - ); + ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; @@ -3220,7 +3311,7 @@ void _block_flag_line_empty_(B)( comp_obj_block = comp_obj_block.init; comp_obj_block.use = "body"; comp_obj_block.is_of = "block"; - comp_obj_block.is_a = "block"; + comp_obj_block.is_a = "group"; comp_obj_block.ocn = obj_cite_number; comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; comp_obj_block.text = an_object["substantive"]; @@ -3229,19 +3320,18 @@ void _block_flag_line_empty_(B)( comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; type["blocks"] = TriState.off; - type["block"] = TriState.off; + type["group"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; #+END_SRC -***** make: code block +***** make: block #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d - } else if (type["code"] == TriState.closing) { - obj_cite_number = - ocn_emit(type["ocn_status"]); + } else if (type["block"] == TriState.closing) { + obj_cite_number = ocn_emit(type["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = @@ -3250,7 +3340,7 @@ void _block_flag_line_empty_(B)( obj_cite_number, segment_anchor_tag_that_object_belongs_to ); - an_object["is"] = "code"; + an_object["is"] = "block"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3259,24 +3349,24 @@ void _block_flag_line_empty_(B)( cntr, heading_ptr-1, an_object["is"] - ); + ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; - comp_obj_code = comp_obj_code.init; - comp_obj_code.use = "body"; - comp_obj_code.is_of = "block"; - comp_obj_code.is_a = "code"; - comp_obj_code.ocn = obj_cite_number; - comp_obj_code.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; - comp_obj_code.text = an_object["substantive"]; - comp_obj_code.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_code.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_code.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_code; + comp_obj_block = comp_obj_block.init; + comp_obj_block.use = "body"; + comp_obj_block.is_of = "block"; + comp_obj_block.is_a = "block"; + comp_obj_block.ocn = obj_cite_number; + comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; type["blocks"] = TriState.off; - type["code"] = TriState.off; + type["block"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3295,7 +3385,7 @@ void _block_flag_line_empty_(B)( obj_cite_number, segment_anchor_tag_that_object_belongs_to ); - an_object["is"] = "verse"; // check also + an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3319,11 +3409,11 @@ void _block_flag_line_empty_(B)( processing.remove("verse"); #+END_SRC -***** make: quote block +***** make: code block #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d - } else if (type["quote"] == TriState.closing) { + } else if (type["code"] == TriState.closing) { obj_cite_number = ocn_emit(type["ocn_status"]); an_object["bookindex_nugget"] = @@ -3334,7 +3424,7 @@ void _block_flag_line_empty_(B)( obj_cite_number, segment_anchor_tag_that_object_belongs_to ); - an_object["is"] = "quote"; + an_object["is"] = "code"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, @@ -3345,25 +3435,25 @@ void _block_flag_line_empty_(B)( an_object["is"] ); auto substantive_obj_misc_tuple = - obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); // ... - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; // ... + obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.use = "body"; - comp_obj_block.is_of = "block"; - comp_obj_block.is_a = "quote"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_code = comp_obj_code.init; + comp_obj_code.use = "body"; + comp_obj_code.is_of = "block"; + comp_obj_code.is_a = "code"; + comp_obj_code.ocn = obj_cite_number; + comp_obj_code.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_code.text = an_object["substantive"]; + comp_obj_code.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_code.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_code.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_code; + type["blocks"] = TriState.off; + type["code"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; - type["blocks"] = TriState.off; - type["quote"] = TriState.off; #+END_SRC ***** make: table @@ -3371,6 +3461,7 @@ void _block_flag_line_empty_(B)( #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d } else if (type["table"] == TriState.closing) { + comp_obj_block = comp_obj_block.init; obj_cite_number = ocn_emit(type["ocn_status"]); an_object["bookindex_nugget"] = @@ -3394,17 +3485,11 @@ void _block_flag_line_empty_(B)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; comp_obj_block = comp_obj_block.init; - comp_obj_block.use = "body"; - comp_obj_block.is_of = "block"; - comp_obj_block.is_a = "table"; comp_obj_block.ocn = obj_cite_number; comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); the_document_body_section ~= comp_obj_block; type["blocks"] = TriState.off; type["table"] = TriState.off; @@ -3899,6 +3984,242 @@ auto font_faces_line(T)( } #+END_SRC +**** tables + +- number of columns +- column widths (either as given or uniform, first often different from rest) +- column aligns (as given else default left for text, check whether can default right for digits) +- table heading (auto align left) +- table walls +- TODO need to be able to align columns left or right (digits) + +***** table instructions + +#+name: abs_functions_table +#+BEGIN_SRC d +auto table_instructions(O,H)( + return ref O table_object, + return ref H table_head, +) { + auto rgx = Rgx(); + table_object.use = "body"; + table_object.is_of = "block"; + table_object.is_a = "table"; + table_object.inline_notes_reg = false; + table_object.inline_notes_star = false; + table_object.inline_links = false; + if (auto m = table_head.matchFirst(rgx.table_head_instructions)) { + table_object.table_heading = ((m["c_heading"].length > 0) && (m["c_heading"] == "h")) ? true : false; + table_object.table_number_of_columns = ((m["c_num"].length > 0) && (m["c_num"].to!int > 0)) ? m["c_num"].to!int : 0; // double check, may be obsolete + foreach (cw; m["c_widths"].matchAll(rgx.table_col_widths)) { + auto x = cw.hit.matchFirst(rgx.table_col_widths_and_alignment); + table_object.table_column_widths ~= x["width"].to!int; + table_object.table_column_aligns ~= (x["align"].empty) ? "" : x["align"]; + } + } + return table_object; +} +#+END_SRC + +***** table array munge + +#+name: abs_functions_table +#+BEGIN_SRC d +auto table_array_munge(O,T)( + return ref O table_object, + return ref T table_array, +) { + auto rgx = Rgx(); + auto mng = InlineMarkup(); + string _table_substantive; + ulong col_num; + ulong col_num_; + ulong col_num_chk = 0; + foreach(idx_r, row; table_array) { + debug(table_dev) { + writeln("row ", idx_r); + } + col_num_ = 0; + if (col_num == 0 + || col_num < row.length) { + col_num = row.length; + } + if (col_num_chk == 0) { + col_num_chk = col_num; + } else if (col_num == 1) { + debug(table_dev) { + writeln("table note: "); + } + } else if (col_num_chk != col_num) { + debug(table_dev) { + writeln("warning irregular number of columns: ", col_num_chk, " != ", col_num); + } + } else { + } + foreach(idx_c, col; row) { + debug(table_dev) { + write(idx_c, ", "); + } + col_num_ = idx_c; + _table_substantive ~= col ~ mng.tc_s; + if (idx_r == 0 && comp_obj_block.table_heading) { + } else if (idx_r == 1 && col.match(rgx.numeric_col)) { + if ((comp_obj_block.table_column_aligns.length > idx_c) + && (comp_obj_block.table_column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { + comp_obj_block.table_column_aligns[idx_c] + = comp_obj_block.table_column_aligns[idx_c]; + } else if (comp_obj_block.table_column_aligns.length > idx_c) { + comp_obj_block.table_column_aligns[idx_c] = "r"; + } else { + comp_obj_block.table_column_aligns ~= "r"; + } + } else if (idx_r == 1) { + if ((comp_obj_block.table_column_aligns.length > idx_c) + && (comp_obj_block.table_column_aligns[idx_c].matchFirst(rgx.table_col_align_match))) { + comp_obj_block.table_column_aligns[idx_c] + = comp_obj_block.table_column_aligns[idx_c]; + } else if (comp_obj_block.table_column_aligns.length > idx_c) { + comp_obj_block.table_column_aligns[idx_c] = "l"; + } else { + comp_obj_block.table_column_aligns ~= "l"; + } + } + } + debug(table_dev) { + writeln(""); + } + if (col_num_chk > 0 && (col_num != col_num_chk)) { + } else if (col_num == col_num_chk){ + } else { + col_num_chk = col_num; + } + _table_substantive = _table_substantive.replaceFirst(rgx.table_col_separator_nl, "\n"); + } + if (comp_obj_block.table_number_of_columns != col_num) { + if (comp_obj_block.table_number_of_columns == 0) { + comp_obj_block.table_number_of_columns = (col_num).to!int; + } else { + debug(table_dev) { + writeln(comp_obj_block.table_number_of_columns, " != ", col_num); + } + } + } + if (table_object.table_number_of_columns == 0 + && table_object.table_column_widths.length > 0) { + writeln(__LINE__, " ERROR"); + } + if (table_object.table_number_of_columns > 0 + && table_object.table_column_widths.length == 0) { + double col_w = (100.00 / table_object.table_number_of_columns); + foreach (i; 0..table_object.table_number_of_columns) { + table_object.table_column_widths ~= col_w; + } + } else if (table_object.table_number_of_columns + != table_object.table_column_widths.length) { + debug(table_dev) { + writeln(m.hit); // further logic required + } + if (table_object.table_number_of_columns > table_object.table_column_widths.length) { + double col_w = (100.00 - (table_object.table_column_widths).sum) + / (table_object.table_number_of_columns - table_object.table_column_widths.length); + foreach (i; 0..table_object.table_column_widths.length) { + table_object.table_column_widths ~= col_w; + } + foreach (i; 0..(table_object.table_number_of_columns - table_object.table_column_widths.length)) { + table_object.table_column_widths ~= col_w; + } + } else if (table_object.table_number_of_columns < table_object.table_column_widths.length) { + writeln(__LINE__, " warning, ERROR"); + } + } + if (table_object.table_column_widths.sum > 101 + || table_object.table_column_widths.sum < 95 ) { + writeln("sum: ", table_object.table_column_widths.sum, + ", array: ", table_object.table_column_widths, + ", cols: ", table_object.table_number_of_columns); + writeln(_table_substantive); + } + debug(table_res) { + writeln("aligns: ", comp_obj_block.table_column_aligns, "\n", + "no. of columns: ", comp_obj_block.table_number_of_columns, "\n", + "col widths: ", comp_obj_block.table_column_widths, + " sum: ", comp_obj_block.table_column_widths.sum, "\n", + _table_substantive); + } + comp_obj_block.text = _table_substantive; + return table_object; +} +#+END_SRC + +****** table array munge simple open & close + +#+name: abs_functions_table +#+BEGIN_SRC d +auto table_array_munge_open_close(O,T)( + return ref O table_object, + return ref T table_array, +) { + auto rgx = Rgx(); + auto mng = InlineMarkup(); + string _table_substantive; + foreach(row; table_array) { + foreach(col; row) { + _table_substantive ~= mng.tc_o ~ col ~ mng.tc_c; + } + _table_substantive ~= "\n"; + } + debug(table_dev) { + writeln(_table_substantive); + } + comp_obj_block.text = _table_substantive; + return table_object; +} +#+END_SRC + +***** table substantive munge + +#+name: abs_functions_table +#+BEGIN_SRC d +auto table_substantive_munge(O,T)( + return ref O table_object, + return ref T table_substantive, +) { + auto rgx = Rgx(); + auto munge = ObjInlineMarkupMunge(); + string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter); + string[] _table_cols; + string[][] _table; + foreach(col; _table_rows) { + _table_cols = col.split(rgx.table_col_delimiter); + _table ~= _table_cols; + } + table_object = table_array_munge(table_object, _table); + return table_object; +} +#+END_SRC + +***** table substantive munge special + +#+name: abs_functions_table +#+BEGIN_SRC d +auto table_substantive_munge_special(O,T)( + return ref O table_object, + return ref T table_substantive, +) { + auto rgx = Rgx(); + auto munge = ObjInlineMarkupMunge(); + string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter_special); + string[] _table_cols; + string[][] _table; + foreach(col; _table_rows) { + _table_cols = col.split(rgx.table_col_delimiter_special); + _table ~= _table_cols; + } + table_object = table_array_munge(table_object, _table); + return table_object; +} +#+END_SRC + *** function emitters :emitters: **** object :object: ***** ocn :ocn: @@ -4088,10 +4409,11 @@ struct ObjInlineMarkupMunge { rgx.inline_notes_curly_sp_asterisk, (mkup.en_a_o ~ "*" ~ " $1" ~ mkup.en_a_c) ); - obj_txt_in = obj_txt_in.replaceAll( - rgx.inline_notes_curly_sp_plus, - (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) - ); + obj_txt_in = + obj_txt_in.replaceAll( + rgx.inline_notes_curly_sp_plus, + (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) + ); /+ url matched +/ if (obj_txt_in.match(rgx.inline_url)) { urls = true; @@ -4189,6 +4511,24 @@ struct ObjInlineMarkupMunge { } #+END_SRC +****** quote + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d + string munge_quote(Ot)(Ot obj_txt_in) + in { + debug(asserts) { + static assert(is(typeof(obj_txt_in) == string)); + } + } + body { + obj_txt["munge"]=obj_txt_in; + return obj_txt["munge"]; + } + invariant() { + } +#+END_SRC + ****** group - group block identified by open an close tags - general markup @@ -4280,7 +4620,7 @@ struct ObjInlineMarkupMunge { } } body { - obj_txt_in = (obj_txt_in).replaceAll(rgx.two_spaces, mkup.nbsp ~ mkup.nbsp); + obj_txt_in = (obj_txt_in).replaceAll(rgx.space, mkup.nbsp); obj_txt["munge"] = obj_txt_in; return obj_txt["munge"]; } @@ -4308,24 +4648,6 @@ struct ObjInlineMarkupMunge { } #+END_SRC -****** quote - -#+name: ao_emitters_obj_inline_markup_munge -#+BEGIN_SRC d - string munge_quote(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt["munge"]=obj_txt_in; - return obj_txt["munge"]; - } - invariant() { - } -#+END_SRC - ****** comment #+name: ao_emitters_obj_inline_markup_munge @@ -5044,11 +5366,11 @@ struct ObjAttributes { } #+END_SRC -******** group +******** quote #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _group(Ot)(Ot obj_txt_in) + string _quote(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5057,18 +5379,18 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"group\""; + ~ " \"is\": \"quote\""; return _obj_attributes; } invariant() { } #+END_SRC -******** block +******** group #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _block(Ot)(Ot obj_txt_in) + string _group(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5077,18 +5399,18 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"block\""; + ~ " \"is\": \"group\""; return _obj_attributes; } invariant() { } #+END_SRC -******** verse +******** block #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _verse(Ot)(Ot obj_txt_in) + string _block(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5097,18 +5419,18 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"verse\""; + ~ " \"is\": \"block\""; return _obj_attributes; } invariant() { } #+END_SRC -******** code +******** verse #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _code(Ot)(Ot obj_txt_in) + string _verse(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5117,18 +5439,18 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"code\""; + ~ " \"is\": \"verse\""; return _obj_attributes; } invariant() { } #+END_SRC -******** table +******** code #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _table(Ot)(Ot obj_txt_in) + string _code(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5137,18 +5459,18 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"table\""; + ~ " \"is\": \"code\""; return _obj_attributes; } invariant() { } #+END_SRC -******** quote +******** table #+name: ao_emitters_obj_attributes_private_an_attribute #+BEGIN_SRC d - string _quote(Ot)(Ot obj_txt_in) + string _table(Ot)(Ot obj_txt_in) in { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); @@ -5157,7 +5479,7 @@ struct ObjAttributes { body { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," - ~ " \"is\": \"quote\""; + ~ " \"is\": \"table\""; return _obj_attributes; } invariant() { @@ -6435,7 +6757,13 @@ struct ObjGenericComposite { bool inline_links = false; bool inline_notes_reg = false; bool inline_notes_star = false; - string syntax = ""; + string language = ""; // not implemented, consider + string code_block_syntax = ""; + int table_number_of_columns = 0; + double[] table_column_widths = []; + string[] table_column_aligns = []; + bool table_heading = false; + bool table_walls = false; // not implemented int ocn = 0; string segment_anchor_tag = ""; string segname_prev = ""; |