From e923c850c2a19640fa28b8663e5dabff57c47954 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 3 May 2019 09:18:27 -0400 Subject: block (grouped text) attributes (possibility) --- src/doc_reform/meta/metadoc_from_src.d | 62 +++++++++++++++++++++++++--------- src/doc_reform/meta/object_setter.d | 3 ++ 2 files changed, 49 insertions(+), 16 deletions(-) (limited to 'src/doc_reform') diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index f603ab8..c4c7365 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -2494,12 +2494,10 @@ template DocReformDocAbstraction() { static assert(is(typeof(object_number_poem) == string[string])); } static auto rgx = Rgx(); - string code_block_syntax = ""; - bool code_block_numbered = false; if (auto m = line.matchFirst(rgx.block_curly_code_open)) { - code_block_syntax = (m[1]) ? m[1].to!string : ""; - code_block_numbered = (m[2].matchFirst(rgx.code_numbering)) - ? true : false; + an_object["lang"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; debug(codecurly) { // code (curly) open writefln( "* [code curly] %s", @@ -2509,7 +2507,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["code"] = TriState.on; obj_type_status["curly_code"] = TriState.on; - } else if (line.matchFirst(rgx.block_curly_poem_open)) { + } else if (auto m = line.matchFirst(rgx.block_curly_poem_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(poem) { // poem (curly) open writefln( "* [poem curly] %s", @@ -2521,7 +2522,10 @@ template DocReformDocAbstraction() { obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; obj_type_status["curly_poem"] = TriState.on; - } else if (line.matchFirst(rgx.block_curly_group_open)) { + } else if (auto m = line.matchFirst(rgx.block_curly_group_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(group) { // group (curly) open writefln( "* [group curly] %s", @@ -2531,7 +2535,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["group"] = TriState.on; obj_type_status["curly_group"] = TriState.on; - } else if (line.matchFirst(rgx.block_curly_block_open)) { + } else if (auto m = line.matchFirst(rgx.block_curly_block_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(block) { // block (curly) open writefln( "* [block curly] %s", @@ -2541,7 +2548,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["block"] = TriState.on; obj_type_status["curly_block"] = TriState.on; - } else if (line.matchFirst(rgx.block_curly_quote_open)) { + } else if (auto m = line.matchFirst(rgx.block_curly_quote_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = m["attrib"].to!string; + an_object["lang"] = m["lang"].to!string; debug(quote) { // quote (curly) open writefln( "* [quote curly] %s", @@ -2570,9 +2580,9 @@ template DocReformDocAbstraction() { obj_type_status["table"] = TriState.on; obj_type_status["curly_table_special_markup"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { - code_block_syntax = (m[1]) ? m[1].to!string : ""; - code_block_numbered = (m[2].matchFirst(rgx.code_numbering)) - ? true : false; + an_object["lang"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; debug(codetic) { // code (tic) open writefln( "* [code tic] %s", @@ -2582,7 +2592,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["code"] = TriState.on; obj_type_status["tic_code"] = TriState.on; - } else if (line.matchFirst(rgx.block_tic_poem_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_poem_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(poem) { // poem (tic) open writefln( "* [poem tic] %s", @@ -2594,7 +2607,10 @@ template DocReformDocAbstraction() { obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; obj_type_status["tic_poem"] = TriState.on; - } else if (line.matchFirst(rgx.block_tic_group_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_group_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(group) { // group (tic) open writefln( "* [group tic] %s", @@ -2604,7 +2620,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["group"] = TriState.on; obj_type_status["tic_group"] = TriState.on; - } else if (line.matchFirst(rgx.block_tic_block_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_block_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; + an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; debug(block) { // block (tic) open writefln( "* [block tic] %s", @@ -2614,7 +2633,10 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["block"] = TriState.on; obj_type_status["tic_block"] = TriState.on; - } else if (line.matchFirst(rgx.block_tic_quote_open)) { + } else if (auto m = line.matchFirst(rgx.block_tic_quote_open)) { + an_object["syntax"] = ""; + an_object["attrib"] = m["attrib"].to!string; + an_object["lang"] = m["lang"].to!string; debug(quote) { // quote (tic) open writefln( "* [quote tic] %s", @@ -3377,6 +3399,8 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.metainfo.lang = an_object["lang"]; + comp_obj_block.metainfo.attrib = an_object["attrib"]; comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_block.text = an_object["substantive"]; @@ -3426,6 +3450,8 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.metainfo.lang = an_object["lang"]; + comp_obj_block.metainfo.attrib = an_object["attrib"]; comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_block.text = an_object["substantive"]; @@ -3475,6 +3501,8 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.metainfo.lang = an_object["lang"]; + comp_obj_block.metainfo.attrib = an_object["attrib"]; comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_block.text = an_object["substantive"]; @@ -3560,6 +3588,8 @@ template DocReformDocAbstraction() { comp_obj_code.metainfo.object_number_off = obj_cite_digits.off; comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_code.metainfo.syntax = an_object["syntax"]; + comp_obj_code.metainfo.attrib = an_object["attrib"]; comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_code.text = an_object["substantive"]; diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index c675f9e..dac10da 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -14,6 +14,9 @@ template ObjectSetter() { alias of_part = is_of_part; alias of_section = is_of_section; alias is_of = is_of_type; + string attrib = ""; // TODO analyze attrib and subdivide here? + string lang = ""; // blocks: group, block, quote; not codeblock; TODO poem:verse not yet done + string syntax = ""; // codeblock only /+ o_n +/ int o_n_substantive = 0; int o_n_non_substantive = 0; -- cgit v1.2.3