diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-05-02 21:45:58 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-05-19 19:26:29 -0400 |
commit | e8186088585cd04a791c0be89b5c08db8130b3b1 (patch) | |
tree | 866d1a4f54d1ade412f15f687adb7be45c991281 /src/doc_reform/meta/metadoc_from_src.d | |
parent | url encoding (diff) |
cosmetic mostly
Diffstat (limited to 'src/doc_reform/meta/metadoc_from_src.d')
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 325 |
1 files changed, 110 insertions, 215 deletions
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 585306d..a057ec7 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -461,9 +461,8 @@ template DocReformDocAbstraction() { } /+ ↓ ↻ loop markup document/text line by line +/ srcDocLoop: - foreach (line; markup_sourcefile_content) { + foreach (line; markup_sourcefile_content) { /+ ↓ markup document/text line by line +/ // "line" variable can be empty but should never be null - /+ ↓ markup document/text line by line +/ /+ scope +/ scope(exit) { } @@ -493,9 +492,8 @@ template DocReformDocAbstraction() { /+ block object: code +/ line.txt_block_code(an_object, obj_type_status); 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) +/ + } 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) @@ -724,25 +722,25 @@ template DocReformDocAbstraction() { tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = line.to!string; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.identifier = ""; - comp_obj_heading_.metainfo.dummy_heading = false; - comp_obj_heading_.metainfo.object_number_off = true; - comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = line.to!string; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.identifier = ""; + comp_obj_heading_.metainfo.dummy_heading = false; + comp_obj_heading_.metainfo.object_number_off = true; + comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb"; comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; - comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv - comp_obj_heading_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv + comp_obj_heading_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + the_blurb_section ~= comp_obj_heading_; tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { @@ -766,41 +764,37 @@ template DocReformDocAbstraction() { obj_type_status["ocn_status"] = OCNstatus.on; } continue; - } else if (obj_type_status["quote"] == TriState.on) { - /+ within block object: quote +/ - line = line._doc_header_and_make_substitutions_(conf_make_meta); - line = line._doc_header_and_make_substitutions_fontface_(conf_make_meta); + } else if (obj_type_status["quote"] == TriState.on) { /+ within block object: quote +/ + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); line.txt_block_quote(an_object, obj_type_status); continue; /+ within block object: group +/ - } else if (obj_type_status["group"] == TriState.on) { - /+ within block object: group +/ - line = line._doc_header_and_make_substitutions_(conf_make_meta); - line = line._doc_header_and_make_substitutions_fontface_(conf_make_meta); + } else if (obj_type_status["group"] == TriState.on) { /+ within block object: group +/ line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta) .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); line.txt_block_group(an_object, obj_type_status); continue; - } else if (obj_type_status["block"] == TriState.on) { - /+ within block object: block +/ - line = line._doc_header_and_make_substitutions_(conf_make_meta); - line = line._doc_header_and_make_substitutions_fontface_(conf_make_meta); + } else if (obj_type_status["block"] == TriState.on) { /+ within block object: block +/ + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); if (auto m = line.match(rgx.spaces_keep)) { line = line .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); } line.txt_block_block(an_object, obj_type_status); continue; - } else if (obj_type_status["poem"] == TriState.on) { - /+ within block object: poem +/ + } else if (obj_type_status["poem"] == TriState.on) { /+ within block object: poem +/ line.txt_block_poem(an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, tag_in_seg); continue; - } else if (obj_type_status["table"] == TriState.on) { - /+ within block object: table +/ + } else if (obj_type_status["table"] == TriState.on) { /+ within block object: table +/ line.txt_block_table(an_object, obj_type_status, conf_make_meta); continue; - } else { - /+ not within a block group +/ + } else { /+ not within a block group +/ assert( (obj_type_status["blocks"] == TriState.off) || (obj_type_status["blocks"] == TriState.closing), @@ -808,16 +802,14 @@ template DocReformDocAbstraction() { ); assertions_flag_types_block_status_none_or_closed(obj_type_status); 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; } line.txt_block_start(obj_type_status, object_number_poem); continue; - } else if (!line.empty) { - /+ line not empty +/ + } else if (!line.empty) { /+ line not empty +/ /+ non blocks (headings, paragraphs) & closed blocks +/ assert( !line.empty, @@ -829,7 +821,7 @@ template DocReformDocAbstraction() { "code block status: none or closed" ); if (obj_type_status["blocks"] == TriState.closing) { - debug(check) { // block + debug(check) { writeln(__LINE__); writeln(line); } @@ -843,14 +835,11 @@ template DocReformDocAbstraction() { } if (line.matchFirst(rgx.book_index) || line.matchFirst(rgx.book_index_open) - || obj_type_status["book_index"] == State.on ) { - /+ book_index +/ + || obj_type_status["book_index"] == State.on ) { /+ book_index +/ line._book_index_(book_idx_tmp, an_object, obj_type_status, opt_action); - } 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); } @@ -868,19 +857,16 @@ template DocReformDocAbstraction() { } else if (((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((obj_type_status["para"] == State.off) - && (obj_type_status["heading"] == State.off))) { - /+ heading or para but neither flag nor line exists +/ + && (obj_type_status["heading"] == State.off))) { /+ heading or para but neither flag nor line exists +/ if ((conf_make_meta.make.headings.length > 2) - && (obj_type_status["make_headings"] == State.off)) { - /+ heading found +/ + && (obj_type_status["make_headings"] == State.off)) { /+ heading found +/ line._heading_found_(conf_make_meta.make.headings, heading_match_str, heading_match_rgx, obj_type_status); } if ((obj_type_status["make_headings"] == State.on) && ((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((obj_type_status["para"] == State.off) - && (obj_type_status["heading"] == State.off))) { - /+ heading make set +/ + && (obj_type_status["heading"] == State.off))) { /+ heading make set +/ line = line._heading_make_set_(line_occur, heading_match_rgx, obj_type_status); } /+ TODO node info: all headings identified at this point, @@ -889,37 +875,34 @@ template DocReformDocAbstraction() { - should be incorporated in composite objects - should happen before endnote links set (they need to be moved down?) +/ - if (line.matchFirst(rgx.heading)) { - /+ heading match +/ + if (line.matchFirst(rgx.heading)) { /+ heading match +/ line = line._doc_header_and_make_substitutions_(conf_make_meta); line._heading_matched_(line_occur, an_object, an_object_key, lv, collapsed_lev, obj_type_status, conf_make_meta); - } else if (line_occur["para"] == State.off) { - /+ para match +/ + } else if (line_occur["para"] == State.off) { /+ para match +/ an_object_key="body_nugget"; - line = line._doc_header_and_make_substitutions_(conf_make_meta); - line = line._doc_header_and_make_substitutions_fontface_(conf_make_meta); + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); line._para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); } - } else if (line_occur["heading"] > State.off) { - /+ heading +/ + } else if (line_occur["heading"] > State.off) { /+ heading +/ debug(heading) { writeln(line); } an_object[an_object_key] ~= line ~= "\n"; ++line_occur["heading"]; - } else if (line_occur["para"] > State.off) { - /+ paragraph +/ + } else if (line_occur["para"] > State.off) { /+ paragraph +/ debug(para) { writeln(an_object_key, "-> ", line); } - line = line._doc_header_and_make_substitutions_(conf_make_meta); - line = line._doc_header_and_make_substitutions_fontface_(conf_make_meta); + line = line + ._doc_header_and_make_substitutions_(conf_make_meta) + ._doc_header_and_make_substitutions_fontface_(conf_make_meta); an_object[an_object_key] ~= " " ~ line; ++line_occur["para"]; } } - } else if (obj_type_status["blocks"] == TriState.closing) { - /+ line empty, with blocks flag +/ + } else if (obj_type_status["blocks"] == TriState.closing) { /+ line empty, with blocks flag +/ _block_flag_line_empty_( bookindex_extract_hash, line, @@ -934,8 +917,7 @@ template DocReformDocAbstraction() { conf_make_meta, tag_in_seg, ); - } else { - /+ line.empty, post contents, empty variables: +/ + } else { /+ line.empty, post contents, empty variables: +/ assert( line.empty, "\nline should be empty:\n \"" @@ -951,8 +933,7 @@ template DocReformDocAbstraction() { tag_in_seg = tag_in_seg.init; } if ((obj_type_status["heading"] == State.on) - && (line_occur["heading"] > State.off)) { - /+ heading object (current line empty) +/ + && (line_occur["heading"] > State.off)) { /+ heading object (current line empty) +/ obj_cite_digits = (an_object["lev_markup_number"].to!int == 0) ? ocn_emit(OCNstatus.reset) : ocn_emit(obj_type_status["ocn_status"]); @@ -993,7 +974,7 @@ template DocReformDocAbstraction() { tag_assoc[anchor_tag]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; } 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; @@ -1123,7 +1104,7 @@ template DocReformDocAbstraction() { comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; comp_obj_para.has.image_without_dimensions = substantive_obj_misc_tuple[sObj.image_no_dimensions]; the_document_body_section ~= comp_obj_para; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); _common_reset_(line_occur, an_object, obj_type_status); indent=[ "hang_position" : 0, @@ -1149,12 +1130,11 @@ template DocReformDocAbstraction() { && (the_document_body_section.length > previous_length)) { if ((the_document_body_section[$-1].metainfo.is_a == "heading") && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) { - obj_type_status["biblio_section"] = State.off; obj_type_status["glossary_section"] = State.off; + obj_type_status["biblio_section"] = State.off; obj_type_status["blurb_section"] = State.off; } - 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( @@ -1168,8 +1148,7 @@ template DocReformDocAbstraction() { } } } - } 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_regular_number_note @@ -1185,7 +1164,7 @@ template DocReformDocAbstraction() { previous_length = the_document_body_section.length.to!int; } } - } /+ ← srcDocLoop closed: loop markup document/text line by line +/ + } /+ ← srcDocLoop closed: loop markup document/text line by line +/ /+ ↓ post loop markup document/text +/ auto en_tuple = note_section.endnote_objects(obj_cite_digits, opt_action); @@ -2066,8 +2045,7 @@ template DocReformDocAbstraction() { int ocn_ = obj_cite_digits.object_number; int ocn_bkidx_ = 0; int ocn_bidx_; - if (the_bookindex_section.length > 1) { - /+ scroll +/ + if (the_bookindex_section.length > 1) { /+ scroll +/ dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_bookindex_section) { @@ -2367,7 +2345,7 @@ template DocReformDocAbstraction() { ); return t; /+ post loop markup document/text ↑ +/ - } /+ ← closed: abstract doc source +/ + } /+ ← closed: abstract doc source +/ /+ ↓ abstraction functions +/ static auto object_reset(O)(O an_object) { debug(asserts) { @@ -2394,7 +2372,7 @@ template DocReformDocAbstraction() { line_occur["para"] = State.off; obj_type_status["heading"] = State.off; obj_type_status["para"] = State.off; - an_object = object_reset(an_object); + an_object = an_object.object_reset; } static auto _check_ocn_status_(L,T)( L line, @@ -2405,13 +2383,11 @@ template DocReformDocAbstraction() { static assert(is(typeof(obj_type_status) == int[string])); } static auto rgx = Rgx(); - if ( - !(line.empty) + if (!(line.empty) && (obj_type_status["ocn_status_off_for_multiple_objects"] == OCN_off_block_status.off) ) { /+ not multi-line object, check whether object_number is on or turned off +/ - if (line.matchFirst(rgx.object_number_block_marks)) { - /+ switch off object_number +/ + if (line.matchFirst(rgx.object_number_block_marks)) { /+ switch off object_number +/ if (line.matchFirst(rgx.object_number_off_block)) { obj_type_status["ocn_status_off_for_multiple_objects"] = OCN_off_block_status.on; obj_type_status["ocn_status"] = OCNstatus.off; @@ -2521,7 +2497,6 @@ template DocReformDocAbstraction() { 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[1]) ? m[1].to!string : ""; code_block_numbered = (m[2].matchFirst(rgx.code_numbering)) ? true : false; @@ -2535,7 +2510,6 @@ template DocReformDocAbstraction() { obj_type_status["code"] = TriState.on; obj_type_status["curly_code"] = TriState.on; } else if (line.matchFirst(rgx.block_curly_poem_open)) { - /+ curly poem open +/ debug(poem) { // poem (curly) open writefln( "* [poem curly] %s", @@ -2548,7 +2522,6 @@ template DocReformDocAbstraction() { obj_type_status["poem"] = TriState.on; obj_type_status["curly_poem"] = TriState.on; } else if (line.matchFirst(rgx.block_curly_group_open)) { - /+ curly group open +/ debug(group) { // group (curly) open writefln( "* [group curly] %s", @@ -2559,7 +2532,6 @@ template DocReformDocAbstraction() { obj_type_status["group"] = TriState.on; obj_type_status["curly_group"] = TriState.on; } else if (line.matchFirst(rgx.block_curly_block_open)) { - /+ curly block open +/ debug(block) { // block (curly) open writefln( "* [block curly] %s", @@ -2570,7 +2542,6 @@ template DocReformDocAbstraction() { obj_type_status["block"] = TriState.on; obj_type_status["curly_block"] = TriState.on; } else if (line.matchFirst(rgx.block_curly_quote_open)) { - /+ curly quote open +/ debug(quote) { // quote (curly) open writefln( "* [quote curly] %s", @@ -2580,8 +2551,7 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["quote"] = TriState.on; obj_type_status["curly_quote"] = TriState.on; - } else if (auto m = line.matchFirst(rgx.block_curly_table_open)) { - /+ curly table open +/ + } else if (auto m = line.matchFirst(rgx.block_curly_table_open)) { /+ curly table open +/ debug(table) { // table (curly) open writefln( "* [table curly] %s", @@ -2593,15 +2563,13 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["table"] = TriState.on; obj_type_status["curly_table"] = TriState.on; - } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { - /+ table: special table block markup syntax! +/ + } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { /+ table: special table block markup syntax! +/ an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "special"; obj_type_status["blocks"] = TriState.on; 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)) { - /+ tic code open +/ code_block_syntax = (m[1]) ? m[1].to!string : ""; code_block_numbered = (m[2].matchFirst(rgx.code_numbering)) ? true : false; @@ -2615,7 +2583,6 @@ template DocReformDocAbstraction() { obj_type_status["code"] = TriState.on; obj_type_status["tic_code"] = TriState.on; } else if (line.matchFirst(rgx.block_tic_poem_open)) { - /+ tic poem open +/ debug(poem) { // poem (tic) open writefln( "* [poem tic] %s", @@ -2628,7 +2595,6 @@ template DocReformDocAbstraction() { obj_type_status["poem"] = TriState.on; obj_type_status["tic_poem"] = TriState.on; } else if (line.matchFirst(rgx.block_tic_group_open)) { - /+ tic group open +/ debug(group) { // group (tic) open writefln( "* [group tic] %s", @@ -2639,7 +2605,6 @@ template DocReformDocAbstraction() { obj_type_status["group"] = TriState.on; obj_type_status["tic_group"] = TriState.on; } else if (line.matchFirst(rgx.block_tic_block_open)) { - /+ tic block open +/ debug(block) { // block (tic) open writefln( "* [block tic] %s", @@ -2650,7 +2615,6 @@ template DocReformDocAbstraction() { obj_type_status["block"] = TriState.on; obj_type_status["tic_block"] = TriState.on; } else if (line.matchFirst(rgx.block_tic_quote_open)) { - /+ tic quote open +/ debug(quote) { // quote (tic) open writefln( "* [quote tic] %s", @@ -2660,8 +2624,7 @@ template DocReformDocAbstraction() { obj_type_status["blocks"] = TriState.on; obj_type_status["quote"] = TriState.on; obj_type_status["tic_quote"] = TriState.on; - } else if (auto m = line.matchFirst(rgx.block_tic_table_open)) { - /+ tic table open +/ + } else if (auto m = line.matchFirst(rgx.block_tic_table_open)) { /+ tic table open +/ debug(table) { // table (tic) open writefln( "* [table tic] %s", @@ -2863,16 +2826,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); } object_reset(an_object); processing.remove("verse"); @@ -2926,16 +2889,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -2972,16 +2935,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); object_number_poem["end"] = obj_cite_digits.object_number.to!string; object_reset(an_object); processing.remove("verse"); @@ -3035,16 +2998,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3100,8 +3063,8 @@ template DocReformDocAbstraction() { } } void txt_block_table(L,O,T,CMM)( - L line, - return ref O an_object, + L line, + return ref O an_object, return ref T obj_type_status, return ref CMM conf_make_meta, ) { @@ -3195,15 +3158,16 @@ template DocReformDocAbstraction() { auto jsn = BibJsnStr(); static auto rgx = Rgx(); if (line.matchFirst(rgx.heading_biblio) - && obj_type_status["para"] != State.on - && obj_type_status["group"] != State.on - && obj_type_status["block"] != State.on - && obj_type_status["poem"] != State.on - && obj_type_status["table"] != State.on - && obj_type_status["quote"] != State.on) { + && obj_type_status["para"] != State.on + && obj_type_status["group"] != State.on + && obj_type_status["block"] != State.on + && obj_type_status["poem"] != State.on + && obj_type_status["table"] != State.on + && obj_type_status["quote"] != State.on + ) { + obj_type_status["glossary_section"] = State.off; obj_type_status["biblio_section"] = TriState.on; obj_type_status["blurb_section"] = State.off; - obj_type_status["glossary_section"] = State.off; } if (line.empty) { debug { @@ -3411,16 +3375,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); obj_type_status["blocks"] = TriState.off; obj_type_status["quote"] = TriState.off; object_reset(an_object); @@ -3460,16 +3424,16 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); + tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc); obj_type_status["blocks"] = TriState.off; obj_type_status["group"] = TriState.off; object_reset(an_object); @@ -3509,10 +3473,10 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + 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"]; comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -3592,12 +3556,12 @@ template DocReformDocAbstraction() { comp_obj_code.metainfo.is_of_type = "block"; comp_obj_code.metainfo.is_a = "code"; comp_obj_code.metainfo.ocn = obj_cite_digits.object_number; - comp_obj_code.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_code.metainfo.identifier = obj_cite_digits.identifier; comp_obj_code.metainfo.object_number_off = obj_cite_digits.off; - 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.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; + 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"]; comp_obj_code.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_code.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -3666,8 +3630,7 @@ template DocReformDocAbstraction() { static assert(is(typeof(obj_type_status) == int[string])); } static auto rgx = Rgx(); - if (auto m = line.match(rgx.book_index)) { - /+ match book_index +/ + if (auto m = line.match(rgx.book_index)) { /+ match book_index +/ debug(bookindexmatch) { writefln( "* [bookindex] %s\n", @@ -3675,8 +3638,7 @@ template DocReformDocAbstraction() { ); } an_object["bookindex_nugget"] = m.captures[1].to!string; - } else if (auto m = line.match(rgx.book_index_open)) { - /+ match open book_index +/ + } else if (auto m = line.match(rgx.book_index_open)) { /+ match open book_index +/ obj_type_status["book_index"] = State.on; if (opt_action.backmatter && opt_action.section_bookindex) { book_idx_tmp = m.captures[1].to!string; @@ -3687,8 +3649,7 @@ template DocReformDocAbstraction() { ); } } - } else if (obj_type_status["book_index"] == State.on ) { - /+ book_index flag set +/ + } else if (obj_type_status["book_index"] == State.on ) { /+ book_index flag set +/ if (auto m = line.match(rgx.book_index_close)) { obj_type_status["book_index"] = State.off; if (opt_action.backmatter @@ -3726,8 +3687,7 @@ template DocReformDocAbstraction() { } static auto rgx = Rgx(); if ((_make_unmarked_headings.length > 2) - && (obj_type_status["make_headings"] == State.off)) { - /+ headings found +/ + && (obj_type_status["make_headings"] == State.off)) { /+ headings found +/ debug(headingsfound) { writeln(_make_unmarked_headings); } @@ -3814,8 +3774,7 @@ template DocReformDocAbstraction() { && ((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((obj_type_status["para"] == State.off) - && (obj_type_status["heading"] == State.off))) { - /+ heading make set +/ + && (obj_type_status["heading"] == State.off))) { /+ heading make set +/ if (line.matchFirst(heading_match_rgx["h_B"])) { line = "B~ " ~ line; debug(headingsfound) { @@ -3881,14 +3840,13 @@ template DocReformDocAbstraction() { static assert(is(typeof(obj_type_status) == int[string])); } static auto rgx = Rgx(); - if (auto m = line.match(rgx.heading)) { - /+ heading match +/ + if (auto m = line.match(rgx.heading)) { /+ heading match +/ ++line_occur["heading"]; obj_type_status["heading"] = State.on; obj_type_status["para"] = State.off; if (line.match(rgx.heading_seg_and_above)) { - obj_type_status["biblio_section"] = State.off; obj_type_status["glossary_section"] = State.off; + obj_type_status["biblio_section"] = State.off; obj_type_status["blurb_section"] = State.off; } an_object[an_object_key] ~= line ~= "\n"; @@ -4240,25 +4198,6 @@ template DocReformDocAbstraction() { comp_obj_block.text = _table_substantive; return table_object; } - auto table_array_munge_open_close(O,T)( - return ref O table_object, - return ref T table_array, - ) { - static auto rgx = Rgx(); - static 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; - } auto table_substantive_munge(O,T)( return ref O table_object, return ref T table_substantive, @@ -4363,7 +4302,7 @@ template DocReformDocAbstraction() { static auto mng = InlineMarkup(); /+ url matched +/ obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented - if (obj_txt_in.match(rgx.smid_image_generic)) { /+ images with and without links +/ + if (obj_txt_in.match(rgx.smid_image_generic)) { /+ images with and without links +/ debug(images) { writeln("Image: ", obj_txt_in); } @@ -5047,50 +4986,6 @@ template DocReformDocAbstraction() { } return munge_; } - unittest { - string txt_lev="1"; - string txt_in, txt_out; - - txt_in = "1~copyright Copyright"; - txt_out ="1~copyright Copyright"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in = "1~ 6. Writing Copyright Licenses"; - txt_out ="1~s6 6. Writing Copyright Licenses"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ 1. Reinforcing trends"; - txt_out= "1~s1 1. Reinforcing trends"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ 11 SCIENCE AS A COMMONS"; - txt_out= "1~s11 11 SCIENCE AS A COMMONS"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ Chapter 1"; - txt_out="1~chapter_1 Chapter 1"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ Chapter 1."; - txt_out="1~chapter_1 Chapter 1."; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ Chapter 1: Done"; - txt_out="1~chapter_1 Chapter 1: Done"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ Chapter 11 - The Battle Over the Institutional Ecology of the Digital Environment"; - txt_out= "1~chapter_11 Chapter 11 - The Battle Over the Institutional Ecology of the Digital Environment"; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ CHAPTER I."; - txt_out="1~x1 CHAPTER I."; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - - txt_in= "1~ CHAPTER II."; - txt_out="1~x2 CHAPTER II."; - assert(_make_segment_anchor_tags_if_none_provided(txt_in, txt_lev) == txt_out); - } } /+ +/ struct ObjAttributes { |