diff options
Diffstat (limited to 'src/sdp/meta')
-rw-r--r-- | src/sdp/meta/conf_make_meta_json.d | 607 | ||||
-rw-r--r-- | src/sdp/meta/conf_make_meta_structs.d | 328 | ||||
-rw-r--r-- | src/sdp/meta/conf_make_meta_toml.d | 77 | ||||
-rw-r--r-- | src/sdp/meta/defaults.d | 241 | ||||
-rw-r--r-- | src/sdp/meta/doc_debugs.d | 652 | ||||
-rw-r--r-- | src/sdp/meta/metadoc.d | 177 | ||||
-rw-r--r-- | src/sdp/meta/metadoc_from_src.d | 6322 | ||||
-rw-r--r-- | src/sdp/meta/metadoc_summary.d | 101 | ||||
-rw-r--r-- | src/sdp/meta/object_setter.d | 126 | ||||
-rw-r--r-- | src/sdp/meta/package.d | 17 | ||||
-rw-r--r-- | src/sdp/meta/rgx.d | 290 |
11 files changed, 0 insertions, 8938 deletions
diff --git a/src/sdp/meta/conf_make_meta_json.d b/src/sdp/meta/conf_make_meta_json.d deleted file mode 100644 index dbba9af..0000000 --- a/src/sdp/meta/conf_make_meta_json.d +++ /dev/null @@ -1,607 +0,0 @@ -/++ - json headers<BR> - extract json header return json -+/ -module sdp.meta.conf_make_meta_json; -static template contentJSONtoSiSUstruct() { - import - std.exception, - std.regex, - std.stdio, - std.string, - std.traits, - std.typecons, - std.utf, - std.conv : to; - import - sdp.meta.conf_make_meta_structs, - sdp.meta.conf_make_meta_json, - sdp.meta.rgx; - ConfCompositePlus _struct_composite; - auto contentJSONtoSiSUstruct(C, J)(C _struct_composite, J _json, string _identifier) { - mixin SiSUrgxInit; - static auto _rgx = Rgx(); - debug (json) { - writeln(">> --------------------------- >>"); - foreach (tag0; _json.object.byKeyValue) { - if (tag0.value.stringof == "string") { - writeln(tag0.key, ": ", tag0.value); - } else { - // writeln(tag0.key, ":"); - foreach (tag1; tag0.value.object.byKeyValue) { - writeln(tag0.key, ":", tag1.key, ": ", tag1.value); - } - } - } - writeln("<< --------------------------- <<"); - } - confCompositeMakeBuild _mk; - /+ make ------------------------------------------------------------------- +/ - if ("make" in _json.object) { - if ("bold" in _json.object["make"] - && (_json.object["make"]["bold"].type().to!string == "STRING") - ) { - _struct_composite.make_str.bold = _json.object["make"]["bold"].str; - } - if ("breaks" in _json.object["make"] - && (_json.object["make"]["breaks"].type().to!string == "STRING") - ) { - _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; - } - if ("cover_image" in _json.object["make"] - && (_json.object["make"]["cover_image"].type().to!string == "STRING") - ) { - _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; - } - if ("css" in _json.object["make"] - && (_json.object["make"]["css"].type().to!string == "STRING") - ) { - _struct_composite.make_str.css = _json.object["make"]["css"].str; - } - if ("emphasis" in _json.object["make"] - && (_json.object["make"]["emphasis"].type().to!string == "STRING") - ) { - _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; - } - if ("footer" in _json.object["make"] - && (_json.object["make"]["footer"].type().to!string == "STRING") - ) { - char[][] __match_footer_array - = (cast(char[]) _json.object["make"]["footer"].str) - .split(_rgx.make_heading_delimiter); - _struct_composite.make_str.footer = __match_footer_array.to!(string[]); - } else if ("footer" in _json.object["make"] - && _json.object["make"]["footer"].type().to!string == "ARRAY") { - string[] _match_footer_array; - foreach (_match_heading; _json.object["make"]["footer"].arrayNoRef) { - _match_footer_array ~= _match_heading.str; - } - _struct_composite.make_str.footer = _match_footer_array; - } - if ("headings" in _json.object["make"] - && (_json.object["make"]["headings"].type().to!string == "STRING") - ) { - char[][] __match_headings_array - = (cast(char[]) _json.object["make"]["headings"].str) - .split(_rgx.make_heading_delimiter); - _struct_composite.make_str.headings = __match_headings_array.to!(string[]); - } else if ("headings" in _json.object["make"] - && _json.object["make"]["headings"].type().to!string == "ARRAY") { - string[] _match_headings_array; - foreach (_match_heading; _json.object["make"]["headings"].arrayNoRef) { - _match_headings_array ~= _match_heading.str; - } - _struct_composite.make_str.headings = _match_headings_array; - } - if ("home_button_image" in _json.object["make"] - && (_json.object["make"]["home_button_image"].type().to!string == "STRING") - ) { - char[][] __match_home_button_image_array - = (cast(char[]) _json.object["make"]["home_button_image"].str) - .split(_rgx.make_heading_delimiter); - _struct_composite.make_str.home_button_image = __match_home_button_image_array.to!(string[]); - } else if ("home_button_image" in _json.object["make"] - && _json.object["make"]["home_button_image"].type().to!string == "ARRAY") { - string[] _match_home_button_image_array; - foreach (_match_heading; _json.object["make"]["home_button_image"].arrayNoRef) { - _match_home_button_image_array ~= _match_heading.str; - } - _struct_composite.make_str.home_button_image = _match_home_button_image_array; - } - if ("home_button_text" in _json.object["make"] - && (_json.object["make"]["home_button_text"].type().to!string == "STRING") - ) { - _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; - } else if ("home_button_text" in _json.object["make"] - && _json.object["make"]["home_button_text"].type().to!string == "ARRAY" - ) { - string[] _match_home_button_text_array; - foreach (_match_heading; _json.object["make"]["home_button_text"].arrayNoRef) { - _match_home_button_text_array ~= _match_heading.str; - } - string _match_home_button_text_str = (_match_home_button_text_array).join("; "); - _struct_composite.make_str.home_button_text = _match_home_button_text_str; - } - if ("italics" in _json.object["make"] - && (_json.object["make"]["italics"].type().to!string == "STRING") - ) { - _struct_composite.make_str.italics = _json.object["make"]["italics"].str; - } - if ("auto_num_top_at_level" in _json.object["make"] // str == A - D, 1 - 4 - && (_json.object["make"]["auto_num_top_at_level"].type().to!string == "STRING") - ) { - _struct_composite.make_str.auto_num_top_at_level = _json.object["make"]["auto_num_top_at_level"].str; - switch (_json.object["make"]["auto_num_top_at_level"].str) { - case "A": - break; - case "B": _struct_composite.make_str.auto_num_top_lv = 1; - break; - case "C": _struct_composite.make_str.auto_num_top_lv = 2; - break; - case "D": _struct_composite.make_str.auto_num_top_lv = 3; - break; - case "1": _struct_composite.make_str.auto_num_top_lv = 4; - break; - case "2": _struct_composite.make_str.auto_num_top_lv = 5; - break; - case "3": _struct_composite.make_str.auto_num_top_lv = 6; - break; - case "4": _struct_composite.make_str.auto_num_top_lv = 7; - break; - default: - break; - } - } - if ("auto_num_depth" in _json.object["make"] - && (_json.object["make"]["auto_num_depth"].type().to!string == "INTEGER") - ) { - _struct_composite.make_str.auto_num_depth = _json.object["make"]["auto_num_depth"].integer.to!int; - } else if ("auto_num_depth" in _json.object["make"] - && (_json.object["make"]["auto_num_depth"].type().to!string == "STRING") - ) { - _struct_composite.make_str.auto_num_depth = _json.object["make"]["auto_num_depth"].str.to!int; - } - if ("substitute" in _json.object["make"]) { - string[][] _sub; - if ( - (_json.object["make"]["substitute"].type().to!string == "ARRAY") - && (_json.object["make"]["substitute"][0].type().to!string == "ARRAY") - ) { - foreach (substitute_pair; _json.object["make"]["substitute"].arrayNoRef) { - if ((substitute_pair.type().to!string) == "ARRAY") { - if (!empty(substitute_pair[0].str) && !empty(substitute_pair[1].str)) { - _sub ~= [ substitute_pair[0].str, substitute_pair[1].str]; - } - } - } - } else if ( - (_json.object["make"]["substitute"].type().to!string == "ARRAY") - && (_json.object["make"]["substitute"][0].type().to!string == "STRING") - ) { - if (!empty(_json.object["make"]["substitute"][0].str) && !empty(_json.object["make"]["substitute"][1].str)) { - _sub = [[_json.object["make"]["substitute"][0].str, _json.object["make"]["substitute"][1].str]]; - } - } - // writeln(_sub); - _struct_composite.make_str.substitute = _sub; - } - if ("texpdf_font" in _json.object["make"] - && (_json.object["make"]["texpdf_font"].type().to!string == "STRING") - ) { - _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; - } - _struct_composite.make.bold = _mk.bold(_struct_composite.make_str.bold); - _struct_composite.make.breaks = _mk.breaks(_struct_composite.make_str.breaks); - _struct_composite.make.cover_image = _mk.cover_image(_struct_composite.make_str.cover_image); - _struct_composite.make.css = _mk.css(_struct_composite.make_str.css); - _struct_composite.make.emphasis = _mk.emphasis(_struct_composite.make_str.emphasis); - _struct_composite.make.footer = _mk.footer(_struct_composite.make_str.footer); - _struct_composite.make.headings = _mk.headings(_struct_composite.make_str.headings); - _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); - _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); - _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); - _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); - _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); - _struct_composite.make.auto_num_depth = _mk.auto_num_depth(_struct_composite.make_str.auto_num_depth); - _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); - _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); - } - /+ conf ------------------------------------------------------------------- +/ - if ("webserv" in _json.object) { - if ("url_root" in _json.object["webserv"] - && (_json.object["webserv"]["url_root"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_url_root = _json.object["webserv"]["url_root"].str; - } - if ("path" in _json.object["webserv"] - && (_json.object["webserv"]["path"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_path = _json.object["webserv"]["path"].str; - } - if ("images" in _json.object["webserv"] - && (_json.object["webserv"]["images"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_images = _json.object["webserv"]["images"].str; - } - if ("cgi" in _json.object["webserv"] - && (_json.object["webserv"]["cgi"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi = _json.object["webserv"]["cgi"].str; - } - if ("cgi_host" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_host"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi_host = _json.object["webserv"]["cgi_host"].str; - } - if ("cgi_host_path" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_host_path"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; - } - if ("cgi_port" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_port"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi_port = _json.object["webserv"]["cgi_port"].str; - } - if ("cgi_user" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_user"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi_user = _json.object["webserv"]["cgi_user"].str; - } - if ("cgi_file_links" in _json.object["webserv"] - && (_json.object["webserv"]["cgi_file_links"].type().to!string == "STRING") - ) { - _struct_composite.conf.webserv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; - } - } - if ("processing" in _json.object) { - if ("path" in _json.object["processing"] - && (_json.object["processing"]["path"].type().to!string == "STRING") - ) { - _struct_composite.conf.processing_path = _json.object["processing"]["path"].str; - } - if ("dir" in _json.object["processing"] - && (_json.object["processing"]["dir"].type().to!string == "STRING") - ) { - _struct_composite.conf.processing_dir = _json.object["processing"]["dir"].str; - } - if ("concord_max" in _json.object["processing"] - && (_json.object["processing"]["concord_max"].type().to!string == "STRING") - ) { - _struct_composite.conf.processing_concord_max = _json.object["processing"]["concord_max"].str; - } - } - if ("flag" in _json.object) { - if ("act0" in _json.object["flag"] - && (_json.object["flag"]["act0"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act0 = _json.object["flag"]["act0"].str; - } - if ("act1" in _json.object["flag"] - && (_json.object["flag"]["act1"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act1 = _json.object["flag"]["act1"].str; - } - if ("act2" in _json.object["flag"] - && (_json.object["flag"]["act2"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act2 = _json.object["flag"]["act2"].str; - } - if ("act3" in _json.object["flag"] - && (_json.object["flag"]["act3"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act3 = _json.object["flag"]["act3"].str; - } - if ("act4" in _json.object["flag"] - && (_json.object["flag"]["act4"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act4 = _json.object["flag"]["act4"].str; - } - if ("act5" in _json.object["flag"] - && (_json.object["flag"]["act5"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act5 = _json.object["flag"]["act5"].str; - } - if ("act6" in _json.object["flag"] - && (_json.object["flag"]["act6"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act6 = _json.object["flag"]["act6"].str; - } - if ("act7" in _json.object["flag"] - && (_json.object["flag"]["act7"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act7 = _json.object["flag"]["act7"].str; - } - if ("act8" in _json.object["flag"] - && (_json.object["flag"]["act8"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act8 = _json.object["flag"]["act8"].str; - } - if ("act9" in _json.object["flag"] - && (_json.object["flag"]["act9"].type().to!string == "STRING") - ) { - _struct_composite.conf.flag_act9 = _json.object["flag"]["act9"].str; - } - } - if ("default" in _json.object) { - if ("papersize" in _json.object["default"] - && (_json.object["default"]["papersize"].type().to!string == "STRING") - ) { - _struct_composite.conf.default_papersize = _json.object["default"]["papersize"].str; - } - if ("text_wrap" in _json.object["default"] - && (_json.object["default"]["text_wrap"].type().to!string == "STRING") - ) { - _struct_composite.conf.default_text_wrap = _json.object["default"]["text_wrap"].str; - } - if ("emphasis" in _json.object["default"] - && (_json.object["default"]["emphasis"].type().to!string == "STRING") - ) { - _struct_composite.conf.default_emphasis = _json.object["default"]["emphasis"].str; - } - if ("language" in _json.object["default"] - && (_json.object["default"]["language"].type().to!string == "STRING") - ) { - _struct_composite.conf.default_language = _json.object["default"]["language"].str; - } - if ("digest" in _json.object["default"] - && (_json.object["default"]["digest"].type().to!string == "STRING") - ) { - _struct_composite.conf.default_digest = _json.object["default"]["digest"].str; - } - } - if ("search" in _json.object) { - if ("flag" in _json.object["search"] - && (_json.object["search"]["flag"].type().to!string == "STRING") - ) { - _struct_composite.conf.search_flag = _json.object["search"]["flag"].str; - } - if ("action" in _json.object["search"] - && (_json.object["search"]["action"].type().to!string == "STRING") - ) { - _struct_composite.conf.search_action = _json.object["search"]["action"].str; - } - if ("db" in _json.object["search"] - && (_json.object["search"]["db"].type().to!string == "STRING") - ) { - _struct_composite.conf.search_db = _json.object["search"]["db"].str; - } - if ("title" in _json.object["search"] - && (_json.object["search"]["title"].type().to!string == "STRING") - ) { - _struct_composite.conf.search_title = _json.object["search"]["title"].str; - } - } - /+ meta ------------------------------------------------------------------- +/ - if ("classify" in _json.object) { - if ("dewey" in _json.object["classify"] - && (_json.object["classify"]["dewey"].type().to!string == "STRING") - ) { - _struct_composite.meta.classify_dewey = _json.object["classify"]["dewey"].str; - } - if ("keywords" in _json.object["classify"] - && (_json.object["classify"]["keywords"].type().to!string == "STRING") - ) { - _struct_composite.meta.classify_keywords = _json.object["classify"]["keywords"].str; - } - if ("loc" in _json.object["classify"] - && (_json.object["classify"]["loc"].type().to!string == "STRING") - ) { - _struct_composite.meta.classify_loc = _json.object["classify"]["loc"].str; - } - if ("subject" in _json.object["classify"] - && (_json.object["classify"]["subject"].type().to!string == "STRING") - ) { - _struct_composite.meta.classify_subject = _json.object["classify"]["subject"].str; - } - if ("topic_register" in _json.object["classify"] - && (_json.object["classify"]["topic_register"].type().to!string == "STRING") - ) { - _struct_composite.meta.classify_topic_register = _json.object["classify"]["topic_register"].str; - } - } - if ("date" in _json.object) { - if ("added_to_site" in _json.object["date"] - && (_json.object["date"]["added_to_site"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_added_to_site = _json.object["date"]["added_to_site"].str; - } - if ("available" in _json.object["date"] - && (_json.object["date"]["available"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_available = _json.object["date"]["available"].str; - } - if ("created" in _json.object["date"] - && (_json.object["date"]["created"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_created = _json.object["date"]["created"].str; - } - if ("issued" in _json.object["date"] - && (_json.object["date"]["issued"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_issued = _json.object["date"]["issued"].str; - } - if ("modified" in _json.object["date"] - && (_json.object["date"]["modified"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_modified = _json.object["date"]["modified"].str; - } - if ("published" in _json.object["date"] - && (_json.object["date"]["published"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_published = _json.object["date"]["published"].str; - } - if ("valid" in _json.object["date"] - && (_json.object["date"]["valid"].type().to!string == "STRING") - ) { - _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; - } - } - if ("links" in _json.object) {} - if ("notes" in _json.object) { - if ("abstract" in _json.object["notes"] - && (_json.object["notes"]["abstract"].type().to!string == "STRING") - ) { - _struct_composite.meta.notes_abstract = _json.object["notes"]["abstract"].str; - } - if ("description" in _json.object["notes"] - && (_json.object["notes"]["description"].type().to!string == "STRING") - ) { - _struct_composite.meta.notes_description = _json.object["notes"]["description"].str; - } - } - if ("original" in _json.object) { - if ("language" in _json.object["original"] - && (_json.object["original"]["language"].type().to!string == "STRING") - ) { - _struct_composite.meta.original_language = _json.object["original"]["language"].str; - } - if ("language_char" in _json.object["original"] - && (_json.object["original"]["language_char"].type().to!string == "STRING") - ) { - _struct_composite.meta.original_language_char = _json.object["original"]["language_char"].str; - } - if ("source" in _json.object["original"] - && (_json.object["original"]["source"].type().to!string == "STRING") - ) { - _struct_composite.meta.original_source = _json.object["original"]["source"].str; - } - if ("title" in _json.object["original"] - && (_json.object["original"]["title"].type().to!string == "STRING") - ) { - _struct_composite.meta.original_title = _json.object["original"]["title"].str; - } - } - if ("publisher" in _json.object) {} - if ("rights" in _json.object) { - if ("copyright" in _json.object["rights"] - && (_json.object["rights"]["copyright"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright = _json.object["rights"]["copyright"].str; - } - if ("copyright_text" in _json.object["rights"] - && (_json.object["rights"]["copyright_text"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_text = _json.object["rights"]["copyright_text"].str; - } - if ("copyright_audio" in _json.object["rights"] - && (_json.object["rights"]["copyright_audio"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_audio = _json.object["rights"]["copyright_audio"].str; - } - if ("copyright_cover" in _json.object["rights"] - && (_json.object["rights"]["copyright_cover"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_cover = _json.object["rights"]["copyright_cover"].str; - } - if ("copyright_illustrations" in _json.object["rights"] - && (_json.object["rights"]["copyright_illustrations"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_illustrations = _json.object["rights"]["copyright_illustrations"].str; - } - if ("copyright_photographs" in _json.object["rights"] - && (_json.object["rights"]["copyright_photographs"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_photographs = _json.object["rights"]["copyright_photographs"].str; - } - if ("copyright_translation" in _json.object["rights"] - && (_json.object["rights"]["copyright_translation"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_translation = _json.object["rights"]["copyright_translation"].str; - } - if ("copyright_video" in _json.object["rights"] - && (_json.object["rights"]["copyright_video"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_copyright_video = _json.object["rights"]["copyright_video"].str; - } - if ("license" in _json.object["rights"] - && (_json.object["rights"]["license"].type().to!string == "STRING") - ) { - _struct_composite.meta.rights_license = _json.object["rights"]["license"].str; - } - } - if (_struct_composite.meta.creator_author.empty) { - if ("creator" in _json.object) { - if ("author" in _json.object["creator"] - && (_json.object["creator"]["author"].type().to!string == "STRING") - ) { - _struct_composite.meta.creator_author = _json.object["creator"]["author"].str; - } - if ("email" in _json.object["creator"] - && (_json.object["creator"]["email"].type().to!string == "STRING") - ) { - _struct_composite.meta.creator_author_email = _json.object["creator"]["email"].str; - } - if ("illustrator" in _json.object["creator"] - && (_json.object["creator"]["illustrator"].type().to!string == "STRING") - ) { - _struct_composite.meta.creator_illustrator = _json.object["creator"]["illustrator"].str; - } - if ("translator" in _json.object["creator"] - && (_json.object["creator"]["translator"].type().to!string == "STRING") - ) { - _struct_composite.meta.creator_translator = _json.object["creator"]["translator"].str; - } - } - string[] authors_arr; - auto authors_raw_arr = _struct_composite.meta.creator_author.split(_rgx.arr_delimiter); - foreach (author_raw; authors_raw_arr) { - authors_arr ~= author_raw.replace(_rgx.raw_author_munge, "$2 $1"); - } - _struct_composite.meta.creator_author = join(authors_arr, ", ").chomp.chomp; - } - if (_struct_composite.meta.title_main.empty) { - if ("title" in _json.object) { - if ((_json.object["title"].type().to!string) == "STRING") { - _struct_composite.meta.title_main = _json.object["title"].str; - } else { - if ("edition" in _json.object["title"] - && (_json.object["title"]["edition"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; - } - if ("full" in _json.object["title"] - && (_json.object["title"]["full"].type().to!string == "STRING") - ) {} - if ("language" in _json.object["title"] - && (_json.object["title"]["language"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_language = _json.object["title"]["language"].str; - } - if ("main" in _json.object["title"] - && (_json.object["title"]["main"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_main = _json.object["title"]["main"].str; - } - if ("note" in _json.object["title"] - && (_json.object["title"]["note"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_note = _json.object["title"]["note"].str; - } - if ("sub" in _json.object["title"] - && (_json.object["title"]["sub"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; - } - if ("subtitle" in _json.object["title"] - && (_json.object["title"]["subtitle"].type().to!string == "STRING") - ) { - _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; - } - } - } - if ((!(_struct_composite.meta.title_subtitle.empty)) - && (_struct_composite.meta.title_sub.empty)) { - _struct_composite.meta.title_sub = _struct_composite.meta.title_subtitle; - } - _struct_composite.meta.title_full = (_struct_composite.meta.title_sub.empty) - ? _struct_composite.meta.title_main - : format( - "%s - %s", - _struct_composite.meta.title_main, - _struct_composite.meta.title_sub, - ); - } - return _struct_composite; - } -} diff --git a/src/sdp/meta/conf_make_meta_structs.d b/src/sdp/meta/conf_make_meta_structs.d deleted file mode 100644 index b67b9ad..0000000 --- a/src/sdp/meta/conf_make_meta_structs.d +++ /dev/null @@ -1,328 +0,0 @@ -module sdp.meta.conf_make_meta_structs; -import - std.exception, - std.json, - std.regex, - std.stdio, - std.string, - std.traits, - std.typecons, - std.utf, - std.conv : to; -import - sdp.meta.defaults, - sdp.meta.rgx; -mixin SiSUrgxInit; -static auto _rgx = Rgx(); -mixin InternalMarkup; -auto _mkup = InlineMarkup(); -auto url_markup(string line) { - auto line_ = (line) - .replaceAll( - _rgx.smid_inline_link_markup_regular, - ("$1" - ~ _mkup.lnk_o ~ "$2" ~ _mkup.lnk_c - ~ _mkup.url_o ~ "$3" ~ _mkup.url_c - ~ "$4") // ("$1{ $2 }$3$4") - ) - .replaceAll( - _rgx.smid_inline_link_naked_url, - ("$1" - ~ _mkup.lnk_o ~ "$2" ~ _mkup.lnk_c - ~ _mkup.url_o ~ "$2" ~ _mkup.url_c - ~ "$3") // ("$1{ $2 }$2$3") - ) - .replaceAll( - _rgx.arr_delimiter, - _mkup.br_line - ); - return line_; -} -struct ConfCompositeMakeStr { - string bold; - string breaks; - string cover_image; - string css; - string emphasis; - string[] footer; - string[] headings; - string[] home_button_image; - string home_button_text = "{SiSU}http://www.sisudoc.org;" - ~ " {www.sisudoc.org}http://www.sisudoc.org;" - ~ " {sources / git}http://git.sisudoc.org/gitweb/"; - string italics; - string auto_num_top_at_level; - int auto_num_top_lv = 9; - int auto_num_depth = 2; - string[][] substitute; - string texpdf_font; -} -struct confCompositeMakeBuild { - auto bold(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "*{$1}*", "<b>$1</b>"]; - } - return _out; - } - auto breaks(string _mk) { - return _mk; - } - auto cover_image(string _mk) { - return _mk; - } - auto css(string _mk) { - return _mk; - } - auto emphasis(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "!{$1}!", "<em>$1</em>" ]; - } - return _out; - } - auto footer(string[] _mk) { - string line_; - string[] _mk2; - foreach (line; _mk) { - _mk2 ~= url_markup(line); - } - return _mk2; - } - auto headings(string[] _mk) { - return _mk; - } - auto home_button_image(string[] _mk) { - return _mk; - } - auto home_button_text(string _mk) { - return url_markup(_mk); - } - auto italics(string _mk) { - string[] _out; - if (_mk) { - _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "/{$1}/", "<i>$1</i>" ]; - } - return _out; - } - auto auto_num_top_at_level(string _mk) { - return _mk; - } - auto auto_num_top_lv(int _mk) { - return _mk; - } - auto auto_num_depth(int _mk) { - return _mk; - } - auto substitute(string[][] _mk) { - return _mk; - } - auto texpdf_font(string _mk) { - return _mk; - } -} -struct ConfCompositeMakeInit { - string[] bold; - string breaks; - string cover_image; - string css; - string[] emphasis; - string[] footer; - string[] headings; - string[] home_button_image; - string home_button_text = "{SiSU}http://www.sisudoc.org;" - ~ " {www.sisudoc.org}http://www.sisudoc.org;" - ~ " {sources / git}http://git.sisudoc.org/gitweb/"; - string[] italics; - string auto_num_top_at_level; - int auto_num_top_lv = 9; - int auto_num_depth = 2; - string[][] substitute; - string texpdf_font; -} -struct ConfCompositeSiteLocal { - string webserv_url_root; - string webserv_path; - string webserv_images; - string webserv_cgi; - string webserv_cgi_host; - string webserv_cgi_host_path; - string webserv_cgi_port; - string webserv_cgi_user; - string webserv_cgi_file_links; - string processing_path; - string processing_dir; - string processing_concord_max; - string flag_act0; - string flag_act1; - string flag_act2; - string flag_act3; - string flag_act4; - string flag_act5; - string flag_act6; - string flag_act7; - string flag_act8; - string flag_act9; - string default_papersize; - string default_text_wrap; - string default_emphasis; - string default_language; - string default_digest; - string permission_share_source; - string search_flag; - string search_action; - string search_db; - string search_title; -} -struct MetaComposite { - string classify_dewey; - string classify_keywords; - string classify_loc; - string classify_subject; - string classify_topic_register; - string creator_author; - string creator_author_email; - string creator_illustrator; - string creator_translator; - string date_added_to_site; - string date_available; - string date_created; - string date_issued; - string date_modified; - string date_published; - string date_valid; - string identifier_isbn; - string identifier_oclc; - string identifier_pg; - string language_document; - string language_document_char; - string links; - string notes_abstract; - string notes_description; - string original_language; - string original_language_char; - string original_publisher; - string original_source; - string original_title; - string publisher; - string rights_copyright; - string rights_copyright_audio; - string rights_copyright_cover; - string rights_copyright_illustrations; - string rights_copyright_photographs; - string rights_copyright_text; - string rights_copyright_translation; - string rights_copyright_video; - string rights_license; - string title_edition; - string title_full; - string title_language; - string title_main; - string title_note; - string title_short; - string title_sub; - string title_subtitle; -} -struct ConfComposite { - MetaComposite meta; - ConfCompositeMakeInit make; - ConfCompositeSiteLocal conf; -} -struct ConfCompositePlus { - MetaComposite meta; - ConfCompositeMakeInit make; - ConfCompositeMakeStr make_str; - ConfCompositeSiteLocal conf; -} -static auto ptr_head_main - = [ - "classify", - "creator", - "date", - "identifier", - "links", - "make", - "original", - "notes", - "rights", - "title" - ]; -static auto ptr_head_sub_classify - = [ - "dewey", - "keywords", - "loc", - "subject", - "topic_register" - ]; -static auto ptr_head_sub_creator - = [ - "author", - "author_email", - "cover", - "illustrator", - "translator" - ]; -static auto ptr_head_sub_date - = [ - "added_to_site", - "available", - "created", - "issued", - "modified", - "published", - "valid" - ]; -static auto ptr_head_sub_identifier - = [ - "isbn", - "oclc", - "pg" - ]; -/+ make +/ -static auto ptr_head_sub_make - = [ - "cover_image", - "home_button_image", - "home_button_text", - "footer", "headings", - "auto_num_top_at_level", "auto_num_top_lv", "auto_num_depth", - "breaks", - "substitute", - "bold", - "italics", - "emphasis", - "texpdf_font", - "css" - ]; -static auto ptr_head_sub_notes - = [ - "abstract", - "description" - ]; -static auto ptr_head_sub_original - = [ - "language", - "source", - "title" - ]; -static auto ptr_head_sub_publisher - = [ "name" ]; -static auto ptr_head_sub_rights - = [ - "copyright", - "cover", - "illustrations", - "license" - ]; -static auto ptr_head_sub_title - = [ - "edition", - "full", - "language", - "main", - "note", - "sub" - ]; -auto config_jsonstr = `{ -}`; diff --git a/src/sdp/meta/conf_make_meta_toml.d b/src/sdp/meta/conf_make_meta_toml.d deleted file mode 100644 index d434f00..0000000 --- a/src/sdp/meta/conf_make_meta_toml.d +++ /dev/null @@ -1,77 +0,0 @@ -/++ - extract native/orig header return associative array<BR> - - the header is passed as text (lopped off top of a sisu markup file until the - required first heading ^A~), determine whether is a native header or sdlang one - with a regex check if whether it contains the "native header" required tag/field - @title: then process accordingly as a "native header" or "sdlang header" - converting the metadata and make instructions to a common json format used by - program internally. Moved to associative array. -+/ -module sdp.meta.conf_make_meta_toml; -static template configParseTOMLreturnJSON() { - import - toml, - toml.json; - auto configParseTOMLreturnJSON(T)( - T _text - ){ - TOMLDocument _doc; - _doc = parseTOML(cast(string)(_text.content)); - auto _doc_json = toJSON(_doc); - return _doc_json; - } -} -static template configParseTOMLreturnSiSUstruct() { - import - toml, - toml.json; - import - sdp.meta.conf_make_meta_structs, - sdp.meta.conf_make_meta_json; - mixin contentJSONtoSiSUstruct; - auto configParseTOMLreturnSiSUstruct(CCm, T)( - CCm _make_and_meta_struct, - T _document_struct - ){ - TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content)); - auto _doc_json = toJSON(_doc); - _make_and_meta_struct = contentJSONtoSiSUstruct!()(_make_and_meta_struct, _doc_json, _document_struct.filename); // struct from json - return _make_and_meta_struct; - } -} -static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { - import - std.exception, - std.regex, - std.stdio, - std.traits, - std.typecons, - std.utf, - std.conv : to; - import - toml, - toml.json; - import - sdp.meta.conf_make_meta_structs, - sdp.meta.conf_make_meta_json, - sdp.meta.rgx; - mixin SiSUrgxInit; - mixin contentJSONtoSiSUstruct; - static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm, Src)( - CCm _make_and_meta_struct, - Src header_src, - ) { - TOMLDocument _doc; - if (header_src.match(rgx.toml_header_meta_title)) { - debug (json) { - writeln(">>> document header is toml, convert to JSON"); - } - _doc = parseTOML(cast(string)(header_src)); - } - auto _doc_json = toJSON(_doc); - auto _header_and_make_and_meta_struct = contentJSONtoSiSUstruct!()(_make_and_meta_struct, _doc_json, "header"); - return _header_and_make_and_meta_struct; - } -} diff --git a/src/sdp/meta/defaults.d b/src/sdp/meta/defaults.d deleted file mode 100644 index 70089e5..0000000 --- a/src/sdp/meta/defaults.d +++ /dev/null @@ -1,241 +0,0 @@ -/++ - default settings -+/ -module sdp.meta.defaults; -template SiSUrgxInitFlags() { - /+ regex flags +/ - static int[string] flags_type_init() { - int[string] flags_type_init = [ - "make_headings" : 0, - "header_make" : 0, - "header_meta" : 0, - "heading" : 0, - "biblio_section" : 0, - "glossary_section" : 0, - "blurb_section" : 0, - "para" : 0, - "blocks" : 0, // 0..2 generic - "code" : 0, // 0..2 - "poem" : 0, // 0..2 - "table" : 0, // 0..2 - "group" : 0, // 0..2 - "block" : 0, // 0..2 - "quote" : 0, // 0..2 - "verse_new" : 0, - "curly_code" : 0, - "curly_poem" : 0, - "curly_group" : 0, - "curly_block" : 0, - "curly_quote" : 0, - "curly_table" : 0, - "curly_table_special_markup" : 0, - "tic_code" : 0, - "tic_poem" : 0, - "tic_group" : 0, - "tic_block" : 0, - "tic_quote" : 0, - "tic_table" : 0, - "ocn_status" : 0, // 0 object_number; 1 no object_number; 2 no object_number & dummy headings - "ocn_status_off_for_multiple_objects" : 0, // 0 object_number; 1 no object_number; 2 no object_number & dummy headings - "book_index" : 0, - ]; - return flags_type_init; - } -} -template SiSUnode() { - static string[string] node_metadata_heading_str() { - auto _node = [ - "is" : "", - "ocn" : "", - "marked_up_lev" : "", - "segment_anchor_tag" : "", - "attrib" : "", - ]; - return _node; - } - static int[string] node_metadata_heading_int() { - auto _node = [ - "ocn" : 0, // decide whether to use or keep? - "ptr_doc_object" : 0, - "ptr_html_segnames" : 0, - "ptr_heading" : 0, - "heading_lev_markup" : 9, - "heading_lev_collapsed" : 9, - "parent_ocn" : 0, - "parent_lev_markup" : 9, - ]; - return _node; - } - static string[string] node_metadata_para_str() { - auto _node = [ - "is" : "", - "ocn" : "", - "attrib" : "", - ]; - return _node; - } - static int[string] node_metadata_para_int() { - auto _node = [ - "ocn" : 0, - "indent_base" : 0, - "indent_hang" : 0, - "bullet" : 0, // bool (0|1) - ]; - return _node; - } -} -template SiSUbiblio() { - // required: deemed_author (author || editor); year; fulltitle; - struct BibJsnStr { - static auto biblio_entry_tags_jsonstr() { - string x = `{ - "is" : "", - "sortby_deemed_author_year_title" : "", - "deemed_author" : "", - "author_raw" : "", - "author" : "", - "author_arr" : [ "" ], - "editor_raw" : "", - "editor" : "", - "editor_arr" : [ "" ], - "title" : "", - "subtitle" : "", - "fulltitle" : "", - "language" : "", - "trans" : "", - "src" : "", - "journal" : "", - "in" : "", - "volume" : "", - "edition" : "", - "year" : "", - "place" : "", - "publisher" : "", - "url" : "", - "pages" : "", - "note" : "", - "short_name" : "", - "id" : "" - }`; // is: book, article, magazine, newspaper, blog, other - return x; - } - } -} -template InternalMarkup() { - import std.array; - static struct InlineMarkup { - auto en_a_o = "【"; auto en_a_c = "】"; - auto en_b_o = "〖"; auto en_b_c = "〗"; - auto lnk_o = "┥"; auto lnk_c = "┝"; - auto url_o = "┤"; auto url_c = "├"; - auto mark_internal_site_lnk = "¤"; - auto nbsp = "░"; - auto br_line = "┘"; - auto br_nl = "┙"; - auto br_paragraph = "┚"; - auto br_obj = "break_obj"; - auto br_page_line = "┼"; - auto br_page = "┿"; - auto br_page_new = "╂"; - auto tc_s = "┊"; - auto tc_o = "┏"; - auto tc_c = "┚"; - auto tc_p = "┆"; - auto mono = "■"; - auto img = "☼"; - static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { - _indent_spaces = replicate(_indent_spaces, indent); - return _indent_spaces; - } - static string repeat_character_by_number_provided(C,N)(C _character ="-", N number=10) { - _character = replicate(_character, number); - return _character; - } - } -} -template SiSUlanguageCodes() { - /+ language codes +/ - struct Lang { - static string[string][string] codes() { - auto _lang_codes = [ - "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], - "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], - "bn": [ "c": "bn", "n": "Bengali", "t": "Bengali", "xlp": "bengali" ], - "br": [ "c": "br", "n": "Breton", "t": "Breton", "xlp": "breton" ], - "ca": [ "c": "ca", "n": "Catalan", "t": "catalan", "xlp": "catalan" ], - "cs": [ "c": "cs", "n": "Czech", "t": "česky", "xlp": "czech" ], - "cy": [ "c": "cy", "n": "Welsh", "t": "Welsh", "xlp": "welsh" ], - "da": [ "c": "da", "n": "Danish", "t": "dansk", "xlp": "danish" ], - "de": [ "c": "de", "n": "German", "t": "Deutsch", "xlp": "german" ], - "el": [ "c": "el", "n": "Greek", "t": "Ελληνικά (Ellinika)", "xlp": "greek" ], - "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], - "eo": [ "c": "eo", "n": "Esperanto", "t": "Esperanto", "xlp": "esperanto" ], - "es": [ "c": "es", "n": "Spanish", "t": "español", "xlp": "spanish" ], - "et": [ "c": "et", "n": "Estonian", "t": "Estonian", "xlp": "estonian" ], - "eu": [ "c": "eu", "n": "Basque", "t": "basque", "xlp": "basque" ], - "fi": [ "c": "fi", "n": "Finnish", "t": "suomi", "xlp": "finnish" ], - "fr": [ "c": "fr", "n": "French", "t": "français", "xlp": "french" ], - "ga": [ "c": "ga", "n": "Irish", "t": "Irish", "xlp": "irish" ], - "gl": [ "c": "gl", "n": "Galician", "t": "Galician", "xlp": "galician" ], - "he": [ "c": "he", "n": "Hebrew", "t": "Hebrew", "xlp": "hebrew" ], - "hi": [ "c": "hi", "n": "Hindi", "t": "Hindi", "xlp": "hindi" ], - "hr": [ "c": "hr", "n": "Croatian", "t": "Croatian", "xlp": "croatian" ], - "hy": [ "c": "hy", "n": "Armenian", "t": "Armenian", "xlp": "armenian" ], - "ia": [ "c": "ia", "n": "Interlingua", "t": "Interlingua", "xlp": "interlingua" ], - "is": [ "c": "is", "n": "Icelandic", "t": "Icelandic", "xlp": "icelandic" ], - "it": [ "c": "it", "n": "Italian", "t": "Italiano", "xlp": "italian" ], - "ja": [ "c": "ja", "n": "Japanese", "t": "日本語 (Nihongo)", "xlp": "japanese" ], - "ko": [ "c": "ko", "n": "Korean", "t": "Korean", "xlp": "korean" ], - "la": [ "c": "la", "n": "Latin", "t": "Latin", "xlp": "latin" ], - "lo": [ "c": "lo", "n": "Lao", "t": "Lao", "xlp": "lao" ], - "lt": [ "c": "lt", "n": "Lithuanian", "t": "Lithuanian", "xlp": "lithuanian" ], - "lv": [ "c": "lv", "n": "Latvian", "t": "Latvian", "xlp": "latvian" ], - "ml": [ "c": "ml", "n": "Malayalam", "t": "Malayalam", "xlp": "malayalam" ], - "mr": [ "c": "mr", "n": "Marathi", "t": "Marathi", "xlp": "marathi" ], - "nl": [ "c": "nl", "n": "Dutch", "t": "Nederlands", "xlp": "dutch" ], - "no": [ "c": "no", "n": "Norwegian", "t": "norsk", "xlp": "norsk" ], - "nn": [ "c": "nn", "n": "Norwegian Nynorsk", "t": "nynorsk", "xlp": "nynorsk" ], - "oc": [ "c": "oc", "n": "Occitan", "t": "Occitan", "xlp": "occitan" ], - "pl": [ "c": "pl", "n": "Polish", "t": "polski", "xlp": "polish" ], - "pt": [ "c": "pt", "n": "Portuguese", "t": "Português", "xlp": "portuges" ], - "pt_BR": [ "c": "pt_BR", "n": "Portuguese Brazil", "t": "Brazilian Português", "xlp": "brazilian" ], - "ro": [ "c": "ro", "n": "Romanian", "t": "română", "xlp": "romanian" ], - "ru": [ "c": "ru", "n": "Russian", "t": "Русский (Russkij)", "xlp": "russian" ], - "sa": [ "c": "sa", "n": "Sanskrit", "t": "Sanskrit", "xlp": "sanskrit" ], - "se": [ "c": "se", "n": "Sami", "t": "Samin", "xlp": "samin" ], - "sk": [ "c": "sk", "n": "Slovak", "t": "slovensky", "xlp": "slovak" ], - "sl": [ "c": "sl", "n": "Slovenian", "t": "Slovenian", "xlp": "slovenian" ], - "sq": [ "c": "sq", "n": "Albanian", "t": "Albanian", "xlp": "albanian" ], - "sr": [ "c": "sr", "n": "Serbian", "t": "Serbian", "xlp": "serbian" ], - "sv": [ "c": "sv", "n": "Swedish", "t": "svenska", "xlp": "swedish" ], - "ta": [ "c": "ta", "n": "Tamil", "t": "Tamil", "xlp": "tamil" ], - "te": [ "c": "te", "n": "Telugu", "t": "Telugu", "xlp": "telugu" ], - "th": [ "c": "th", "n": "Thai", "t": "Thai", "xlp": "thai" ], - "tk": [ "c": "tk", "n": "Turkmen", "t": "Turkmen", "xlp": "turkmen" ], - "tr": [ "c": "tr", "n": "Turkish", "t": "Türkçe", "xlp": "turkish" ], - "uk": [ "c": "uk", "n": "Ukranian", "t": "українська (ukrajins\"ka)", "xlp": "ukrainian" ], - "ur": [ "c": "ur", "n": "Urdu", "t": "Urdu", "xlp": "urdu" ], - "us": [ "c": "en", "n": "English (American)","t": "English", "xlp": "english" ], - "vi": [ "c": "vi", "n": "Vietnamese", "t": "Vietnamese", "xlp": "vietnamese" ], - "zh": [ "c": "zh", "n": "Chinese", "t": "中文", "xlp": "chinese" ], - "en": [ "c": "en", "n": "English", "t": "English", "xlp": "english" ], - "xx": [ "c": "xx", "n": "Default", "t": "English", "xlp": "english" ], - ]; - return _lang_codes; - } - static string[] code_arr_ptr() { - auto _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; - return _lang_codes; - } - static string[] code_arr() { - auto _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; - return _lang_codes; - } - static auto codes_() { - return "(" ~ join(code_arr,"|") ~ ")"; - } - static auto codes_regex() { - return regex(codes_); - } - } -} diff --git a/src/sdp/meta/doc_debugs.d b/src/sdp/meta/doc_debugs.d deleted file mode 100644 index 73b0f3b..0000000 --- a/src/sdp/meta/doc_debugs.d +++ /dev/null @@ -1,652 +0,0 @@ -/++ - output debugs -+/ -module sdp.meta.doc_debugs; -template SiSUdebugs() { - import - sdp.meta.defaults, - sdp.meta.rgx; - import - std.algorithm, - std.array, - std.container, - std.exception, - std.json, - std.stdio, - std.file, - std.path, - std.range, - std.regex, - std.string, - std.traits, - std.typecons, - std.utf, - std.conv : to; - auto SiSUdebugs(S,T)( - const S contents, - T doc_matters, - ) { - mixin SiSUrgxInit; - mixin InternalMarkup; - static auto rgx = Rgx(); - auto markup = InlineMarkup(); - string key; - debug(parent) { - writefln( - "%s:%s", - __FILE__, - __LINE__, - ); - foreach (key; doc_matters.xml.keys_seq.seg) { - foreach (obj; contents[key]) { - if (obj.metainfo.is_of_part != "empty") { - if (obj.metainfo.is_a == "heading") { - writefln( - "%s node: %s heading: %s %s", - obj.object_number, - obj.node, - obj.heading_lev_markup, - obj.text, - ); - } - } - } - } - } - debug(dumpdoc) { - writefln( - "> %s:%s", - __FILE__, - __LINE__, - ); - } - debug(section_head) { - key="head"; - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(section_toc) { - key="toc_seg"; - out_toc(contents, key); - } - debug(section_toc_seg) { - key="toc_seg"; - out_toc(contents, key); - } - debug(section_toc_scroll) { - key="toc_scroll"; - out_toc(contents, key); - } - debug(segnames) { - writeln(__LINE__); - out_segnames(contents, doc_matters); - } - debug(section_body) { - key="body"; - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(toc_nav_dom) { - enum DomTags { none, open, close, close_and_open, open_still, } - foreach (sect; doc_matters.xml.keys_seq.seg) { - foreach (obj; contents[sect]) { - if (obj.metainfo.is_a == "heading") { - foreach_reverse (k; 0 .. 7) { - switch (obj.dom_structure_markedup_tags_status[k]) { - case DomTags.close : - writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); - break; - case DomTags.close_and_open : - writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); - writeln(markup.indent_by_spaces_provided(k), - "<", k, ">", obj.text, - " file: ", obj.segment_anchor_tag, ".xhtml#", obj.ocn); - break; - case DomTags.open : - writeln(markup.indent_by_spaces_provided(k), - "<", k, ">", obj.text, - " file: ", obj.segment_anchor_tag, ".xhtml#", obj.ocn); - break; - default : - break; - } - } - } - } - } - writeln("--------------------"); - foreach (sect; doc_matters.xml.keys_seq.seg) { - foreach (obj; contents[sect]) { - if (obj.metainfo.is_a == "heading") { - foreach_reverse (k; 0 .. 7) { - switch (obj.dom_structure_collapsed_tags_status[k]) { - case DomTags.close : - writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); - break; - case DomTags.close_and_open : - writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); - writeln(markup.indent_by_spaces_provided(k), - "<", k, ">", obj.text, - " file: ", obj.segment_anchor_tag, ".xhtml#", obj.ocn); - break; - case DomTags.open : - writeln(markup.indent_by_spaces_provided(k), - "<", k, ">", obj.text, - " file: ", obj.segment_anchor_tag, ".xhtml#", obj.ocn); - break; - default : - break; - } - } - } - } - } - } - debug(decendants) { - foreach (sect; doc_matters.xml.keys_seq.scroll) { - foreach (obj; contents[sect]) { - if (obj.metainfo.is_a == "heading") { - writeln(obj.metainfo.ocn, " .. ", obj.metainfo.last_decendant_ocn); - } - } - } - } - debug(section_endnotes) { - key="endnotes"; - out_endnotes(contents, key); - } - debug(section_endnotes_seg) { - key="endnotes"; - out_endnotes(contents, key); - } - debug(section_glossary) { - key="glossary"; - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(section_bibliography) { - key="bibliography"; - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(section_bookindex) { - key="bookindex_seg"; - out_bookindex(contents, key); - } - debug(section_bookindex_seg) { - key="bookindex_seg"; - out_bookindex(contents, key); - } - debug(section_bookindex_scroll) { - key="bookindex_scroll"; - out_bookindex(contents, key); - } - debug(blurb_section) { - key="blurb"; - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(objects) { - writefln( - "> %s:%s", - __FILE__, - __LINE__, - ); - foreach (obj; contents[key]) { - if (obj.metainfo.is_of_part != "empty") { - writefln( - "* [%s][%s] %s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - debug(headermakejson) { - writefln( - "%s\n%s\n%s", - "document header, metadata & make instructions:", - doc_matters.conf_make_meta.meta, - ptr_head_main, - ); - foreach (main_header; ptr_head_main) { - switch (main_header) { - case "make": - foreach (sub_header; ptr_head_sub_make) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - default: - break; - } - } - } - debug(headermetadatajson) { - writefln( - "%s\n%s\n%s", - "document header, metadata & make instructions:", - doc_matters.conf_make_meta.meta, - ptr_head_main, - ); - foreach (main_header; ptr_head_main) { - switch (main_header) { - case "creator": - foreach (sub_header; ptr_head_sub_creator) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full, - ); - } - } - break; - case "title": - foreach (sub_header; ptr_head_sub_title) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "rights": - foreach (sub_header; ptr_head_sub_rights) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "date": - foreach (sub_header; ptr_head_sub_date) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "original": - foreach (sub_header; ptr_head_sub_original) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "classify": - foreach (sub_header; ptr_head_sub_classify) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "identifier": - foreach (sub_header; ptr_head_sub_identifier) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "notes": - foreach (sub_header; ptr_head_sub_notes) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - case "publisher": - foreach (sub_header; ptr_head_sub_publisher) { - if (doc_matters.conf_make_meta.meta.title_full.to!string.length > 2) { - writefln( - "%s:%s: %s", - main_header, - sub_header, - doc_matters.conf_make_meta.meta.title_full - ); - } - } - break; - default: - break; - } - } - } - debug(anchor) { - writefln( - "> %s:%s", - __FILE__, - __LINE__, - ); - foreach (k; doc_matters.xml.keys_seq.seg) { - foreach (obj; contents[k]) { - if (obj.metainfo.is_a == "heading") { - writefln( - "%s~ [%s] %s %s", - obj.marked_up_level, - obj.object_number, - obj.anchor_tags, - obj.text - ); - } - } - } - } - debug(heading) { // heading - foreach (k; doc_matters.xml.keys_seq.seg) { - foreach (o; contents[k]) { - if (o.metainfo.is_a == "heading") { - writefln( - "%s* %s\n (markup level: %s; collapsed level: %s)", - replicate(" ", o.heading_lev_markup), - strip(o.text), - o.heading_lev_markup, - o.heading_lev_collapsed, - ); - } - } - } - } - debug(headings) { - writefln( - "> %s:%s", - __FILE__, - __LINE__, - ); - foreach (k; doc_matters.xml.keys_seq.seg) { - foreach (obj; contents[k]) { - if (obj.metainfo.is_a == "heading") { - writefln( - "%s~ [%s] %s", - obj.marked_up_level, - obj.object_number, - obj.text - ); - } - } - } - } - debug(summary) { - string[string] check = [ - "last_object_number" : "NA [debug \"checkdoc\" not run]", - ]; - } - debug(checkdoc) { - if ((doc_matters.opt.action.debug_do)) { - debug(checkdoc) { - if (auto mfn=match(doc_matters.src.filename, rgx.src_fn)) { - if (doc_matters.opt.action.assertions) { - switch (mfn.captures[2]) { - // live manual: - case "live-manual.ssm": - assert(check["last_object_number"] == - "1019","last object_number should be: 1019 (check test, document is frequently updated)"); // ok - break; - // sisu_markup: - case "sisu_markup.sst": - assert(check["last_object_number"] == - "297","last object_number expected to be: 297 rather than " ~ check["last_object_number"]); // ok - // assert(check["last_object_number"] == "297","last object_number expected to be: 297 rather than " ~ check["last_object_number"]); - // notes for first divergance study sisu headings 247 250 - // sisu has issue with code that contains heading 1~ which results in no object_number! ?? - // sisu currently has incorrect last body object_number of 294! - // bug in sisu? attend - break; - // sisu-markup-samples: - case "accelerando.charles_stross.sst": - assert(check["last_object_number"] == - "2861","last object_number expected to be: 2861 rather than " ~ check["last_object_number"]); // ok - break; - case "alices_adventures_in_wonderland.lewis_carroll.sst": - assert(check["last_object_number"] == - "805","last object_number expected to be: 805 rather than " ~ check["last_object_number"]); // 808 - break; - case "autonomy_markup0.sst": - assert(check["last_object_number"] == - "77","last object_number expected to be: 77 rather than " ~ check["last_object_number"]); // ok endnotes - // assert(check["last_object_number"] == "78","last object_number expected to be: 78 rather than " ~ check["last_object_number"]); - break; - case "content.cory_doctorow.sst": - assert(check["last_object_number"] == - "953","last object_number expected to be: 953 rather than " ~ check["last_object_number"]); // 1007 way off, check object_number off switches - // assert(check["last_object_number"] == "953","last object_number expected to be: 953 rather than " ~ check["last_object_number"]); - break; - case "democratizing_innovation.eric_von_hippel.sst": - // fixed ERROR! range violation, broken check! endnotes, bookindex, biblio - // error in bookindex ... (ch1; ch6; ch8 ) - assert(check["last_object_number"] == - "905","last object_number expected to be: 905 rather than " ~ check["last_object_number"]); // 911 - break; - case "down_and_out_in_the_magic_kingdom.cory_doctorow.sst": - assert(check["last_object_number"] == - "1417","last object_number expected to be: 1417 rather than " ~ check["last_object_number"]); // 1455 check object_number off switches - break; - case "for_the_win.cory_doctorow.sst": - assert(check["last_object_number"] == - "3510","last object_number expected to be: 3510 rather than " ~ check["last_object_number"]); // 3569 check object_number off switches - break; - case "free_as_in_freedom_2.richard_stallman_and_the_free_software_revolution.sam_williams.richard_stallman.sst": - assert(check["last_object_number"] == - "1082","last object_number expected to be: 1082 rather than " ~ check["last_object_number"]); // check 1079 too few - break; - case "free_culture.lawrence_lessig.sst": - assert(check["last_object_number"] == - "1330","last object_number expected to be: 1330 rather than " ~ check["last_object_number"]); // 1312 - // fixed ERROR! range violation, broken check! - // error in bookindex ... sections piracy (ch1) & property (ch10 market concentration) fixed - break; - case "free_for_all.peter_wayner.sst": // endnotes, bookindex, biblio - assert(check["last_object_number"] == - "1559","last object_number expected to be: 1559 rather than " ~ check["last_object_number"]); // 1560, check object_number off switches, has endnotes so 2 too many - // assert(check["last_object_number"] == "1559","last object_number expected to be: 1559 rather than " ~ check["last_object_number"]); - break; - case "gpl2.fsf.sst": - assert(check["last_object_number"] == - "65","last object_number expected to be: 65 rather than " ~ check["last_object_number"]); // ok endnotes? check - // assert(check["last_object_number"] == "66","last object_number expected to be: 66 rather than " ~ check["last_object_number"]); - break; - case "gpl3.fsf.sst": - assert(check["last_object_number"] == - "123","last object_number expected to be: 123 rather than " ~ check["last_object_number"]); // ok - break; - case "gullivers_travels.jonathan_swift.sst": - assert(check["last_object_number"] == - "668","last object_number expected to be: 668 rather than " ~ check["last_object_number"]); // 674 - break; - case "little_brother.cory_doctorow.sst": - assert(check["last_object_number"] == - "3130","last object_number expected to be: 3130 rather than " ~ check["last_object_number"]); // 3204, check object_number off switches - break; - case "the_cathedral_and_the_bazaar.eric_s_raymond.sst": - assert(check["last_object_number"] == - "258","last object_number expected to be: 258 rather than " ~ check["last_object_number"]); // ok - break; - case "the_public_domain.james_boyle.sst": - assert(check["last_object_number"] == - "970","last object_number expected to be: 970 rather than " ~ check["last_object_number"]); // 978 - break; - case "the_wealth_of_networks.yochai_benkler.sst": // endnotes, bookindex - assert(check["last_object_number"] == - "829","last object_number expected to be: 829 rather than " ~ check["last_object_number"]); // ok - // assert(check["last_object_number"] == "832","last object_number expected to be: 832 rather than " ~ check["last_object_number"]); - // has endnotes and bookindex, issue with sisu.rb - break; - case "through_the_looking_glass.lewis_carroll.sst": - assert(check["last_object_number"] == - "949","last object_number expected to be: 949 rather than " ~ check["last_object_number"]); // 955 - break; - case "two_bits.christopher_kelty.sst": // endnotes, bookindex, biblio - assert(check["last_object_number"] == - "1190","last object_number expected to be: 1190 rather than " ~ check["last_object_number"]); // 1191 - // assert(check["last_object_number"] == "1193","last object_number expected to be: 1193 rather than " ~ check["last_object_number"]); // 1191 ok? - // has endnotes and bookindex, issue with sisu.rb - break; - // fixed ERROR! range violation! - // error in bookindex ... (ch3 the movement) - case "un_contracts_international_sale_of_goods_convention_1980.sst": - assert(check["last_object_number"] == - "377","last object_number expected to be: 377 rather than " ~ check["last_object_number"]); // ok - break; - case "viral_spiral.david_bollier.sst": // endnotes, bookindex - assert(check["last_object_number"] == - "1078","last object_number expected to be: 1078 rather than " ~ check["last_object_number"]); // 1100 - // fixed ERROR! range violation! - // error in bookindex ... (ch7 ... building the cc machine, an extra semi colon) - break; - default: - writeln(doc_matters.src.filename); - break; - } - } - } - } - debug(checkdoc) { - void out_segnames(S,T)( - const S contents, - T doc_matters, - ) { - foreach (key; doc_matters.xml.keys_seq.seg) { - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - if (obj.heading_lev_markup == 4) { - writeln(obj.ptr_html_segnames, ". (", doc_matters.xml.segnames[obj.ptr_html_segnames], ") -> ", obj.text); - } - } - } - } - } - } - debug(checkdoc) { - void out_toc(S)( - const S contents, - string key, - ) { - if (contents[key].length > 1) { - string indent_spaces; - foreach (obj; contents[key]) { - indent_spaces=markup.indent_by_spaces_provided(obj.indent_hang); - writefln( - "%s%s", - indent_spaces, - obj.text - ); - } - } - } - } - debug(checkdoc) { - void out_endnotes(S)( - const S contents, - string key, - ) { - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s]\n%s", - obj.metainfo.is_a, - obj.text - ); - } - } - } - } - debug(checkdoc) { - void out_bookindex(S)( - const S contents, - string key, - ) { - if (contents[key].length > 1) { - foreach (obj; contents[key]) { - writefln( - "[%s][%s]\n%s", - obj.object_number, - obj.metainfo.is_a, - obj.text - ); - } - } - } - } - } - } - } -} diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d deleted file mode 100644 index 5821096..0000000 --- a/src/sdp/meta/metadoc.d +++ /dev/null @@ -1,177 +0,0 @@ -module sdp.meta.metadoc; -template SiSUabstraction() { - import - std.getopt, - std.file, - std.path, - std.process; - import - sdp.meta, - sdp.meta.metadoc_summary, - sdp.meta.metadoc_from_src, - sdp.meta.conf_make_meta_structs, - sdp.meta.conf_make_meta_toml, - sdp.meta.conf_make_meta_json, - sdp.meta.defaults, - sdp.meta.doc_debugs, - sdp.meta.rgx, - sdp.source.paths_source, - sdp.source.read_config_files, - sdp.source.read_source_files, - sdp.output.hub; - mixin SiSUrgxInit; - mixin contentJSONtoSiSUstruct; - mixin SiSUbiblio; - mixin SiSUrgxInitFlags; - mixin outputHub; - enum headBody { header, body_content, insert_file_list, image_list } - enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } - static auto rgx = Rgx(); - auto SiSUabstraction(E,O,M)( - E _env, - O _opt_action, - M _manifest - ){ - auto _config_document_struct = readConfigDoc!()(_manifest, _env); // document config file - auto _config_local_site_struct = readConfigSite!()(_manifest, _env); // local site config - ConfCompositePlus _make_and_meta_struct; - _make_and_meta_struct = configParseTOMLreturnSiSUstruct!()(_make_and_meta_struct, _config_document_struct); - _make_and_meta_struct = configParseTOMLreturnSiSUstruct!()(_make_and_meta_struct, _config_local_site_struct); - /+ ↓ read file (filename with path) +/ - /+ ↓ file tuple of header and content +/ - debug(steps) { - writeln("step1 commence → (get document header & body & insert file list & if needed image list)" - ); - } - auto _header_body_insertfilelist_imagelist - = SiSUrawMarkupContent!()(_opt_action, _manifest.src.path_and_fn); - static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist)); - static assert(_header_body_insertfilelist_imagelist.length==4); - debug(steps) { - writeln("- step1 complete"); - } - debug(header_and_body) { - writeln(header); - writeln(_header_body_insertfilelist_imagelist.length); - writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]); - } - /+ ↓ split header into make and meta +/ - debug(steps) { - writeln("step2 commence → (read document header - toml, return struct)"); - } - _make_and_meta_struct = - docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct!()( - _make_and_meta_struct, - _header_body_insertfilelist_imagelist[headBody.header] - ); - debug(steps) { - writeln("- step2 complete"); - } - /+ ↓ document abstraction: process document, return abstraction as tuple +/ - debug(steps) { - writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters)"); - } - auto da = SiSUdocAbstraction!()( - _header_body_insertfilelist_imagelist[headBody.body_content], - _make_and_meta_struct, - _opt_action, - _manifest, - true, - ); - static assert(!isTypeTuple!(da)); - static assert(da.length==5); - auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ - auto _document_section_keys_sequenced = da[docAbst.section_keys]; - string[] _doc_html_segnames = da[docAbst.segnames]; - string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; - auto _images = da[docAbst.images]; - debug(steps) { - writeln("- step3 complete"); - } - debug(steps) { - writeln("step4 commence → (doc_matters)"); - } - struct DocumentMatters { - auto conf_make_meta() { // TODO meld with all make instructions - return _make_and_meta_struct; - } - auto env() { - struct Env_ { - auto pwd() { - return _manifest.env.pwd; - } - auto home() { - return _manifest.env.home; - } - } - return Env_(); - } - auto opt() { - struct Opt_ { - auto action() { - /+ getopt options, commandline instructions, raw - - processing instructions --epub --html etc. - - command line config instructions --output-path - +/ - return _opt_action; - } - } - return Opt_(); - } - auto src() { - return _manifest.src; - } - auto src_path_info() { - return SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path - } - auto srcs() { - struct SRC_ { - auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - } - auto image_list() { - return _images; - } - } - return SRC_(); - } - auto pod() { - return _manifest.pod; - } - auto sqlite() { - struct SQLite_ { - string filename() { - return _opt_action.sqlite_filename; - } - } - return SQLite_(); - } - auto xml() { - struct XML_ { - auto keys_seq() { - /+ contains .seg & .scroll sequences +/ - return _document_section_keys_sequenced; - } - string[] segnames() { - return _doc_html_segnames; - } - string[] segnames_lv_0_to_4() { - return _doc_epub_segnames_0_4; - } - } - return XML_(); - } - auto output_path() { - return _manifest.output.path; - } - } - auto doc_matters = DocumentMatters(); - debug(steps) { - writeln("- step4 complete"); - } - auto t = tuple(doc_abstraction, doc_matters); - static assert(t.length==2); - return t; - } -} diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d deleted file mode 100644 index 1a568dd..0000000 --- a/src/sdp/meta/metadoc_from_src.d +++ /dev/null @@ -1,6322 +0,0 @@ -/++ - document abstraction: - abstraction of sisu markup for downstream processing - metadoc_from_src.d -+/ -module sdp.meta.metadoc_from_src; -template SiSUdocAbstraction() { - /+ ↓ abstraction imports +/ - import sdp.meta; - import - std.algorithm, - std.container, - std.file, - std.json, - std.path; - import - sdp.meta.defaults, - sdp.meta.object_setter, - sdp.meta.rgx; - /+ ↓ abstraction mixins +/ - mixin ObjectSetter; - mixin InternalMarkup; - mixin SiSUrgxInit; - /+ ↓ abstraction struct init +/ - /+ initialize +/ - ObjGenericComposite[][string] the_table_of_contents_section; - ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; - ObjGenericComposite[] the_dom_tail_section; - string[string] an_object, processing; - string an_object_key; - string[] anchor_tags; - string anchor_tag_; - string segment_anchor_tag_that_object_belongs_to; - string segment_anchor_tag_that_object_belongs_to_uri; - /+ enum +/ - enum State { off, on } - enum TriState { off, on, closing } - enum DocStructMarkupHeading { - h_sect_A, - h_sect_B, - h_sect_C, - h_sect_D, - h_text_1, - h_text_2, - h_text_3, - h_text_4, - h_text_5, // extra level, drop - content_non_header - } // header section A-D; header text 1-4 - enum OCNstatus { on, off, bkidx, closing, reset, } - enum OCNtype { ocn, non, bkidx, } - /+ biblio variables +/ - string biblio_tag_name, biblio_tag_entry, st; - string[] biblio_arr_json; - string biblio_entry_str_json; - JSONValue[] bib_arr_json; - int bib_entry; - /+ counters +/ - int cntr, previous_count, previous_length; - bool reset_note_numbers=true; - int[string] line_occur; - int html_segnames_ptr=0; - int html_segnames_ptr_cntr=0; - int verse_line, heading_ptr; - /+ paragraph attributes +/ - int[string] indent; - bool bullet = true; - string content_non_header = "8"; - static auto obj_im = ObjInlineMarkup(); - static auto obj_att = ObjAttributes(); - /+ ocn +/ - struct OCNset { - int digit; - int on; - int off; - int bkidx; - int type; - } - OCNset obj_cite_digits; - int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; - auto object_citation_number = OCNemitter(); - int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - enum DomTags { none, open, close, close_and_open, open_still, } - pure auto obj_heading_ancestors(O)( - O obj, - string[] lv_ancestors_txt, - ) { - switch (obj.metainfo.heading_lev_markup) { - case 0: - lv_ancestors_txt[0] = obj.text.to!string; - foreach(k; 1..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 1: - lv_ancestors_txt[1] = obj.text.to!string; - foreach(k; 2..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 2: - lv_ancestors_txt[2] = obj.text.to!string; - foreach(k; 3..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 3: - lv_ancestors_txt[3] = obj.text.to!string; - foreach(k; 4..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 4: - lv_ancestors_txt[4] = obj.text.to!string; - foreach(k; 5..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 5: - lv_ancestors_txt[5] = obj.text.to!string; - foreach(k; 6..8) { - lv_ancestors_txt[k] = ""; - } - goto default; - case 6: - lv_ancestors_txt[6] = obj.text.to!string; - lv_ancestors_txt[7] = ""; - goto default; - case 7: - lv_ancestors_txt[7] = obj.text.to!string; - goto default; - default: - obj.tags.heading_ancestors_text = lv_ancestors_txt.dup; - } - return obj; - } - pure auto obj_dom_structure_set_markup_tags(O)( - O obj, - int[] dom, - int lev - ) { - foreach (i; 0 .. 8) { - if (i < lev) { - if (dom[i] == DomTags.open - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.open_still; - } else if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } - } else if (i == lev) { - if (lev == 0 - && dom[i] == DomTags.open_still - ) { - dom[i] = DomTags.close; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close_and_open; - } else { - dom[i] = DomTags.open; - } - } else if (i > lev) { - if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close; - } - } - } - debug(dom_magic_numbers) { - writeln("marked up: ", lev, ": ", dom); - } - obj.metainfo.dom_structure_markedup_tags_status = dom.dup; - return obj; - } - pure auto obj_dom_set_collapsed_tags(O)( - O obj, - int[] dom, - int lev - ) { - foreach (i; 0 .. 8) { - if (i < lev) { - if (dom[i] == DomTags.open - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.open_still; - } else if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } - } else if (i == lev) { - if (lev == 0 - && dom[i] == DomTags.open_still - ) { - dom[i] = DomTags.close; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close_and_open; - } else { - dom[i] = DomTags.open; - } - } else if (i > lev) { - if (dom[i] == DomTags.close) { - dom[i] = DomTags.none; - } else if (dom[i] == DomTags.open - || dom[i] == DomTags.open_still - || dom[i] == DomTags.close_and_open - ) { - dom[i] = DomTags.close; - } - } - } - debug(dom_magic_numbers) { - writeln("collapsed: ", lev, ": ", dom); - } - obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; - return obj; - } - static auto ocn_emit(int ocn_status_flag) { - return object_citation_number.ocn_emitter(ocn_status_flag); - } - /+ book index variables +/ - string book_idx_tmp; - string[][string][string] bookindex_unordered_hashes; - /+ node +/ - ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; - auto node_construct = NodeStructureMetadata(); - enum sObj { content, anchor_tags, notes_reg, notes_star, links, image_no_dimensions } - /+ ↓ abstract marked up document +/ - auto SiSUdocAbstraction(Src,CMM,Opt,Mfst)( - Src markup_sourcefile_content, - CMM conf_make_meta, - Opt opt_action, - Mfst manifest_matter, - bool _new_doc - ) { - static auto rgx = Rgx(); - debug(asserts) { - static assert(is(typeof(markup_sourcefile_content) == char[][])); - } - /+ ↓ abstraction init +/ - scope(success) { - } - scope(failure) { - } - scope(exit) { - destroy(the_document_head_section); - destroy(the_table_of_contents_section); - destroy(the_document_body_section); - destroy(the_bibliography_section); - destroy(an_object); - destroy(processing); - destroy(biblio_arr_json); - previous_length=0; - reset_note_numbers=true; - } - mixin SiSUrgxInitFlags; - mixin SiSUnode; - auto node_para_int_ = node_metadata_para_int; - auto node_para_str_ = node_metadata_para_str; - ObjGenericComposite comp_obj_heading_, comp_obj_para, comp_obj_toc; - line_occur = [ - "heading" : 0, - "para" : 0, - "glossary" : 0, - "blurb" : 0, - ]; - auto obj_type_status = flags_type_init; - string[string] object_number_poem = [ - "start" : "", - "end" : "" - ]; - string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ]; - int[string] lv = [ - "lv" : State.off, - "h0" : State.off, - "h1" : State.off, - "h2" : State.off, - "h3" : State.off, - "h4" : State.off, - "h5" : State.off, - "h6" : State.off, - "h7" : State.off, - "lev_int_collapsed" : 0, - ]; - int[string] collapsed_lev = [ - "h0" : State.off, - "h1" : State.off, - "h2" : State.off, - "h3" : State.off, - "h4" : State.off, - "h5" : State.off, - "h6" : State.off, - "h7" : State.off - ]; - string[string] heading_match_str = [ - "h_A": "^(none)", - "h_B": "^(none)", - "h_C": "^(none)", - "h_D": "^(none)", - "h_1": "^(none)", - "h_2": "^(none)", - "h_3": "^(none)", - "h_4": "^(none)" - ]; - auto heading_match_rgx = [ - "h_A": regex(r"^(none)"), - "h_B": regex(r"^(none)"), - "h_C": regex(r"^(none)"), - "h_D": regex(r"^(none)"), - "h_1": regex(r"^(none)"), - "h_2": regex(r"^(none)"), - "h_3": regex(r"^(none)"), - "h_4": regex(r"^(none)") - ]; - string _anchor_tag; - string toc_txt_; - an_object["glossary_nugget"] = ""; - an_object["blurb_nugget"] = ""; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "frontmatter"; - comp_obj_heading_.metainfo.is_of_section = "toc"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Table of Contents"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "toc"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; - comp_obj_heading_.tags.anchor_tags = ["toc"]; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; - auto toc_head = comp_obj_heading_; - html_segnames_ptr_cntr++; - the_table_of_contents_section = [ - "seg": [toc_head], - "scroll": [toc_head], - ]; - static auto mkup = InlineMarkup(); - static auto munge = ObjInlineMarkupMunge(); - auto note_section = NotesSection(); - auto bookindex_extract_hash = BookIndexNuggetHash(); - string[][string] lev4_subtoc; - string[] html_segnames=["toc"]; - int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; - /+ abstraction init ↑ +/ - enum Substitute { match, markup, } - debug (substitutions) { - writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); - if (!(conf_make_meta.make.headings.empty)) { - writeln(conf_make_meta.make.headings); - } - if (conf_make_meta.make.substitute) { - foreach(substitution_pair; conf_make_meta.make.substitute) { - writeln("regex to match: ", substitution_pair[Substitute.match]); - writeln("substitution to make: ", substitution_pair[Substitute.markup]); - } - } - if (conf_make_meta.make.bold) { - writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]); - } - if (conf_make_meta.make.emphasis) { - writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]); - } - if (conf_make_meta.make.italics) { - writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]); - writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]); - } - } - /+ ↓ ↻ loop markup document/text line by line +/ - srcDocLoop: - foreach (line; markup_sourcefile_content) { - // "line" variable can be empty but should never be null - /+ ↓ markup document/text line by line +/ - /+ scope +/ - scope(exit) { - } - scope(failure) { - stderr.writefln( - "%s\n%s\n%s:%s failed here:\n line: %s", - __MODULE__, __FUNCTION__, - __FILE__, __LINE__, - line, - ); - } - line = (line).replaceAll(rgx.true_dollar, "$$$$"); - /+ dollar represented as $$ needed to stop submatching on $ - (substitutions using ${identifiers} must take into account (i.e. happen earlier)) - +/ - debug(source) { - writeln(line); - } - debug(srclines) { - if (!line.empty) { - writefln( - "* %s", - line - ); - } - } - if (!line.empty) { - obj_type_status = _check_ocn_status_(line, obj_type_status); - } - if (obj_type_status["code"] == TriState.on) { - /+ block object: code +/ - _code_block_(line, 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) +/ - /+ heading, glossary, blurb, poem, group, block, quote, table +/ - if (line.matchFirst(rgx.heading_biblio) - || (obj_type_status["biblio_section"] == State.on - && (!(line.matchFirst(rgx.heading_blurb_glossary))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) { - /+ within section (block object): biblio +/ - obj_type_status["glossary_section"] = State.off; - obj_type_status["biblio_section"] = State.on; - obj_type_status["blurb_section"] = State.off; - if (opt_action.backmatter && opt_action.section_biblio) { - _biblio_block_(line, obj_type_status, bib_entry, biblio_entry_str_json, biblio_arr_json); - debug(bibliobuild) { - writeln("- ", biblio_entry_str_json); - writeln("-> ", biblio_arr_json.length); - } - } - continue; - } else if (line.matchFirst(rgx.heading_glossary) - || (obj_type_status["glossary_section"] == State.on - && (!(line.matchFirst(rgx.heading_biblio_blurb))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) { - /+ within section (block object): glossary +/ - debug(glossary) { - writeln(__LINE__); - writeln(line); - } - obj_type_status["glossary_section"] = State.on; - obj_type_status["biblio_section"] = State.off; - obj_type_status["blurb_section"] = State.off; - if (opt_action.backmatter && opt_action.section_glossary) { - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - obj_type_status["para"] = State.on; - line_occur["para"] = State.off; - an_object_key="glossary_nugget"; // - if (line.matchFirst(rgx.heading_glossary)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "glossary"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Glossary"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_glossary"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_glossary_section ~= comp_obj_heading_; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "glossary"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Glossary"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "glossary"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; - comp_obj_heading_.tags.anchor_tags = ["glossary"]; - the_glossary_section ~= comp_obj_heading_; - } else { - _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); - comp_obj_para = comp_obj_para.init; - comp_obj_para.metainfo.is_of_part = "backmatter"; - comp_obj_para.metainfo.is_of_section = "glossary"; - comp_obj_para.metainfo.is_of_type = "para"; - comp_obj_para.metainfo.is_a = "glossary"; - comp_obj_para.text = line.to!string.strip; - comp_obj_para.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_para.attrib.indent_hang = indent["hang_position"]; - comp_obj_para.attrib.indent_base = indent["base_position"]; - comp_obj_para.attrib.bullet = bullet; - the_glossary_section ~= comp_obj_para; - } - obj_type_status["ocn_status"] = OCNstatus.on; - } - continue; - } else if (line.matchFirst(rgx.heading_blurb) - || (obj_type_status["blurb_section"] == State.on - && (!(line.matchFirst(rgx.heading_biblio_glossary))) - && (!(line.matchFirst(rgx.heading))) - && (!(line.matchFirst(rgx.comment))))) { - /+ within section (block object): blurb +/ - debug(blurb) { - writeln(__LINE__); - writeln(line); - } - obj_type_status["glossary_section"] = State.off; - obj_type_status["biblio_section"] = State.off; - obj_type_status["blurb_section"] = State.on; - if (opt_action.backmatter && opt_action.section_blurb) { - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - if (auto m = line.matchFirst(rgx.para_indent)) { - debug(paraindent) { - writeln(line); - } - indent["hang_position"] = (m.captures[1]).to!int; - indent["base_position"] = 0; - } else if (line.matchFirst(rgx.para_bullet)) { - debug(parabullet) { - writeln(line); - } - bullet = true; - } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { - debug(paraindenthang) { - writeln(line); - } - indent=[ - "hang_position" : (m.captures[1]).to!int, - "base_position" : (m.captures[2]).to!int, - ]; - } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { - debug(parabulletindent) { - writeln(line); - } - indent=[ - "hang_position" : (m.captures[1]).to!int, - "base_position" : 0, - ]; - bullet = true; - } - obj_type_status["para"] = State.on; - line_occur["para"] = State.off; - an_object_key="blurb_nugget"; - if (line.matchFirst(rgx.heading_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 = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; - 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 = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["blurb"]; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; - } 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.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "blurb"; - 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_; - } else { - _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); - comp_obj_para = comp_obj_para.init; - comp_obj_para.metainfo.is_of_part = "backmatter"; - comp_obj_para.metainfo.is_of_section = "blurb"; - comp_obj_para.metainfo.is_of_type = "para"; - comp_obj_para.metainfo.is_a = "blurb"; - comp_obj_para.text = munge.url_links(line.to!string.strip).replaceFirst(rgx.para_attribs, ""); - comp_obj_para.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_para.attrib.indent_hang = indent["hang_position"]; - comp_obj_para.attrib.indent_base = indent["base_position"]; - comp_obj_para.has.inline_links = true; - comp_obj_para.attrib.bullet = bullet; - the_blurb_section ~= comp_obj_para; - } - obj_type_status["ocn_status"] = OCNstatus.on; - } - continue; - } else if (obj_type_status["quote"] == TriState.on) { - /+ within block object: quote +/ - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); - _quote_block_(line, an_object, obj_type_status); - continue; - /+ within block object: group +/ - } else if (obj_type_status["group"] == TriState.on) { - /+ within block object: group +/ - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); - line = (line) - .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); - _group_block_(line, an_object, obj_type_status); - continue; - } else if (obj_type_status["block"] == TriState.on) { - /+ within block object: block +/ - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); - if (auto m = line.match(rgx.spaces_line_start)) { - line = (line) - .replaceAll(rgx.spaces_line_start, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); - } - if (auto m = line.match(rgx.spaces_multiple)) { - line = (line) - .replaceAll(rgx.spaces_multiple, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); - } - _block_block_(line, an_object, obj_type_status); - continue; - } else if (obj_type_status["poem"] == TriState.on) { - /+ within block object: poem +/ - _poem_block_(line, an_object, obj_type_status, cntr, object_number_poem, conf_make_meta); - continue; - } else if (obj_type_status["table"] == TriState.on) { - /+ within block object: table +/ - _table_block_(line, an_object, obj_type_status, conf_make_meta); - continue; - } else { - /+ not within a block group +/ - assert( - (obj_type_status["blocks"] == TriState.off) - || (obj_type_status["blocks"] == TriState.closing), - "block status: none or closed" - ); - 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! +/ - object_reset(an_object); - processing.remove("verse"); - object_number_poem["start"] = obj_cite_digits.on.to!string; - } - _start_block_(line, obj_type_status, object_number_poem); - continue; - } else if (!line.empty) { - /+ line not empty +/ - /+ non blocks (headings, paragraphs) & closed blocks +/ - assert( - !line.empty, - "line tested, line not empty surely:\n \"" ~ line ~ "\"" - ); - assert( - (obj_type_status["blocks"] == TriState.off) - || (obj_type_status["blocks"] == TriState.closing), - "code block status: none or closed" - ); - if (obj_type_status["blocks"] == TriState.closing) { - debug(check) { // block - writeln(__LINE__); - writeln(line); - } - assert( - line.matchFirst(rgx.book_index) - || line.matchFirst(rgx.book_index_open) - || obj_type_status["book_index"] == State.on, - "\nblocks closed, unless followed by book index, non-matching line:\n \"" - ~ line ~ "\"" - ); - } - if (line.matchFirst(rgx.book_index) - || line.matchFirst(rgx.book_index_open) - || obj_type_status["book_index"] == State.on ) { - /+ book_index +/ - _book_index_(line, book_idx_tmp, an_object, obj_type_status, opt_action); - } else { - /+ not book_index +/ - an_object_key="body_nugget"; - if (auto m = matchFirst(line, rgx.comment)) { - /+ matched comment +/ - debug(comment) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; - comp_obj_comment = comp_obj_comment.init; - comp_obj_comment.metainfo.is_of_part = "comment"; // breaks flow - comp_obj_comment.metainfo.is_of_section = "comment"; // breaks flow - comp_obj_comment.metainfo.is_of_type = "comment"; - comp_obj_comment.metainfo.is_a = "comment"; - comp_obj_comment.text = an_object[an_object_key].strip; - the_document_body_section ~= comp_obj_comment; - _common_reset_(line_occur, an_object, obj_type_status); - processing.remove("verse"); - ++cntr; - } 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 +/ - if ((conf_make_meta.make.headings.length > 2) - && (obj_type_status["make_headings"] == State.off)) { - /+ heading found +/ - _heading_found_(line, 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 +/ - line = _heading_make_set_(line, line_occur, heading_match_rgx, obj_type_status); - } - /+ TODO node info: all headings identified at this point, - - extract node info here?? - - how long can it wait? - - should be incorporated in composite objects - - should happen before endnote links set (they need to be moved down?) - +/ - if (line.matchFirst(rgx.heading)) { - /+ heading match +/ - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - _heading_matched_(line, 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 +/ - an_object_key="body_nugget"; - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); - _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); - } - } 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 +/ - debug(para) { - writeln(an_object_key, "-> ", line); - } - line = _doc_header_and_make_substitutions_(line, conf_make_meta); - line = _doc_header_and_make_substitutions_fontface_(line, 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 +/ - _block_flag_line_empty_( - bookindex_extract_hash, - line, - an_object, - the_document_body_section, - bookindex_unordered_hashes, - obj_cite_digits, - comp_obj_heading, - cntr, - obj_type_status, - object_number_poem, - conf_make_meta, - ); - } else { - /+ line.empty, post contents, empty variables: +/ - assert( - line.empty, - "\nline should be empty:\n \"" - ~ line ~ "\"" - ); - assert( - (obj_type_status["blocks"] == State.off), - "code block status: none" - ); - if ((obj_type_status["heading"] == State.on) - && (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(OCNstatus.on); - an_object["is"] = "heading"; - an_object_key="body_nugget"; - auto substantive_object_and_anchor_tags_tuple - = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, _new_doc); - an_object["substantive"] = substantive_object_and_anchor_tags_tuple[sObj.content]; - anchor_tags = substantive_object_and_anchor_tags_tuple[sObj.anchor_tags]; - if (_new_doc) { - cnt1 = 1; - cnt2 = 1; - cnt3 = 1; - _new_doc = false; - } - if ( - an_object["lev_markup_number"].to!int == 4 - && anchor_tags.length > 0 - ) { - segment_anchor_tag_that_object_belongs_to = anchor_tags[0]; - segment_anchor_tag_that_object_belongs_to_uri = anchor_tags[0] ~ ".fnSuffix"; - anchor_tag_ = anchor_tags[0]; - } else if (an_object["lev_markup_number"].to!int > 4) { - segment_anchor_tag_that_object_belongs_to = anchor_tag_; - segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digits.on.to!string; - } else if (an_object["lev_markup_number"].to!int < 4) { - string segn; - switch (an_object["lev_markup_number"].to!int) { - case 0: - segn = "_the_title"; - goto default; - case 1: - segn = "_part_" ~ cnt1.to!string; - ++cnt1; - goto default; - case 2: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; - ++cnt2; - goto default; - case 3: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; - ++cnt3; - goto default; - default: - segment_anchor_tag_that_object_belongs_to = segn; - segment_anchor_tag_that_object_belongs_to_uri = segn ~ ".fnSuffix"; - break; - } - } - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); - /+ (incrementally build toc) table of contents here! +/ - _anchor_tag=to!string(obj_cite_digits.on); - the_table_of_contents_section = obj_im.table_of_contents_gather_headings( - an_object, - conf_make_meta, - segment_anchor_tag_that_object_belongs_to, - _anchor_tag, - lev4_subtoc, - the_table_of_contents_section, - ); - if (an_object["lev_markup_number"] == "4") { - html_segnames ~= segment_anchor_tag_that_object_belongs_to; - html_segnames_ptr = html_segnames_ptr_cntr; - html_segnames_ptr_cntr++; - } - auto comp_obj_heading - = node_construct.node_emitter_heading( - an_object["substantive"], // string - an_object["lev_markup_number"], // string - an_object["lev_collapsed_number"], // string - segment_anchor_tag_that_object_belongs_to, // string - obj_cite_digits, // OCNset - cntr, // int - heading_ptr, // int - lv_ancestors_txt, // string[] - an_object["is"], // string - html_segnames_ptr, // int - substantive_object_and_anchor_tags_tuple[sObj.notes_reg], - substantive_object_and_anchor_tags_tuple[sObj.notes_star], - substantive_object_and_anchor_tags_tuple[sObj.links], - ); - ++heading_ptr; - debug(segments) { - writeln(an_object["lev_markup_number"]); - writeln(segment_anchor_tag_that_object_belongs_to); - } - the_document_body_section ~= comp_obj_heading; - debug(objectrelated1) { // check - writeln(line); - } - _common_reset_(line_occur, an_object, obj_type_status); - an_object.remove("lev"); - an_object.remove("lev_markup_number"); - processing.remove("verse"); - ++cntr; - } else if ((obj_type_status["para"] == State.on) - && (line_occur["para"] > State.off)) { - /+ paragraph object (current line empty) +/ - obj_cite_digits = ocn_emit(obj_type_status["ocn_status"]); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); - an_object["is"] = "para"; - auto comp_obj_heading - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; - comp_obj_para = comp_obj_para.init; - comp_obj_para.metainfo.is_of_part = "body"; - comp_obj_para.metainfo.is_of_section = "body"; - comp_obj_para.metainfo.is_of_type = "para"; - comp_obj_para.metainfo.is_a = "para"; - comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.metainfo.ocn = obj_cite_digits.digit; - comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_para.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_para.attrib.indent_hang = indent["hang_position"]; - comp_obj_para.attrib.indent_base = indent["base_position"]; - comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; - comp_obj_para.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_para.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - comp_obj_para.has.contains_image_without_dimensions = substantive_obj_misc_tuple[sObj.image_no_dimensions]; - the_document_body_section ~= comp_obj_para; - _common_reset_(line_occur, an_object, obj_type_status); - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - processing.remove("verse"); - ++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 - /+ unless (the_document_body_section.length == 0) ? +/ - if (the_document_body_section.length > 0) { - if (((the_document_body_section[$-1].metainfo.is_a == "para") - || (the_document_body_section[$-1].metainfo.is_a == "heading") - || (the_document_body_section[$-1].metainfo.is_a == "quote") - || (the_document_body_section[$-1].metainfo.is_a == "group") - || (the_document_body_section[$-1].metainfo.is_a == "block") - || (the_document_body_section[$-1].metainfo.is_a == "verse")) - && (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["blurb_section"] = State.off; - } - 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( - rgx.inline_notes_delimiter_al_regular_number_note - )) { - note_section.gather_notes_for_endnote_section( - the_document_body_section, - segment_anchor_tag_that_object_belongs_to, - (i).to!int, - ); - } - } - } - } 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_delimiter_al_regular_number_note - )) { - previous_count=(the_document_body_section.length -1).to!int; - note_section.gather_notes_for_endnote_section( - the_document_body_section, - segment_anchor_tag_that_object_belongs_to, - (the_document_body_section.length-1).to!int, - ); - } - } - previous_length = the_document_body_section.length.to!int; - } - } - } /+ ← 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); - static assert(!isTypeTuple!(en_tuple)); - auto the_endnotes_section = en_tuple[0]; - obj_cite_digits = en_tuple[1]; - debug(endnotes) { - writefln( - "%s %s", - __LINE__, - the_endnotes_section.length - ); - foreach (o; the_endnotes_section) { - writeln(o); - } - } - if (an_object["glossary_nugget"].length == 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Glossary section"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_glossary_section ~= comp_obj_heading_; - } - debug(glossary) { - foreach (gloss; the_glossary_section) { - writeln(gloss.text); - } - } - auto biblio_unsorted_incomplete = biblio_arr_json.dup; - auto biblio = Bibliography(); - auto biblio_ordered - = biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json); - if (biblio_ordered.length > 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_bibliography"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_bibliography_section ~= comp_obj_heading_; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "bibliography"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["bibliography"]; - the_bibliography_section ~= comp_obj_heading_; - } else { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Bibliography"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_bibliography_section ~= comp_obj_heading_; - } - string out_; - foreach (entry; biblio_ordered) { - out_ = format( - "%s \"%s\"%s%s%s%s%s%s%s%s%s.", - ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str), - entry["fulltitle"].str, - ((entry["journal"].str.empty) ? "" : ", /{" ~ entry["journal"].str ~ "}/"), - ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str), - ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str), - ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""), - ", " ~ entry["year"].str, - ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str), - ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str), - ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str), - ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"), - ); - comp_obj_para = comp_obj_para.init; - comp_obj_para.metainfo.is_of_part = "backmatter"; - comp_obj_para.metainfo.is_of_section = "bibliography"; - comp_obj_para.metainfo.is_of_type = "para"; - comp_obj_para.metainfo.is_a = "bibliography"; - comp_obj_para.text = out_.to!string.strip; - comp_obj_para.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_para.attrib.indent_hang = 0; - comp_obj_para.attrib.indent_base = 1; - comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; - the_bibliography_section ~= comp_obj_para; - } - debug(bibliosection) { - foreach (o; the_bibliography_section) { - writeln(o.text); - } - } - auto bi = BookIndexReportSection(); - auto bi_tuple - = bi.bookindex_build_abstraction_section( - bookindex_unordered_hashes, - obj_cite_digits, - opt_action, - ); - destroy(bookindex_unordered_hashes); - static assert(!isTypeTuple!(bi_tuple)); - auto the_bookindex_section = bi_tuple[0]; - obj_cite_digits = bi_tuple[1]; - debug(bookindex) { - foreach (bi_entry; the_bookindex_section["seg"]) { - writeln(bi_entry); - } - } - if (an_object["blurb_nugget"].length == 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Blurb section"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = ""; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; - } - debug(blurb) { - foreach (blurb; the_blurb_section) { - writeln(blurb.text); - } - } - indent=[ - "hang_position" : 1, - "base_position" : 1, - ]; - comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.metainfo.is_of_part = "frontmatter"; - comp_obj_toc.metainfo.is_of_section = "toc"; - comp_obj_toc.metainfo.is_of_type = "para"; - comp_obj_toc.metainfo.is_a = "toc"; - comp_obj_toc.metainfo.ocn = 0; - comp_obj_toc.metainfo.object_number_off = ""; - comp_obj_toc.metainfo.object_number_type = 0; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.attrib.bullet = false; - if (the_endnotes_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Endnotes", - mkup.mark_internal_site_lnk, - "endnotes", // segment_anchor_tag_that_object_belongs_to - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - } - if (the_glossary_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Glossary", - mkup.mark_internal_site_lnk, - "glossary", // segment_anchor_tag_that_object_belongs_to - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - toc_txt_ = format( - "{ %s }#%s", - "Glossary", - "glossary", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - if (the_bibliography_section.length > 1){ - toc_txt_ = format( - "{ %s }%s%s%s", - "Bibliography", - mkup.mark_internal_site_lnk, - "bibliography", // segment_anchor_tag_that_object_belongs_to - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - - toc_txt_ = format( - "{ %s }#%s", - "Bibliography", - "bibliography", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - if (the_bookindex_section["seg"].length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Book Index", - mkup.mark_internal_site_lnk, - "bookindex", // segment_anchor_tag_that_object_belongs_to - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - } - if (the_bookindex_section["scroll"].length > 1) { - toc_txt_ = format( - "{ %s }#%s", - "Book Index", - "bookindex", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - if (the_blurb_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Blurb", - mkup.mark_internal_site_lnk, - "blurb", // segment_anchor_tag_that_object_belongs_to - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - toc_txt_ = format( - "{ %s }#%s", - "Blurb", - "blurb", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.has.inline_links = true; - comp_obj_toc.text = toc_txt_.to!string.strip; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - debug(toc) { - writefln( - "%s %s", - __LINE__, - the_table_of_contents_section["seg"].length - ); - foreach (toc_linked_heading; the_table_of_contents_section["seg"]) { - writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); - } - } - debug(tocscroll) { - writefln( - "%s %s", - __LINE__, - the_table_of_contents_section["seg"].length - ); - foreach (toc_linked_heading; the_table_of_contents_section["scroll"]) { - writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); - } - } - the_document_head_section ~= the_document_body_section[0]; - the_document_body_section=the_document_body_section[1..$]; - int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup == 1) { - _ancestors_markup = [ - _ancestors_markup[0], - 0,0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 2) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - 0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 3) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - 0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 4) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - 0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 5) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - 0,0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 6) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - 0,0 - ]; - } - if (obj.metainfo.heading_lev_markup == 7) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - _ancestors_markup[6], - 0 - ]; - } - if (obj.metainfo.heading_lev_markup == 8) { - _ancestors_markup = [ - _ancestors_markup[0], - _ancestors_markup[1], - _ancestors_markup[2], - _ancestors_markup[3], - _ancestors_markup[4], - _ancestors_markup[5], - _ancestors_markup[6], - _ancestors_markup[7] - ]; - } - _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; - } - debug(ancestor_markup) { - writeln("marked up: ", _ancestors_markup); - } - return _ancestors_markup; - } - int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { - if (obj.metainfo.is_a == "heading") { - if (obj.metainfo.heading_lev_collapsed == 1) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - 0,0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 2) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - 0,0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 3) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - 0,0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 4) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - 0,0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 5) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - 0,0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 6) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - 0,0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 7) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - _ancestors_collapsed[6], - 0 - ]; - } - if (obj.metainfo.heading_lev_collapsed == 8) { - _ancestors_collapsed = [ - _ancestors_collapsed[0], - _ancestors_collapsed[1], - _ancestors_collapsed[2], - _ancestors_collapsed[3], - _ancestors_collapsed[4], - _ancestors_collapsed[5], - _ancestors_collapsed[6], - _ancestors_collapsed[7] - ]; - } - _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; - } - debug(ancestor_collapsed) { - writeln("collapsed: ", _ancestors_collapsed); - } - return _ancestors_collapsed; - } - /+ multiple 1~ levels, loop through document body +/ - if (the_document_body_section.length > 1) { - int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; - int[][] _ancestors_markup_; - _ancestors_markup = [1,0,0,0,0,0,0,0]; - _ancestors_markup_ ~= _ancestors_markup; - int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; - int[][] _ancestors_collapsed_; - _ancestors_collapsed = [1,0,0,0,0,0,0,0]; - _ancestors_collapsed_ ~= _ancestors_collapsed; - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); - obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed); - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - } - debug(ancestors) { - writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); - writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); - } - } - if (the_endnotes_section.length > 1) { - html_segnames ~= "endnotes"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_endnotes_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_glossary_section.length > 1) { - html_segnames ~= "glossary"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_glossary_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_bibliography_section.length > 1) { - html_segnames ~= "bibliography"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_bookindex_section["scroll"].length > 1) { - html_segnames ~= "bookindex"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_bookindex_section["scroll"]) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - foreach (ref obj; the_bookindex_section["seg"]) { - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - if (the_blurb_section.length > 1) { - html_segnames ~= "blurb"; - html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_blurb_section) { - if (obj.metainfo.is_a == "heading") { - obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; - } - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } - html_segnames_ptr_cntr++; - } - auto get_decendants(S)(S document_sections) { - int[string] _heading_ocn_decendants; - string[] _ocn_open_key = ["","","","","","","",""]; - auto _doc_sect_length = document_sections.length - 1; - int _last_ocn; - foreach (_lg, ref obj; document_sections) { - if (obj.metainfo.is_a == "heading") { - foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) { - switch (dom_tag_status) { - case DomTags.none: break; - case DomTags.open: - _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; - _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; - break; - case DomTags.close: - if (_ocn_open_key[_dts_lv].empty) { - _ocn_open_key[_dts_lv] = "0"; - } - _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; - _ocn_open_key[_dts_lv] = (0).to!string; - break; - case DomTags.close_and_open: - if (_ocn_open_key[_dts_lv].empty) { - _ocn_open_key[_dts_lv] = "0"; - } - _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1; - _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string; - _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn; - break; - case DomTags.open_still: break; - default: break; - } - } - } - if (obj.metainfo.ocn > 0) { - _last_ocn = obj.metainfo.ocn; - } - if (_lg == _doc_sect_length) { - _heading_ocn_decendants["1"] = _last_ocn; // close existing o_n key - } - } - Tuple!(int, int)[] pairs; - foreach (pair; _heading_ocn_decendants.byPair) { - pairs ~= tuple(pair[0].to!int, pair[1]); - } - return pairs.sort; - } - string[] _images; - auto extract_images(S)(S content_block) { - string[] images_; - if (auto m = content_block.matchAll(rgx.image)) { - images_ ~= m.captures[1]; - } - return images_; - } - string[] segnames_0_4; - auto _image_dimensions(M,O)(M manifest_matter, O obj) { - if (obj.has.contains_image_without_dimensions) { - import std.math; - import imageformats; - int w, h, chans; - real _w, _h; - int max_width = 640; - foreach (m; obj.text.matchAll(rgx.inline_image_without_dimensions)) { - debug(images) { - writeln(manifest_matter.src.image_dir_path ~ "/" ~ m.captures["img"]); - } - read_image_info(manifest_matter.src.image_dir_path ~ "/" ~ m.captures["img"], w, h, chans); - // calculate, decide max width and proportionally reduce to keep w & h within it - debug(images) { - writeln("width: ", w, ", height: ", h); - } - if (w > max_width) { - _w = max_width; - _h = round((max_width / w.to!real) * h.to!real); - } else { - _w = w; - _h = h; - } - obj.text = obj.text.replaceFirst( - rgx.inline_image_without_dimensions, - ("$1☼$3,w" ~ _w.to!string ~ "h" ~ _h.to!string ~ " $6") - ); - } - debug(images) { - writeln("image without dimensions: ", obj.text); - } - } - return obj; - } - foreach (ref obj; the_document_head_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - } - if (obj.metainfo.heading_lev_markup == 0) { - /+ TODO second hit (of two) with same assertion failure, check, fix and reinstate - assert( obj.metainfo.ocn == 1, - "Title OCN should be 1 not: " ~ obj.metainfo.ocn.to!string); // bug introduced 0.18.1 - +/ - obj.metainfo.ocn = 1; - obj.metainfo.object_number_type = OCNtype.ocn; - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } - } - if (the_table_of_contents_section["scroll"].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_table_of_contents_section["scroll"]) { - if (obj.metainfo.is_a == "heading") { - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } - } - /+ seg +/ - dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; - dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; - foreach (ref obj; the_table_of_contents_section["seg"]) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } - } - } - /+ multiple 1~ levels, loop through document body +/ - if (the_document_body_section.length > 1) { - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.segment_anchor_tag]; - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "para") { - _images ~= extract_images(obj.text); - obj = _image_dimensions(manifest_matter, obj); - } - } - } - auto images=uniq(_images.sort()); - /+ optional only one 1~ level +/ - if (the_endnotes_section.length > 1) { - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; - dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; - dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; - dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; - foreach (ref obj; the_endnotes_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.digit; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } - } - } - /+ optional only one 1~ level +/ - if (the_glossary_section.length > 1) { - foreach (ref obj; the_glossary_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.digit; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "glossary") { - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.digit; - } - } - } - /+ optional only one 1~ level +/ - if (the_bibliography_section.length > 1) { - foreach (ref obj; the_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.digit; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "bibliography") { - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.on; - } - } - } - /+ optional only one 1~ level +/ - int ocn_ = obj_cite_digits.on; - int ocn_bkidx_ = 0; - int ocn_bidx_; - if (the_bookindex_section["scroll"].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["scroll"]) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - } - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.on; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "bookindex") { - obj_cite_digits = ocn_emit(OCNstatus.bkidx); - obj.metainfo.ocn = obj_cite_digits.digit; - obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; - obj.metainfo.object_number_type = OCNtype.bkidx; - } - } - /+ seg +/ - dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; - dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; - foreach (ref obj; the_bookindex_section["seg"]) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - obj.metainfo.ocn = ++ocn_; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "bookindex") { - ocn_bidx_ = ++ocn_bkidx_; - obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn - obj.metainfo.object_number_type = OCNtype.bkidx; - } - } - /+ TODO assert failure, reinstate - assert(obj_cite_digit_bkidx == ocn_bidx_ - obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); - +/ - } - /+ optional only one 1~ level +/ - if (the_blurb_section.length > 1) { - foreach (ref obj; the_blurb_section) { - if (obj.metainfo.is_a == "heading") { - debug(dom) { - writeln(obj.text); - } - obj_cite_digits = ocn_emit(OCNstatus.on); - obj.metainfo.ocn = obj_cite_digits.on; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); - } - obj = obj_heading_ancestors(obj, lv_ancestors_txt); - } else if (obj.metainfo.is_a == "blurb") { - obj_cite_digits = ocn_emit(OCNstatus.off); - obj.metainfo.object_number_off = obj_cite_digits.off.to!string; - obj.metainfo.object_number_type = OCNtype.non; - } - } - } - if (the_document_body_section.length > 1) { - auto pairs = get_decendants( - the_document_head_section ~ - the_document_body_section ~ - the_endnotes_section ~ - the_glossary_section ~ - the_bibliography_section ~ - the_bookindex_section["scroll"] ~ - the_blurb_section - ); - debug(decendants_tuple) { - pairs = pairs.sort(); - foreach (pair; pairs) { // (pair; pairs.sort()) - writeln(pair[0], "..", pair[1]); - } - } - foreach (ref obj; the_document_head_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - if (the_document_body_section.length > 1) { - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - if (the_endnotes_section.length > 1) { - foreach (ref obj; the_endnotes_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - if (the_glossary_section.length > 1) { - foreach (ref obj; the_glossary_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - if (the_bibliography_section.length > 1) { - foreach (ref obj; the_bibliography_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - if (the_bookindex_section["scroll"].length > 1) { - foreach (ref obj; the_bookindex_section["scroll"]) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - if (the_blurb_section.length > 1) { - foreach (ref obj; the_blurb_section) { - if (obj.metainfo.is_a == "heading") { - foreach (pair; pairs) { - if (obj.metainfo.ocn == pair[0]) { - obj.metainfo.last_decendant_ocn = pair[1]; - } - } - } - } - } - } - /+ 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"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = ""; - comp_obj_heading_.metainfo.heading_lev_markup = 9; - comp_obj_heading_.metainfo.heading_lev_collapsed = 9; - comp_obj_heading_.metainfo.parent_ocn = 0; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; - comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; - comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_structure_markedup_tags_status, 0); - comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_structure_collapsed_tags_status, 0); - comp_obj_heading_ = obj_heading_ancestors(comp_obj_heading_, lv_ancestors_txt); - // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later - auto document_the = [ - "head": the_document_head_section, - "toc_seg": the_table_of_contents_section["seg"], - "toc_scroll": the_table_of_contents_section["scroll"], - /+ substantive/body: +/ - "body": the_document_body_section, - /+ backmatter: +/ - "endnotes": the_endnotes_section, - "glossary": the_glossary_section, - "bibliography": the_bibliography_section, - "bookindex_scroll": the_bookindex_section["scroll"], - "bookindex_seg": the_bookindex_section["seg"], - "blurb": the_blurb_section, - /+ dom tail only +/ - "tail": the_dom_tail_section, - ]; - string[][string] document_section_keys_sequenced = [ - "seg": ["head", "toc_seg", "body",], - "scroll": ["head", "toc_scroll", "body",], - "sql": ["head", "body",] - ]; - if (document_the["endnotes"].length > 1) { - document_section_keys_sequenced["seg"] ~= "endnotes"; - document_section_keys_sequenced["scroll"] ~= "endnotes"; - } - if (document_the["glossary"].length > 1) { - document_section_keys_sequenced["seg"] ~= "glossary"; - document_section_keys_sequenced["scroll"] ~= "glossary"; - document_section_keys_sequenced["sql"] ~= "glossary"; - } - if (document_the["bibliography"].length > 1) { - document_section_keys_sequenced["seg"] ~= "bibliography"; - document_section_keys_sequenced["scroll"] ~= "bibliography"; - document_section_keys_sequenced["sql"] ~= "bibliography"; - } - if (document_the["bookindex_seg"].length > 1) { - document_section_keys_sequenced["seg"] ~= "bookindex_seg"; - document_section_keys_sequenced["sql"] ~= "bookindex_seg"; - } - if (document_the["bookindex_scroll"].length > 1) { - document_section_keys_sequenced["scroll"] ~= "bookindex_scroll"; - } - if (document_the["blurb"].length > 1) { - document_section_keys_sequenced["seg"] ~= "blurb"; - document_section_keys_sequenced["scroll"] ~= "blurb"; - document_section_keys_sequenced["sql"] ~= "blurb"; - } - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub)) { - document_section_keys_sequenced["seg"] ~= "tail"; - document_section_keys_sequenced["scroll"] ~= "tail"; - } - auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced); - auto segnames = html_segnames.dup; - destroy(the_document_head_section); - destroy(the_table_of_contents_section); - destroy(the_document_body_section); - destroy(the_endnotes_section); - destroy(the_glossary_section); - destroy(the_bibliography_section); - destroy(the_bookindex_section); - destroy(the_blurb_section); - destroy(html_segnames); - destroy(bookindex_unordered_hashes); - destroy(an_object); - obj_cite_digits = ocn_emit(OCNstatus.reset); - biblio_arr_json = []; - obj_cite_digit_ = 0; - html_segnames_ptr = 0; - html_segnames_ptr_cntr = 0; - content_non_header = "8"; - dom_structure_markedup_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 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - debug(abstraction) { - foreach (part; sequenced_document_keys.scroll) { - foreach (ref obj; document_the[part]) { - debug(node_misc) { - if (obj.metainfo.is_a == "heading") { - writeln("heading ancestors text?: ", obj.tags.heading_ancestors_text); - } - } - debug(node_headings) { - if (obj.metainfo.is_a == "heading") { - writeln("---"); - writeln(obj.text); - writeln(" node: ", obj.metainfo.node); - writeln(" ocn: ", obj.metainfo.ocn); - writeln(" markedup heading lev: ", obj.metainfo.heading_lev_markup); - writeln(" collapsed heading lev ", obj.metainfo.heading_lev_collapsed); - writeln(" parent ocn: ", obj.metainfo.parent_ocn); - writeln(" parent lev: ", obj.metainfo.parent_lev_markup); - writeln(" markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); - writeln(" dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); - writeln(" collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); - writeln(" dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); - } - } - debug(node_all) { - writeln("---"); - if (obj.metainfo.is_a == "heading") { - writeln(obj.text); - } - writeln("node: ", obj.metainfo.node); - writeln("ocn: ", obj.metainfo.ocn); - writeln("markedup heading lev: ", obj.metainfo.heading_lev_markup); - writeln("collapsed heading lev ", obj.metainfo.heading_lev_collapsed); - writeln("markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); - writeln("collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); - writeln("dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); - writeln("dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); - writeln("parent ocn: ", obj.metainfo.parent_ocn); - writeln("parent lev: ", obj.metainfo.parent_lev_markup); - writeln("Node: ", obj.metainfo.ocn); - } - } - } - } - auto t = tuple( - document_the, - sequenced_document_keys, - segnames, - segnames_0_4, - images, - ); - return t; - /+ post loop markup document/text ↑ +/ - } /+ ← closed: abstract doc source +/ - /+ ↓ abstraction functions +/ - static auto object_reset(O)(O an_object) { - debug(asserts) { - static assert(is(typeof(an_object) == string[string])); - } - an_object.remove("body_nugget"); - an_object.remove("substantive"); - an_object.remove("is"); - an_object.remove("attrib"); - an_object.remove("bookindex_nugget"); - return an_object; - } - auto _common_reset_(L,O,T)( - return ref L line_occur, - return ref O an_object, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line_occur) == int[string])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - line_occur["heading"] = State.off; - line_occur["para"] = State.off; - obj_type_status["heading"] = State.off; - obj_type_status["para"] = State.off; - an_object = object_reset(an_object); - } - static auto _check_ocn_status_(L,T)( - L line, - T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if ((!line.empty) && (obj_type_status["ocn_status_off_for_multiple_objects"] == TriState.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_off_block)) { - obj_type_status["ocn_status_off_for_multiple_objects"] = TriState.on; - debug(ocnoff) { - writeln(line); - } - } - if (line.matchFirst(rgx.object_number_off_block_dh)) { - obj_type_status["ocn_status_off_for_multiple_objects"] = TriState.closing; - debug(ocnoff) { - writeln(line); - } - } - } else { - if (obj_type_status["ocn_status_off_for_multiple_objects"] == TriState.off) { - if (line.matchFirst(rgx.object_number_off)) { - obj_type_status["ocn_status"] = OCNstatus.off; - } else if (line.matchFirst(rgx.object_number_off_dh)) { - obj_type_status["ocn_status"] = OCNstatus.closing; - } else { - obj_type_status["ocn_status"] = OCNstatus.on; - } - } else { - obj_type_status["ocn_status"] - = obj_type_status["ocn_status_off_for_multiple_objects"]; - } - } - } else if ((!line.empty) && (obj_type_status["ocn_status_off_for_multiple_objects"] > TriState.off)) { - if (line.matchFirst(rgx.object_number_off_block_close)) { - obj_type_status["ocn_status_off_for_multiple_objects"] = TriState.off; - obj_type_status["ocn_status"] = OCNstatus.on; - debug(ocnoff) { - writeln(line); - } - } - } - return obj_type_status; - } - auto _doc_header_and_make_substitutions_(L,CMM)( - L line, - CMM conf_make_meta, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - } - enum Substitute { match, markup, } - if (conf_make_meta.make.substitute) { - foreach(substitution_pair; conf_make_meta.make.substitute) { - line = line.replaceAll( - regex("\b" ~ substitution_pair[Substitute.match]), - substitution_pair[Substitute.markup] - ); - } - } - return line; - } - auto _doc_header_and_make_substitutions_fontface_(L,CMM)( - L line, - CMM conf_make_meta, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - } - enum Substitute { match, markup, } - if ( conf_make_meta.make.bold) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.bold[Substitute.match]), - conf_make_meta.make.bold[Substitute.markup] - ); - } - if (conf_make_meta.make.emphasis) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.emphasis[Substitute.match]), - conf_make_meta.make.emphasis[Substitute.markup] - ); - } - if (conf_make_meta.make.italics) { - line = line.replaceAll( - regex("\b" ~ conf_make_meta.make.italics[Substitute.match]), - conf_make_meta.make.italics[Substitute.markup] - ); - } - return line; - } - void _start_block_(L,T,N)( - L line, - return ref T obj_type_status, - return ref N object_number_poem - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(obj_type_status) == int[string])); - 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)) { - /+ 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", - line - ); - } - 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)) { - /+ curly poem open +/ - debug(poem) { // poem (curly) open - writefln( - "* [poem curly] %s", - line - ); - } - object_number_poem["start"] = obj_cite_digits.on.to!string; - obj_type_status["blocks"] = TriState.on; - 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)) { - /+ curly group open +/ - debug(group) { // group (curly) open - writefln( - "* [group curly] %s", - line - ); - } - 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)) { - /+ curly block open +/ - debug(block) { // block (curly) open - writefln( - "* [block curly] %s", - line - ); - } - 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)) { - /+ curly quote open +/ - debug(quote) { // quote (curly) open - writefln( - "* [quote curly] %s", - line - ); - } - 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 +/ - debug(table) { // table (curly) open - writefln( - "* [table curly] %s", - line - ); - } - an_object["table_head"] = m.captures[1].to!string; - an_object["block_type"] = "curly"; - 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! +/ - an_object["table_head"] = m.captures[1].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.captures[1]) ? m.captures[1].to!string : ""; - code_block_numbered = (m.captures[2] == "#") ? true : false; - debug(code) { // code (tic) open - writefln( - "* [code tic] %s", - line - ); - } - 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)) { - /+ tic poem open +/ - debug(poem) { // poem (tic) open - writefln( - "* [poem tic] %s", - line - ); - } - object_number_poem["start"] = obj_cite_digits.on.to!string; - obj_type_status["blocks"] = TriState.on; - 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)) { - /+ tic group open +/ - debug(group) { // group (tic) open - writefln( - "* [group tic] %s", - line - ); - } - 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)) { - /+ tic block open +/ - debug(block) { // block (tic) open - writefln( - "* [block tic] %s", - line - ); - } - 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)) { - /+ tic quote open +/ - debug(quote) { // quote (tic) open - writefln( - "* [quote tic] %s", - line - ); - } - 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 +/ - debug(table) { // table (tic) open - writefln( - "* [table tic] %s", - line - ); - } - an_object["table_head"] = m.captures[1].to!string; - an_object["block_type"] = "tic"; - obj_type_status["blocks"] = TriState.on; - obj_type_status["table"] = TriState.on; - obj_type_status["tic_table"] = TriState.on; - } - } - void _quote_block_(L,O,T)( - L line, - return ref O an_object, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_quote"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_quote_close)) { - debug(quote) { // quote (curly) close - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["quote"] = TriState.closing; - obj_type_status["curly_quote"] = TriState.off; - } else { - debug(quote) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) - } - } else if (obj_type_status["tic_quote"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(quote) { // quote (tic) close - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["quote"] = TriState.closing; - obj_type_status["tic_quote"] = TriState.off; - } else { - debug(quote) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) - } - } - } - void _group_block_(L,O,T)( - L line, - return ref O an_object, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_group"] == State.on) { - if (line.matchFirst(rgx.block_curly_group_close)) { - debug(group) { - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["group"] = TriState.closing; - obj_type_status["curly_group"] = TriState.off; - } else { - debug(group) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build group array (or string) - } - } else if (obj_type_status["tic_group"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(group) { - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["group"] = TriState.closing; - obj_type_status["tic_group"] = TriState.off; - } else { - debug(group) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build group array (or string) - } - } - } - void _block_block_(L,O,T)( - L line, - return ref O an_object, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_block"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_block_close)) { - debug(block) { // block (curly) close - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["block"] = TriState.closing; - obj_type_status["curly_block"] = TriState.off; - } else { - debug(block) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build block array (or string) - } - } else if (obj_type_status["tic_block"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(block) { - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key].stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["block"] = TriState.closing; - obj_type_status["tic_block"] = TriState.off; - } else { - debug(block) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build block array (or string) - } - } - } - void _poem_block_(L,O,T,C,N,CMM)( - L line, - return ref O an_object, - return ref T obj_type_status, - return ref C cntr, - N object_number_poem, - CMM conf_make_meta, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - static assert(is(typeof(cntr) == int)); - static assert(is(typeof(object_number_poem) == string[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_poem"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_poem_close)) { - if (an_object_key in an_object - || processing.length > 0) { - an_object[an_object_key] = ""; - debug(poem) { - writefln( - "* [poem curly] %s", - line - ); - } - if (processing.length > 0) { - an_object[an_object_key] = processing["verse"]; - } - debug(poem) { - writeln(__LINE__); - writefln( - "* %s %s", - obj_cite_digits.on, - line - ); - } - if (an_object.length > 0) { - debug(poem) { // poem (curly) close - writeln( - obj_cite_digits.on, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - } - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - object_number_poem["end"] = obj_cite_digits.on.to!string; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["poem"] = TriState.closing; - obj_type_status["curly_poem"] = TriState.off; - } else { - processing["verse"] ~= line ~= "\n"; - if (obj_type_status["verse_new"] == State.on) { - obj_cite_digits = ocn_emit(OCNstatus.on); - obj_type_status["verse_new"] = State.off; - } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { - processing["verse"] = processing["verse"].stripRight; - verse_line = TriState.off; - obj_type_status["verse_new"] = State.on; - } - if (obj_type_status["verse_new"] == State.on) { - verse_line=1; - an_object[an_object_key] = processing["verse"]; - debug(poem) { // poem verse - writefln( - "* %s curly\n%s", - obj_cite_digits.on, - an_object[an_object_key] - ); - } - processing.remove("verse"); - an_object["is"] = "verse"; - auto comp_obj_location = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - } - } else if (obj_type_status["tic_poem"] == TriState.on) { - if (auto m = line.matchFirst(rgx.block_tic_close)) { // tic_poem_close - an_object[an_object_key]="verse"; - debug(poem) { - writefln( - "* [poem tic] %s", - line - ); - } - if (processing.length > 0) { - an_object[an_object_key] = processing["verse"]; - } - if (an_object.length > 0) { - debug(poem) { // poem (tic) close - writeln(__LINE__); - writeln(obj_cite_digits.on, line); - } - processing.remove("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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - object_number_poem["end"] = obj_cite_digits.on.to!string; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - obj_type_status["blocks"] = TriState.closing; - obj_type_status["poem"] = TriState.closing; - obj_type_status["tic_poem"] = TriState.off; - } else { - processing["verse"] ~= line ~= "\n"; - if (obj_type_status["verse_new"] == State.on) { - obj_cite_digits = ocn_emit(OCNstatus.on); - obj_type_status["verse_new"] = State.off; - } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { - processing["verse"] = processing["verse"].stripRight; - obj_type_status["verse_new"] = State.on; - verse_line = TriState.off; - } - if (obj_type_status["verse_new"] == State.on) { - verse_line=1; - an_object[an_object_key] = processing["verse"]; - debug(poem) { // poem (tic) close - writefln( - "* %s tic\n%s", - obj_cite_digits.on, - an_object[an_object_key] - ); - } - processing.remove("verse"); - an_object["is"] = "verse"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - } - } - } - void _code_block_(L,O,T)( - L line, - return ref O an_object, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_code"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_code_close)) { - debug(code) { // code (curly) close - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key] - .replaceFirst(rgx.newline_eol_delimiter_only, "") - .stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["code"] = TriState.closing; - obj_type_status["curly_code"] = TriState.off; - } else { - debug(code) { // code (curly) line - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // code (curly) line - } - } else if (obj_type_status["tic_code"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(code) { // code (tic) close - writeln(line); - } - an_object[an_object_key] = an_object[an_object_key] - .replaceFirst(rgx.newline_eol_delimiter_only, "") - .stripRight; - obj_type_status["blocks"] = TriState.closing; - obj_type_status["code"] = TriState.closing; - obj_type_status["tic_code"] = TriState.off; - } else { - debug(code) { // code (tic) line - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // code (tic) line - } - } - } - void _table_block_(L,O,T,CMM)( - L line, - return ref O an_object, - return ref T obj_type_status, - return ref CMM conf_make_meta, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (obj_type_status["curly_table"] == TriState.on) { - if (line.matchFirst(rgx.block_curly_table_close)) { - debug(table) { // table (curly) close - writeln(line); - } - obj_type_status["blocks"] = TriState.closing; - obj_type_status["table"] = TriState.closing; - obj_type_status["curly_table"] = TriState.off; - } else { - debug(table) { // table - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) - } - } else if (obj_type_status["curly_table_special_markup"] == TriState.on) { - if (line.empty) { - obj_type_status["blocks"] = TriState.off; - obj_type_status["table"] = TriState.off; - obj_type_status["curly_table_special_markup"] = TriState.off; - _table_closed_make_special_notation_table_( - line, - an_object, - the_document_body_section, - obj_cite_digits, - comp_obj_heading, - cntr, - obj_type_status, - conf_make_meta, - ); - } else { - debug(table) { - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; - } - } else if (obj_type_status["tic_table"] == TriState.on) { - if (line.matchFirst(rgx.block_tic_close)) { - debug(table) { // table (tic) close - writeln(line); - } - obj_type_status["blocks"] = TriState.closing; - obj_type_status["table"] = TriState.closing; - obj_type_status["tic_table"] = TriState.off; - } else { - debug(table) { // table - writeln(line); - } - an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) - } - } - } - final string biblio_tag_map(A)(A abr) { - debug(asserts) { - static assert(is(typeof(abr) == string)); - } - auto btm = [ - "au" : "author_raw", - "ed" : "editor_raw", - "ti" : "fulltitle", - "lng" : "language", - "jo" : "journal", - "vol" : "volume", - "edn" : "edition", - "yr" : "year", - "pl" : "place", - "pb" : "publisher", - "pub" : "publisher", - "pg" : "pages", - "pgs" : "pages", - "sn" : "short_name" - ]; - return btm[abr]; - } - void _biblio_block_( - char[] line, - return ref int[string] obj_type_status, - return ref int bib_entry, - return ref string biblio_entry_str_json, - return ref string[] biblio_arr_json - ) { - mixin SiSUbiblio; - auto jsn = BibJsnStr(); - static auto rgx = Rgx(); - if (line.matchFirst(rgx.heading_biblio)) { - 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 { - debug(biblioblock) { - writeln("---"); - } - debug(biblioblockinclude) { - writeln(biblio_entry_str_json.length); - } - } - if ((bib_entry == State.off) - && (biblio_entry_str_json.empty)) { - bib_entry = State.on; - biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; - } else if (!(biblio_entry_str_json.empty)) { - bib_entry = State.off; - if (!(biblio_entry_str_json == jsn.biblio_entry_tags_jsonstr)) { - auto biblio_entry = parseJSON(biblio_entry_str_json); - if (biblio_entry["fulltitle"].str.empty) { - writeln("check problem entry (Title missing): ", biblio_entry_str_json); - } else if ((biblio_entry["author_raw"].str.empty) && (biblio_entry["editor_raw"].str.empty)) { - writeln("check problem entry (No author and no editor): ", biblio_entry_str_json); - } else { - biblio_arr_json ~= biblio_entry_str_json; - } - biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; - } - } else { // CHECK ERROR - writeln("?? 2. ERROR ", biblio_entry_str_json, "??"); - biblio_entry_str_json = ""; - } - } else if (line.matchFirst(rgx.biblio_tags)) { - debug(biblioblock) { - writeln(line); - } - auto bt = line.match(rgx.biblio_tags); - bib_entry = State.off; - st = bt.captures[1].to!string; - auto header_tag_value=(bt.captures[2]).to!string; - JSONValue j = parseJSON(biblio_entry_str_json); - biblio_tag_name = (st.match(rgx.biblio_abbreviations)) - ? (biblio_tag_map(st)) - : st; - j.object[biblio_tag_name] = header_tag_value; - debug(bibliounsortedcheckduplicates) { - writeln(biblio_tag_name, ": ", header_tag_value); - writeln("--"); - } - switch (biblio_tag_name) { - case "author_raw": // author_arr author (fn sn) - j["author_arr"] - = header_tag_value.split(rgx.arr_delimiter); - string tmp; - biblioAuthorLoop: - foreach (au; j["author_arr"].array) { - if (auto x = au.str.match(rgx.name_delimiter)) { - tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; - } else { - tmp ~= au.str; - } - } - tmp = (tmp).replace(rgx.trailing_comma, ""); - j["author"].str = tmp; - goto default; - case "editor_raw": // editor_arr editor (fn sn) - j["editor_arr"] - = header_tag_value.split(rgx.arr_delimiter); - string tmp; - biblioEditorLoop: - foreach (ed; j["editor_arr"].array) { - if (auto x = ed.str.match(rgx.name_delimiter)) { - tmp ~= x.captures[2] ~ " " ~ x.captures[1] ~ ", "; - } else { - tmp ~= ed.str; - } - } - tmp = (tmp).replace(rgx.trailing_comma, ""); - j["editor"].str = tmp; - goto default; - case "fulltitle": // title & subtitle - goto default; - default: - break; - } - auto s = j.toString(); - debug(biblio1) { - writefln( - "* %s: %s\n%s", - biblio_tag_name, - biblio_tag_entry, - j[biblio_tag_name] - ); - } - if (line.match(rgx.comment)) { - writeln("ERROR", line, "COMMENT"); - writeln("ERROR", s, "%%"); - } - if (!(match(line, rgx.comment))) { - debug(biblioblockinclude) { - writeln(line); - } - biblio_entry_str_json = s; - } else { - biblio_entry_str_json = ""; - } - header_tag_value=""; - } - } - void _table_closed_make_special_notation_table_(N,CMM)( - char[] line, - return ref string[string] an_object, - return ref ObjGenericComposite[] the_document_body_section, - return ref N obj_cite_digits, - return ref ObjGenericComposite _comp_obj_heading, - return ref int cntr, - return ref int[string] obj_type_status, - CMM conf_make_meta - ) { - comp_obj_block = comp_obj_block.init; - obj_cite_digits = ocn_emit(OCNstatus.on); - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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", conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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 = 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; - } - void _block_flag_line_empty_(B,N,CMM)( - B bookindex_extract_hash, - char[] line, - return ref string[string] an_object, - return ref ObjGenericComposite[] the_document_body_section, - return ref string[][string][string] bookindex_unordered_hashes, - return ref N obj_cite_digits, - return ref ObjGenericComposite _comp_obj_heading, - return ref int cntr, - return ref int[string] obj_type_status, - string[string] object_number_poem, - CMM conf_make_meta, - ) { - assert( - line.empty, - "\nline should be empty:\n \"" - ~ line ~ "\"" - ); - assert( - (obj_type_status["blocks"] == TriState.closing), - "code block status: closed" - ); - assertions_flag_types_block_status_none_or_closed(obj_type_status); - if (obj_type_status["quote"] == TriState.closing) { - obj_cite_digits = ocn_emit(OCNstatus.on); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "quote"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "quote"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - obj_type_status["blocks"] = TriState.off; - obj_type_status["quote"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (obj_type_status["group"] == TriState.closing) { - obj_cite_digits = ocn_emit(OCNstatus.on); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "group"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "group"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - obj_type_status["blocks"] = TriState.off; - obj_type_status["group"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (obj_type_status["block"] == TriState.closing) { - obj_cite_digits = ocn_emit(OCNstatus.on); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "block"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "block"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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.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; - obj_type_status["blocks"] = TriState.off; - obj_type_status["block"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (obj_type_status["poem"] == TriState.closing) { - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "verse"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - cntr, - heading_ptr-1, - an_object["is"] - ); - comp_obj_poem_ocn = comp_obj_poem_ocn.init; - comp_obj_poem_ocn.metainfo.is_of_part = "body"; - comp_obj_poem_ocn.metainfo.is_of_section = "body"; - comp_obj_poem_ocn.metainfo.is_of_type = "block"; - comp_obj_poem_ocn.metainfo.is_a = "poem"; - comp_obj_poem_ocn.metainfo.ocn = obj_cite_digits.on; - comp_obj_poem_ocn.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; // - comp_obj_poem_ocn.metainfo.o_n_book_index = obj_cite_digits.bkidx; // - comp_obj_poem_ocn.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_poem_ocn.text = ""; - the_document_body_section ~= comp_obj_poem_ocn; - obj_type_status["blocks"] = TriState.off; - obj_type_status["poem"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - } else if (obj_type_status["code"] == TriState.closing) { - obj_cite_digits = ocn_emit(OCNstatus.on); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "code"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - 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.metainfo.is_of_part = "body"; - comp_obj_code.metainfo.is_of_section = "body"; - comp_obj_code.metainfo.is_of_type = "block"; - comp_obj_code.metainfo.is_a = "code"; - comp_obj_code.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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_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]; - comp_obj_code.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_code; - obj_type_status["blocks"] = TriState.off; - obj_type_status["code"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } else if (obj_type_status["table"] == TriState.closing) { - comp_obj_block = comp_obj_block.init; - obj_cite_digits = ocn_emit(OCNstatus.on); - an_object["bookindex_nugget"] - = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; - bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash( - an_object["bookindex_nugget"], - obj_cite_digits, - segment_anchor_tag_that_object_belongs_to - ); - an_object["is"] = "table"; - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - segment_anchor_tag_that_object_belongs_to, - obj_cite_digits, - 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, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - 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 = 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; - obj_type_status["blocks"] = TriState.off; - obj_type_status["table"] = TriState.off; - object_reset(an_object); - processing.remove("verse"); - ++cntr; - } - } - auto _book_index_(L,I,O,T,B)( - L line, - return ref I book_idx_tmp, - return ref O an_object, - return ref T obj_type_status, - B opt_action, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(book_idx_tmp) == string)); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if (auto m = line.match(rgx.book_index)) { - /+ match book_index +/ - debug(bookindexmatch) { - writefln( - "* [bookindex] %s\n", - m.captures[1].to!string, - ); - } - an_object["bookindex_nugget"] = m.captures[1].to!string; - } 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; - debug(bookindexmatch) { - writefln( - "* [bookindex] %s\n", - book_idx_tmp, - ); - } - } - } 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 - && opt_action.section_bookindex) { - an_object["bookindex_nugget"] = book_idx_tmp ~ m.captures[1].to!string; - debug(bookindexmatch) { - writefln( - "* [bookindex] %s\n", - book_idx_tmp, - ); - } - } - book_idx_tmp = ""; - } else { - if (opt_action.backmatter - && opt_action.section_bookindex) { - book_idx_tmp ~= line; - } - } - } - } - auto _heading_found_(L,X,H,R,T)( - L line, - X _make_unmarked_headings, - return ref H heading_match_str, - return ref R heading_match_rgx, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(_make_unmarked_headings) == string[])); - static assert(is(typeof(heading_match_str) == string[string])); - static assert(is(typeof(heading_match_rgx) == Regex!(char)[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - if ((_make_unmarked_headings.length > 2) - && (obj_type_status["make_headings"] == State.off)) { - /+ headings found +/ - debug(headingsfound) { - writeln(_make_unmarked_headings); - } - debug(headingsfound) { - writeln(_make_unmarked_headings.length); - writeln(_make_unmarked_headings); - } - switch (_make_unmarked_headings.length) { - case 7 : - if (!empty(_make_unmarked_headings[6])) { - heading_match_str["h_4"] - = "^(" ~ _make_unmarked_headings[6].to!string ~ ")"; - heading_match_rgx["h_4"] - = regex(heading_match_str["h_4"]); - } - goto case; - case 6 : - if (!empty(_make_unmarked_headings[5])) { - heading_match_str["h_3"] - = "^(" ~ _make_unmarked_headings[5].to!string ~ ")"; - heading_match_rgx["h_3"] - = regex(heading_match_str["h_3"]); - } - goto case; - case 5 : - if (!empty(_make_unmarked_headings[4])) { - heading_match_str["h_2"] - = "^(" ~ _make_unmarked_headings[4].to!string ~ ")"; - heading_match_rgx["h_2"] - = regex(heading_match_str["h_2"]); - } - goto case; - case 4 : - if (!empty(_make_unmarked_headings[3])) { - heading_match_str["h_1"] - = "^(" ~ _make_unmarked_headings[3].to!string ~ ")"; - heading_match_rgx["h_1"] - = regex(heading_match_str["h_1"]); - } - goto case; - case 3 : - if (!empty(_make_unmarked_headings[2])) { - heading_match_str["h_D"] - = "^(" ~ _make_unmarked_headings[2].to!string ~ ")"; - heading_match_rgx["h_D"] - = regex(heading_match_str["h_D"]); - } - goto case; - case 2 : - if (!empty(_make_unmarked_headings[1])) { - heading_match_str["h_C"] - = "^(" ~ _make_unmarked_headings[1].to!string ~ ")"; - heading_match_rgx["h_C"] - = regex(heading_match_str["h_C"]); - } - goto case; - case 1 : - if (!empty(_make_unmarked_headings[0])) { - heading_match_str["h_B"] - = "^(" ~ _make_unmarked_headings[0].to!string ~ ")"; - heading_match_rgx["h_B"] - = regex(heading_match_str["h_B"]); - } - break; - default: - break; - } - obj_type_status["make_headings"] = State.on; - } - } - auto _heading_make_set_(L,C,R,T)( - L line, - C line_occur, - return ref R heading_match_rgx, - return ref T obj_type_status - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(line_occur) == int[string])); - static assert(is(typeof(heading_match_rgx) == Regex!(char)[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - 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 +/ - if (line.matchFirst(heading_match_rgx["h_B"])) { - line = "B~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_C"])) { - line = "C~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_D"])) { - line = "D~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_1"])) { - line = "1~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_2"])) { - line = "2~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_3"])) { - line = "3~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - if (line.matchFirst(heading_match_rgx["h_4"])) { - line = "4~ " ~ line; - debug(headingsfound) { - writeln(line); - } - } - } - return line; - } - auto _heading_matched_(L,C,O,K,Lv,Lc,T,CMM)( - L line, - return ref C line_occur, - return ref O an_object, - return ref K an_object_key, - return ref Lv lv, - return ref Lc collapsed_lev, - return ref T obj_type_status, - return ref CMM conf_make_meta, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(line_occur) == int[string])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(an_object_key) == string)); - static assert(is(typeof(lv) == int[string])); - static assert(is(typeof(collapsed_lev) == int[string])); - static assert(is(typeof(obj_type_status) == int[string])); - } - static auto rgx = Rgx(); - 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["blurb_section"] = State.off; - } - an_object[an_object_key] ~= line ~= "\n"; - an_object["lev"] ~= m.captures[1]; - assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels - switch (an_object["lev"]) { - case "A": // Title set - an_object[an_object_key]=(an_object[an_object_key]) - .replaceFirst(rgx.variable_doc_title, - (conf_make_meta.meta.title_full ~ ",")) - .replaceFirst(rgx.variable_doc_author, - conf_make_meta.meta.creator_author); - collapsed_lev["h0"] = 0; - an_object["lev_collapsed_number"] - = collapsed_lev["h0"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_A; - ++lv["h0"]; - lv["h1"] = State.off; - lv["h2"] = State.off; - lv["h3"] = State.off; - lv["h4"] = State.off; - lv["h5"] = State.off; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "B": - collapsed_lev["h1"] = collapsed_lev["h0"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h1"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_B; - ++lv["h1"]; - lv["h2"] = State.off; - lv["h3"] = State.off; - lv["h4"] = State.off; - lv["h5"] = State.off; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "C": - collapsed_lev["h2"] = collapsed_lev["h1"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h2"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_C; - ++lv["h2"]; - lv["h3"] = State.off; - lv["h4"] = State.off; - lv["h5"] = State.off; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "D": - collapsed_lev["h3"] = collapsed_lev["h2"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h3"].to!string; - lv["lv"] = DocStructMarkupHeading.h_sect_D; - ++lv["h3"]; - lv["h4"] = State.off; - lv["h5"] = State.off; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "1": - if (lv["h3"] > State.off) { - collapsed_lev["h4"] = collapsed_lev["h3"] + 1; - } else if (lv["h2"] > State.off) { - collapsed_lev["h4"] = collapsed_lev["h2"] + 1; - } else if (lv["h1"] > State.off) { - collapsed_lev["h4"] = collapsed_lev["h1"] + 1; - } else if (lv["h0"] > State.off) { - collapsed_lev["h4"] = collapsed_lev["h0"] + 1; - } - an_object["lev_collapsed_number"] - = collapsed_lev["h4"].to!string; - lv["lv"] = DocStructMarkupHeading.h_text_1; - ++lv["h4"]; - lv["h5"] = State.off; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "2": - if (lv["h5"] > State.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h5"].to!string; - } else if (lv["h4"] > State.off) { - collapsed_lev["h5"] = collapsed_lev["h4"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h5"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_2; - ++lv["h5"]; - lv["h6"] = State.off; - lv["h7"] = State.off; - goto default; - case "3": - if (lv["h6"] > State.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h6"].to!string; - } else if (lv["h5"] > State.off) { - collapsed_lev["h6"] = collapsed_lev["h5"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h6"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_3; - ++lv["h6"]; - lv["h7"] = State.off; - goto default; - case "4": - if (lv["h7"] > State.off) { - an_object["lev_collapsed_number"] - = collapsed_lev["h7"].to!string; - } else if (lv["h6"] > State.off) { - collapsed_lev["h7"] = collapsed_lev["h6"] + 1; - an_object["lev_collapsed_number"] - = collapsed_lev["h7"].to!string; - } - lv["lv"] = DocStructMarkupHeading.h_text_4; - ++lv["h7"]; - goto default; - default: - an_object["lev_markup_number"] = lv["lv"].to!string; - } - debug(heading) { - writeln(line.strip); - } - } - } - void _para_match_(L,O,K,I,B,T,C)( - L line, - return ref O an_object, - return ref K an_object_key, - return ref I indent, - return ref B bullet, - return ref T obj_type_status, - return ref C line_occur, - ) { - debug(asserts) { - static assert(is(typeof(line) == char[])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(an_object_key) == string)); - static assert(is(typeof(indent) == int[string])); - static assert(is(typeof(bullet) == bool)); - static assert(is(typeof(obj_type_status) == int[string])); - static assert(is(typeof(line_occur) == int[string])); - } - static auto rgx = Rgx(); - if (line_occur["para"] == State.off) { - line = font_faces_line(line); - /+ para matches +/ - obj_type_status["para"] = State.on; - an_object[an_object_key] ~= line; - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - bullet = false; - if (auto m = line.matchFirst(rgx.para_indent)) { - debug(paraindent) { - writeln(line); - } - indent["hang_position"] = (m.captures[1]).to!int; - indent["base_position"] = 0; - } else if (line.matchFirst(rgx.para_bullet)) { - debug(parabullet) { - writeln(line); - } - bullet = true; - } else if (auto m = line.matchFirst(rgx.para_indent_hang)) { - debug(paraindenthang) { - writeln(line); - } - indent=[ - "hang_position" : (m.captures[1]).to!int, - "base_position" : (m.captures[2]).to!int, - ]; - } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) { - debug(parabulletindent) { - writeln(line); - } - indent=[ - "hang_position" : (m.captures[1]).to!int, - "base_position" : 0, - ]; - bullet = true; - } - ++line_occur["para"]; - } - } - auto font_faces_line(T)( - T textline, - ) { - static auto rgx = Rgx(); - if (textline.match(rgx.inline_faces_line)) { - textline = (textline) - .replaceFirst(rgx.inline_emphasis_line, ("*{$1}*$2")) - .replaceFirst(rgx.inline_bold_line, ("!{$1}!$2")) - .replaceFirst(rgx.inline_underscore_line, ("_{$1}_$2")) - .replaceFirst(rgx.inline_italics_line, ("/{$1}/$2")); - } - return textline; - } - auto table_instructions(O,H)( - return ref O table_object, - return ref H table_head, - ) { - static auto rgx = Rgx(); - table_object.metainfo.is_of_part = "body"; - table_object.metainfo.is_of_section = "body"; - table_object.metainfo.is_of_type = "block"; - table_object.metainfo.is_a = "table"; - table_object.has.inline_notes_reg = false; - table_object.has.inline_notes_star = false; - table_object.has.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; - } - auto table_array_munge(O,T)( - return ref O table_object, - return ref T table_array, - ) { - static auto rgx = Rgx(); - static 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 (col.match(rgx.numeric_col) && idx_r == 1) { // conditions reversed to avoid: gdc compiled program run segfault - 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; - } - 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, - ) { - static auto rgx = Rgx(); - static 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; - } - auto table_substantive_munge_special(O,T)( - return ref O table_object, - return ref T table_substantive, - ) { - static auto rgx = Rgx(); - static 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; - } - /+ abstraction functions ↑ +/ - /+ ↓ abstraction function emitters +/ - pure struct OCNemitter { - int ocn_, ocn_on, ocn_on_, ocn_off, ocn_off_, ocn_bkidx, ocn_bkidx_; - auto ocn_emitter(int ocn_status_flag) { - OCNset ocn; - assert(ocn_status_flag <= OCNstatus.reset); - ocn_on = ocn_off = ocn_bkidx = 0; - switch(ocn_status_flag) { - case OCNstatus.reset: - ocn_ = ocn_on_ = ocn_off_ = 1; - ocn_bkidx_ = 0; - break; - case OCNstatus.on: - ocn_ = ocn_on = ++ocn_on_; - break; - case OCNstatus.off: - ocn_ = ocn_off = ++ocn_off_; - break; - case OCNstatus.bkidx: - ocn_ = ocn_bkidx = ++ocn_bkidx_; - break; - case OCNstatus.closing: - break; - default: - ocn_ = 0; - } - assert(ocn_ >= 0); - ocn.digit = ocn_; - ocn.on = ocn_on; - ocn.off = ocn_off; - ocn.bkidx = ocn_bkidx; - ocn.type = ocn_status_flag; - return ocn; - } - invariant() { - } - } - /+ +/ - static struct ObjInlineMarkupMunge { - string[string] obj_txt; - int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; - string asterisks_, plus_; - string obj_txt_out, tail, note; - static auto rgx = Rgx(); - static auto mkup = InlineMarkup(); - int stage_reset_note_numbers = true; - private auto initialize_note_numbers() { - n_foot = 0; - n_foot_reg = 0; - n_foot_sp_asterisk = 0; - n_foot_sp_plus = 0; - } - static auto url_links(Ot)(Ot obj_txt_in) { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - static auto mng = InlineMarkup(); - obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono, (mng.mono ~ "{$1}" ~ mng.mono)); - /+ 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_inline_url_generic)) { - /+ link: naked url: http://url +/ - if (obj_txt_in.match(rgx.smid_inline_link_naked_url)) { - obj_txt_in = (obj_txt_in).replaceAll( - rgx.smid_inline_link_naked_url, - ("$1" - ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ "$3") // ("$1{ $2 }$2$3") - ); - } - /+ link with helper for endnote including the url: - {~^ link which includes url as footnote }http://url - maps to: - { link which includes url as footnote }http://url~{ { http://url }http://url }~ - +/ - if (obj_txt_in.match(rgx.smid_inline_link_endnote_url_helper)) { - obj_txt_in = (obj_txt_in) - .replaceAll( - rgx.smid_inline_link_endnote_url_helper_punctuated, - (mkup.lnk_o ~ "$1" ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") - ) - .replaceAll( - rgx.smid_inline_link_endnote_url_helper, - (mkup.lnk_o ~ "$1" ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ " }~") // ("{ $1 }$2~{ { $2 }$2 }~") - ); - } - /+ link with regular markup: - { linked text or image }http://url - +/ - if (obj_txt_in.match(rgx.smid_inline_link_markup_regular)) { - obj_txt_in = (obj_txt_in).replaceAll( - rgx.smid_inline_link_markup_regular, - ("$1" - ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c - ~ mkup.url_o ~ "$3" ~ mkup.url_c - ~ "$4") // ("$1{ $2 }$3$4") - ); - } - } - obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono_box, ("#{$1}#")); - return obj_txt_in; - } - static auto images(Ot)(Ot obj_txt_in) { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - static auto mng = InlineMarkup(); - obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono, (mng.mono ~ "{$1}" ~ mng.mono)); // figure - /+ 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 +/ - debug(images) { - writeln("Image: ", obj_txt_in); - } - if (obj_txt_in.match(rgx.smid_image_with_dimensions)) { - obj_txt_in = (obj_txt_in).replaceAll( - rgx.smid_image_with_dimensions, - ("$1" - ~ mkup.img ~ "$2,w$3h$4 " - ~ "$5") // ("$1{ $2 }$2$3") - ); - debug(images) { - writeln("IMAGE with size: ", obj_txt_in); // decide on representation - } - } else if (obj_txt_in.match(rgx.smid_image)) { - obj_txt_in = (obj_txt_in).replaceAll( - rgx.smid_image, - ("$1" - ~ mkup.img ~ "$2,w0h0 " - ~ "$3") // ("$1{ $2 }$2$3") - ); - debug(images) { - writeln("IMAGE: ", obj_txt_in); // decide on representation - } - } - } - obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono_box, ("#{$1}#")); // figure - return obj_txt_in; - } - auto footnotes_endnotes_markup_and_number_or_stars(Ot)(Ot obj_txt_in, bool reset_note_numbers) { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - /+ endnotes (regular) +/ - bool flg_notes_reg = false; - bool flg_notes_star = false; - bool flg_notes_plus = false; - obj_txt_in = (obj_txt_in).replaceAll( - rgx.inline_notes_curly, - (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) - ); - if (!(stage_reset_note_numbers) && reset_note_numbers) { - stage_reset_note_numbers = true; - } - if (obj_txt_in.match(rgx.inline_notes_al_gen)) { - if (auto m = obj_txt_in.matchAll(rgx.inline_text_and_note_al_)) { - if (stage_reset_note_numbers) { - n_foot = 0; - n_foot_reg = 0; - n_foot_sp_asterisk = 0; - n_foot_sp_plus = 0; - } - stage_reset_note_numbers = false; - foreach(n; m) { - if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_star)) { - flg_notes_star = true; - ++n_foot_sp_asterisk; - asterisks_ = "*"; - n_foot=n_foot_sp_asterisk; - obj_txt_out ~= n.hit.to!string.replaceFirst( - rgx.inline_al_delimiter_open_symbol_star, - (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ") - ) ~ "\n"; - } else if (n.hit.to!string.match(rgx.inline_al_delimiter_open_symbol_plus)) { - flg_notes_plus = true; - ++n_foot_sp_plus; - plus_ = "*"; - n_foot=n_foot_sp_plus; - obj_txt_out ~= n.hit.to!string.replaceFirst( - rgx.inline_al_delimiter_open_symbol_plus, - (mkup.en_a_o ~ replicate(plus_, n_foot_sp_plus) ~ " ") - ) ~ "\n"; - } else if (n.hit.to!string.match(rgx.inline_al_delimiter_open_regular)) { - flg_notes_reg = true; - ++n_foot_reg; - n_foot=n_foot_reg; - obj_txt_out ~= n.hit.to!string.replaceFirst( - rgx.inline_al_delimiter_open_regular, - (mkup.en_a_o ~ to!string(n_foot) ~ " ") - ) ~ "\n"; - } else { - obj_txt_out ~= n.hit.to!string ~ "\n"; - } - } - } - } else { - obj_txt_out = obj_txt_in; - } - auto t = tuple( - obj_txt_out, - flg_notes_reg, - flg_notes_star, - flg_notes_plus, - ); - return t; - } - private auto object_notes_and_links_(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) - in { - debug(asserts) { - assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt_out = ""; - bool urls = false; - bool images_without_dimensions = false; - tail = ""; - /+ special endnotes +/ - obj_txt_in = obj_txt_in.replaceAll( - 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) - ); - /+ image matched +/ - if (obj_txt_in.match(rgx.smid_image_generic)) { - obj_txt_in = images(obj_txt_in); - if (obj_txt_in.match(rgx.smid_mod_image_without_dimensions)) { - images_without_dimensions = true; - } - } - /+ url matched +/ - if (obj_txt_in.match(rgx.smid_inline_url)) { - urls = true; - obj_txt_in = url_links(obj_txt_in); - } - auto ftn = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); - obj_txt_out = ftn[0]; - debug(footnotes) { - writeln(obj_txt_out, tail); - } - obj_txt_out = obj_txt_out ~ tail; - debug(footnotesdone) { - foreach(m; matchAll(obj_txt_out, - (mkup.en_a_o ~ `\s*(.+?)` ~ mkup.en_a_c))) { - writeln(m.captures[1]); - writeln(m.hit); - } - } - auto t = tuple( - obj_txt_out, - ftn[1], - ftn[2], - ftn[3], - urls, - images_without_dimensions, - ); - return t; - } - auto init() - in { } - body { - auto t = object_notes_and_links_(""); - return t; - } - invariant() { - } - auto munge_heading(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt["munge"]=(obj_txt_in) - .replaceFirst(rgx.heading, "") - .replaceFirst(rgx.object_number_off_all, "") - .strip; - auto t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); - debug(munge) { - writeln(__LINE__); - writeln(obj_txt_in); - writeln(__LINE__); - writeln(obj_txt["munge"].to!string); - } - return t; - } - invariant() { - } - auto munge_para(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt["munge"]=(obj_txt_in) - .replaceFirst(rgx.para_attribs, "") - .replaceFirst(rgx.object_number_off_all, ""); - auto t = object_notes_and_links_(obj_txt["munge"]); - debug(munge) { - writeln(__LINE__); - writeln(obj_txt_in); - writeln(__LINE__); - writeln(obj_txt["munge"].to!string); - } - return t; - } - 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() { - } - auto munge_group(string obj_txt_in) - in { } - body { - obj_txt["munge"]=obj_txt_in; - auto t = object_notes_and_links_(obj_txt["munge"]); - return t; - } - invariant() { - } - auto munge_block(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt["munge"]=obj_txt_in; - auto t = object_notes_and_links_(obj_txt["munge"]); - return t; - } - invariant() { - } - auto munge_verse(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt["munge"]=obj_txt_in; - auto t = object_notes_and_links_(obj_txt["munge"]); - return t; - } - invariant() { - } - string munge_code(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - assert(is(typeof(obj_txt_in) == string)); - } - } - body { - obj_txt_in = (obj_txt_in).replaceAll(rgx.space, mkup.nbsp); - obj_txt["munge"] = obj_txt_in; - return obj_txt["munge"]; - } - invariant() { - } - string munge_table(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() { - } - string munge_comment(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() { - } - } - static struct ObjInlineMarkup { - static auto rgx = Rgx(); - static auto munge = ObjInlineMarkupMunge(); - string[string] obj_txt; - static string[] anchor_tags_ = []; - static string anchor_tag = ""; - auto obj_inline_markup_and_anchor_tags_and_misc(O,K,CMM)( - O obj_, - K obj_key_, - CMM conf_make_meta, - bool _new_doc - ) - in { - debug(asserts) { - static assert(is(typeof(obj_) == string[string])); - static assert(is(typeof(obj_key_) == string)); - } - } - body { - obj_txt["munge"] = obj_[obj_key_].dup; - obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) - ? obj_txt["munge"] - : obj_txt["munge"].strip; - if (_new_doc) { - anchor_tags_ = []; - } - auto x = munge.init; - bool[string] obj_notes_and_links; - obj_notes_and_links["notes_reg"] = false; - obj_notes_and_links["notes_star"] = false; - obj_notes_and_links["links"] = false; - obj_notes_and_links["image_no_dimensions"] = false; - switch (obj_["is"]) { - case "heading": - if (_new_doc) { - anchor_tag = ""; - } - obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc); - obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); - if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { - anchor_tag = m.captures[1]; - anchor_tags_ ~= anchor_tag; - } else if (obj_["lev"] == "1") { - writeln("heading anchor tag missing: ", obj_txt["munge"]); - } - x = munge.munge_heading(obj_txt["munge"], reset_note_numbers); - reset_note_numbers=false; - goto default; - case "para": - x = munge.munge_para(obj_txt["munge"]); - goto default; - case "group": - x = munge.munge_group(obj_txt["munge"]); - goto default; - case "block": - x = munge.munge_block(obj_txt["munge"]); - goto default; - case "verse": - x = munge.munge_verse(obj_txt["munge"]); - goto default; - case "code": - obj_txt["munge"] = munge.munge_code(obj_txt["munge"]); - break; - case "table": - obj_txt["munge"] = munge.munge_table(obj_txt["munge"]); - break; - case "quote": - obj_txt["munge"] = munge.munge_quote(obj_txt["munge"]); - break; - case "comment": - obj_txt["munge"] = munge.munge_comment(obj_txt["munge"]); - break; - case "doc_end_reset": - munge.initialize_note_numbers(); - break; - default: - /+ para, heading, group, block, verse +/ - obj_txt["munge"] = x[0]; - obj_notes_and_links["notes_reg"] = x[1]; - obj_notes_and_links["notes_star"] = x[2]; - obj_notes_and_links["notes_plus"] = x[3]; - obj_notes_and_links["links"] = x[4]; - obj_notes_and_links["image_no_dimensions"] = x[5]; - break; - } - auto t = tuple( - obj_txt["munge"], - anchor_tags_, - obj_notes_and_links["notes_reg"], - obj_notes_and_links["notes_star"], - obj_notes_and_links["links"], - obj_notes_and_links["image_no_dimensions"], - ); - anchor_tags_=[]; - return t; - } - invariant() { - } - auto _clean_heading_toc_(Toc)( - Toc heading_toc_, - ) { - debug(asserts) { - static assert(is(typeof(heading_toc_) == char[])); - } - auto m = (cast(char[]) heading_toc_).matchFirst(rgx.heading); - heading_toc_ = (m.post).replaceAll( - rgx.inline_notes_curly_gen, - ""); - return heading_toc_; - }; - auto table_of_contents_gather_headings(O,CMM,Ts,Ta,X,Toc)( - O obj_, - CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, - Ta _anchor_tag, - return ref X lev4_subtoc, - Toc the_table_of_contents_section, - ) - in { - debug(asserts) { - static assert(is(typeof(obj_) == string[string])); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string)); - static assert(is(typeof(_anchor_tag) == string)); - static assert(is(typeof(lev4_subtoc) == string[][string])); - static assert(is(typeof(the_table_of_contents_section) == ObjGenericComposite[][string])); - } - } - body { - ObjGenericComposite comp_obj_toc; - mixin InternalMarkup; - static auto mkup = InlineMarkup(); - char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])).replaceAll(rgx.inline_notes_al, ""); - heading_toc_ = _clean_heading_toc_(heading_toc_); - auto attrib=""; - string toc_txt_, subtoc_txt_; - int[string] indent; - if (obj_["lev_markup_number"].to!int > 0) { - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - toc_txt_ = format( - "{ %s }#%s", - heading_toc_, - _anchor_tag, - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.metainfo.is_of_part = "frontmatter"; - comp_obj_toc.metainfo.is_of_section = "toc"; - comp_obj_toc.metainfo.is_of_type = "para"; - comp_obj_toc.metainfo.is_a = "toc"; - comp_obj_toc.metainfo.ocn = 0; - comp_obj_toc.metainfo.object_number_off = ""; - comp_obj_toc.metainfo.object_number_type = 0; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.attrib.bullet = false; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } else { - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.metainfo.is_of_part = "frontmatter"; - comp_obj_toc.metainfo.is_of_section = "toc"; - comp_obj_toc.metainfo.is_of_type = "para"; - comp_obj_toc.metainfo.is_a = "toc"; - comp_obj_toc.metainfo.ocn = 0; - comp_obj_toc.metainfo.object_number_off = ""; - comp_obj_toc.metainfo.object_number_type = 0; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.attrib.bullet = false; - comp_obj_toc.text = "Table of Contents"; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.metainfo.is_of_part = "frontmatter"; - comp_obj_toc.metainfo.is_of_section = "toc"; - comp_obj_toc.metainfo.is_of_type = "para"; - comp_obj_toc.metainfo.is_a = "toc"; - comp_obj_toc.metainfo.ocn = 0; - comp_obj_toc.metainfo.object_number_off = ""; - comp_obj_toc.metainfo.object_number_type = 0; - comp_obj_toc.attrib.bullet = false; - comp_obj_toc.has.inline_links = true; - switch (obj_["lev_markup_number"].to!int) { - case 0: - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "toc.fnSuffix"; - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - case 1: .. case 3: - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - toc_txt_ = format( - "%s", - heading_toc_, - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - case 4: - toc_txt_ = format( - "{ %s }%s%s%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to, - ".fnSuffix", - ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to] = []; - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - case 5: .. case 7: - toc_txt_ = format( - "{ %s }%s%s%s#%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to, - ".fnSuffix", - _anchor_tag, - ); - subtoc_txt_ = format( - "{ %s }#%s", - heading_toc_, - _anchor_tag, - ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to] - ~= munge.url_links(obj_["lev_markup_number"] - ~ "~ " ~ subtoc_txt_.to!string.strip - ); - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - default: - break; - } - return the_table_of_contents_section; - } - invariant() { - } - private: - static int[] heading_num = [ 0, 0, 0, 0 ]; - static string heading_number_auto_composite = ""; - static string _configured_auto_heading_numbering_and_segment_anchor_tags(M,O,CMM)( - M munge_, - O obj_, - CMM conf_make_meta, - bool _new_doc - ) { - debug(asserts) { - static assert(is(typeof(munge_) == string)); - static assert(is(typeof(obj_) == string[string])); - } - if (_new_doc) { - heading_num = [ 0, 0, 0, 0 ]; - heading_number_auto_composite = ""; - } - if (conf_make_meta.make.auto_num_top_lv) { - if (obj_["lev_markup_number"].to!int == 0) { - heading_num[0] = 0; - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - heading_number_auto_composite = ""; - } - /+ auto_num_depth minimum 0 - (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ - if ( - conf_make_meta.make.auto_num_top_lv - > obj_["lev_markup_number"].to!uint - ) { - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == obj_["lev_markup_number"].to!uint - ) { - heading_num[0] ++; - heading_num[1] = 0; - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 1) - ) { - heading_num[1] ++; - heading_num[2] = 0; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 2) - ) { - heading_num[2] ++; - heading_num[3] = 0; - } else if ( - conf_make_meta.make.auto_num_top_lv - == (obj_["lev_markup_number"].to!uint - 3) - ) { - heading_num[3] ++; - } - if (heading_num[3] > 0) { - heading_number_auto_composite - = (conf_make_meta.make.auto_num_depth.to!uint == 3) - ? ( heading_num[0].to!string ~ "." - ~ heading_num[1].to!string ~ "." - ~ heading_num[2].to!string ~ "." - ~ heading_num[3].to!string - ) - : ""; - } else if (heading_num[2] > 0) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 2) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3)) - ? ( heading_num[0].to!string ~ "." - ~ heading_num[1].to!string ~ "." - ~ heading_num[2].to!string - ) - : ""; - } else if (heading_num[1] > 0) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 1) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3)) - ? ( heading_num[0].to!string ~ "." - ~ heading_num[1].to!string - ) - : ""; - } else if (heading_num[0] > 0) { - heading_number_auto_composite - = ((conf_make_meta.make.auto_num_depth.to!uint >= 0) - && (conf_make_meta.make.auto_num_depth.to!uint <= 3)) - ? (heading_num[0].to!string) - : ""; - } else { - heading_number_auto_composite = ""; - } - debug(heading_number_auto) { - writeln(heading_number_auto_composite); - } - if ((!empty(heading_number_auto_composite)) - && (obj_["lev_markup_number"].to!uint >= conf_make_meta.make.auto_num_top_lv)) { - munge_=(munge_) - .replaceFirst(rgx.heading, - "$1~$2 " ~ heading_number_auto_composite ~ ". ") - .replaceFirst(rgx.heading_marker_missing_tag, - "$1~" ~ heading_number_auto_composite ~ " "); - } - } - return munge_; - } - static int heading_num_lev1 = 0; - static string _make_segment_anchor_tags_if_none_provided(M,Lv)( - M munge_, - Lv lev_, - bool _new_doc - ) { - debug(asserts) { - static assert(is(typeof(munge_) == string)); - static assert(is(typeof(lev_) == string)); - } - if (!(munge_.match(rgx.heading_anchor_tag))) { - if (munge_.match(rgx.heading_identify_anchor_tag)) { - if (auto m = munge_.match(rgx.heading_extract_named_anchor_tag)) { - munge_=(munge_).replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ m.captures[1].toLower ~ "_" ~ m.captures[2] ~ " "); - if (auto n = munge_.match(rgx.heading_anchor_tag_plus_colon)) { - auto tag_remunge_ = n.captures[2].replaceAll(rgx.heading_marker_tag_has_colon, ".."); - munge_=(munge_).replaceFirst(rgx.heading_anchor_tag_plus_colon, n.captures[1] ~ tag_remunge_ ~ " "); - } - } else if (auto m = munge_.match(rgx.heading_extract_unnamed_anchor_tag)) { - munge_=(munge_).replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ "s" ~ m.captures[1] ~ " "); - } - } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1" - if (_new_doc) { - heading_num_lev1 = 0; - } - heading_num_lev1 ++; - munge_=(munge_).replaceFirst( - rgx.heading_marker_missing_tag, - "$1~" ~ "x" ~ heading_num_lev1.to!string ~ " "); - } - } - 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 { - string[string] _obj_attrib; - string obj_attributes(Oi,OR,OH)( - Oi obj_is_, - OR obj_raw, - OH _comp_obj_heading, - ) - in { - debug(asserts) { - static assert(is(typeof(obj_is_) == string)); - static assert(is(typeof(obj_raw) == string)); - static assert(is(typeof(_comp_obj_heading) == ObjGenericComposite)); - } - } - body { - scope(exit) { - destroy(obj_is_); - destroy(obj_raw); - destroy(_comp_obj_heading); - } - _obj_attrib["json"] ="{"; - switch (obj_is_) { - case "heading": - _obj_attrib["json"] ~= _heading(obj_raw); - break; - case "para": - _obj_attrib["json"] ~= _para_and_blocks(obj_raw) - ~ _para(obj_raw); - break; - case "code": - _obj_attrib["json"] ~= _code(obj_raw); - break; - case "group": - _obj_attrib["json"] ~= _para_and_blocks(obj_raw) - ~ _group(obj_raw); - break; - case "block": - _obj_attrib["json"] ~= _para_and_blocks(obj_raw) - ~ _block(obj_raw); - break; - case "verse": - _obj_attrib["json"] ~= _verse(obj_raw); - break; - case "quote": - _obj_attrib["json"] ~= _quote(obj_raw); - break; - case "table": - _obj_attrib["json"] ~= _table(obj_raw); - break; - case "comment": - _obj_attrib["json"] ~= _comment(obj_raw); - break; - default: - _obj_attrib["json"] ~= _para(obj_raw); - break; - } - _obj_attrib["json"] ~=" }"; - _obj_attrib["json"]=_set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, _comp_obj_heading); - debug(structattrib) { - if (oa_j["is"].str() == "heading") { - writeln(_obj_attrib["json"]); - writeln( - "is: ", oa_j["is"].str(), - "; object_number: ", oa_j["object_number"].integer() - ); - } - } - return _obj_attrib["json"]; - } - invariant() { - } - private: - string _obj_attributes; - string _para_and_blocks(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - if (obj_txt_in.matchFirst(rgx.para_bullet)) { - _obj_attributes =" \"bullet\": \"true\"," - ~ " \"indent_hang\": 0," - ~ " \"indent_base\": 0,"; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_bullet_indent)) { - _obj_attributes =" \"bullet\": \"true\"," - ~ " \"indent_hang\": " ~ m.captures[1].to!string ~ "," - ~ " \"indent_base\": " ~ m.captures[1].to!string ~ ","; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent_hang)) { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": " ~ m.captures[1].to!string ~ "," - ~ " \"indent_base\": " ~ m.captures[2].to!string ~ ","; - } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent)) { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": " ~ m.captures[1].to!string ~ "," - ~ " \"indent_base\": " ~ m.captures[1].to!string ~ ","; - } else { - _obj_attributes =" \"bullet\": \"false\"," - ~ " \"indent_hang\": 0," - ~ " \"indent_base\": 0,"; - } - return _obj_attributes; - } - string _heading(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"para\"," - ~ " \"is\": \"heading\""; - return _obj_attributes; - } - invariant() { - } - string _para(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"para\"," - ~ " \"is\": \"para\""; - return _obj_attributes; - } - invariant() { - } - string _quote(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"quote\""; - return _obj_attributes; - } - invariant() { - } - string _group(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"group\""; - return _obj_attributes; - } - invariant() { - } - string _block(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"block\""; - return _obj_attributes; - } - invariant() { - } - string _verse(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"verse\""; - return _obj_attributes; - } - invariant() { - } - string _code(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"code\""; - return _obj_attributes; - } - invariant() { - } - string _table(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"content\"," - ~ " \"of\": \"block\"," - ~ " \"is\": \"table\""; - return _obj_attributes; - } - invariant() { - } - string _comment(Ot)(Ot obj_txt_in) - in { - debug(asserts) { - static assert(is(typeof(obj_txt_in) == string)); - } - } - body { - _obj_attributes = " \"use\": \"comment\"," - ~ " \"of\": \"comment\"," - ~ " \"is\": \"comment\""; - return _obj_attributes; - } - invariant() { - } - string _set_additional_values_parse_as_json(OA,Oi,OH)( - OA _obj_attrib, - Oi obj_is_, - OH _comp_obj_heading, - ) { - debug(asserts) { - static assert(is(typeof(_obj_attrib) == string)); - static assert(is(typeof(obj_is_) == string)); - static assert(is(typeof(_comp_obj_heading) == ObjGenericComposite)); - } - JSONValue oa_j = parseJSON(_obj_attrib); - assert( - (oa_j.type == JSON_TYPE.OBJECT) - ); - if (obj_is_ == "heading") { - oa_j.object["object_number"] = _comp_obj_heading.metainfo.ocn; - oa_j.object["lev_markup_number"] = _comp_obj_heading.metainfo.heading_lev_markup; - oa_j.object["lev_collapsed_number"] = _comp_obj_heading.metainfo.heading_lev_collapsed; - oa_j.object["heading_ptr"] - = _comp_obj_heading.ptr.heading; - oa_j.object["doc_object_ptr"] - = _comp_obj_heading.ptr.doc_object; - } - oa_j.object["parent_object_number"] = _comp_obj_heading.metainfo.parent_ocn; - oa_j.object["parent_lev_markup_number"] = _comp_obj_heading.metainfo.parent_lev_markup; - _obj_attrib = oa_j.toString(); - return _obj_attrib; - } - } - /+ +/ - struct BookIndexNuggetHash { - string main_term, sub_term, sub_term_bits; - int object_number_offset, object_number_endpoint; - string[] object_numbers; - string[][string][string] bi; - string[][string][string] hash_nugget; - string[] bi_main_terms_split_arr; - string[][string][string] bookindex_nugget_hash(BI,N,S)( - BI bookindex_section, - N obj_cite_digits, - S segment_anchor_tag, - ) - in { - debug(asserts) { - static assert(is(typeof(bookindex_section) == string)); - static assert(is(typeof(obj_cite_digits.on) == int)); - } - debug(bookindexraw) { - if (!bookindex_section.empty) { - writeln( - "* [bookindex] ", - "[", obj_cite_digits.on.to!string, ": ", segment_anchor_tag, "] ", bookindex_section - ); - } - } - } - body { - static auto rgx = Rgx(); - if (!bookindex_section.empty) { - auto bi_main_terms_split_arr - = bookindex_section.split(rgx.bi_main_terms_split); - foreach (bi_main_terms_content; bi_main_terms_split_arr) { - auto bi_main_term_and_rest - = bi_main_terms_content.split(rgx.bi_main_term_plus_rest_split); - if (auto m = bi_main_term_and_rest[0].match( - rgx.bi_term_and_object_numbers_match) - ) { - main_term = m.captures[1].strip; - object_number_offset = m.captures[2].to!int; - object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ "-" ~ to!string(object_number_endpoint) - ~ ":" ~ segment_anchor_tag); - } else { - main_term = bi_main_term_and_rest[0].strip; - object_numbers ~= obj_cite_digits.on.to!string - ~ ":" ~ segment_anchor_tag; - } - bi[main_term]["_a"] ~= object_numbers; - object_numbers=null; - if (bi_main_term_and_rest.length > 1) { - auto bi_sub_terms_split_arr - = bi_main_term_and_rest[1].split( - rgx.bi_sub_terms_plus_object_number_offset_split - ); - foreach (sub_terms_bits; bi_sub_terms_split_arr) { - if (auto m = sub_terms_bits.match(rgx.bi_term_and_object_numbers_match)) { - sub_term = m.captures[1].strip; - object_number_offset = m.captures[2].to!int; - object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ " - " ~ to!string(object_number_endpoint) - ~ ":" ~ segment_anchor_tag); - } else { - sub_term = sub_terms_bits.strip; - object_numbers ~= to!string(obj_cite_digits.on) - ~ ":" ~ segment_anchor_tag; - } - if (!empty(sub_term)) { - bi[main_term][sub_term] ~= object_numbers; - } - object_numbers=null; - } - } - } - } - hash_nugget = bi; - return hash_nugget; - } - invariant() { - } - } - struct BookIndexReportIndent { - int mkn, skn; - auto bookindex_report_indented(BI)( - BI bookindex_unordered_hashes - ) { - debug(asserts) { - static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string])); - } - auto mainkeys - = bookindex_unordered_hashes.byKey.array.sort().release; - foreach (mainkey; mainkeys) { - debug(bookindex1) { - writeln(mainkey); - } - auto subkeys - = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; - foreach (subkey; subkeys) { - debug(bookindex1) { - writeln(" ", subkey); - writeln(" ", to!string( - bookindex_unordered_hashes[mainkey][subkey] - )); - } - ++skn; - } - ++mkn; - } - } - } - struct BookIndexReportSection { - int mkn, skn; - static auto rgx = Rgx(); - static auto munge = ObjInlineMarkupMunge(); - auto bookindex_write_section(BI)( - BI bookindex_unordered_hashes - ) { - debug(asserts) { - static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string])); - } - auto mainkeys=bookindex_unordered_hashes.byKey.array.sort().release; - foreach (mainkey; mainkeys) { - write("_0_1 !{", mainkey, "}! "); - foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - auto go = (ref_).replaceAll(rgx.book_index_go, "$1"); - write(" {", ref_, "}#", go, ", "); - } - writeln(" \\\\"); - bookindex_unordered_hashes[mainkey].remove("_a"); - auto subkeys - = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; - foreach (subkey; subkeys) { - write(" ", subkey, ", "); - foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - auto go = (ref_).replaceAll(rgx.book_index_go, "$1"); - write(" {", ref_, "}#", go, ", "); - } - writeln(" \\\\"); - ++skn; - } - ++mkn; - } - } - auto bookindex_build_abstraction_section(BI,N,B)( - BI bookindex_unordered_hashes, - N obj_cite_digits, - B opt_action, - ) { - debug(asserts) { - static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string])); - static assert(is(typeof(obj_cite_digits.on) == int)); - } - mixin SiSUnode; - mixin InternalMarkup; - static auto mkup = InlineMarkup(); - string type_is; - string lev; - int heading_lev_markup, heading_lev_collapsed; - string attrib; - int[string] indent; - auto mainkeys - = bookindex_unordered_hashes.byKey.array.sort().release; - ObjGenericComposite[][string] bookindex_section; - ObjGenericComposite comp_obj_heading_, comp_obj_para; - auto node_para_int_ = node_metadata_para_int; - auto node_para_str_ = node_metadata_para_str; - if ((mainkeys.length > 0) - && (opt_action.backmatter - && opt_action.section_bookindex)) { - string bi_tmp_seg, bi_tmp_scroll; - string[] bi_tmp_tags; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bookindex"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Book Index"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_book_index"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; - ++mkn; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bookindex"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Index"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "bookindex"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading.has.inline_links = false; - comp_obj_heading_.tags.anchor_tags = ["bookindex"]; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; - ++mkn; - import std.array : appender; - auto buffer = appender!(char[])(); - string[dchar] transTable = [' ' : "_"]; - foreach (mainkey; mainkeys) { - bi_tmp_tags = [""]; - bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; - buffer.clear(); - bi_tmp_tags ~= translate(mainkey, transTable); - bi_tmp_seg = "!{" ~ mainkey ~ "}! "; - auto bkidx_lnk_seg(string locs) { - string markup = ""; - if (auto m = locs.matchFirst(rgx.book_index_go_seg)) { - markup - = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk ~ m["seg"] ~ ".fnSuffix" - ~ "#" ~ m["ocn"] ~ ", "); - } else { - writeln(__LINE__, ": ", locs); - } - return markup; - } - auto bkidx_lnk_scroll(string locs) { - string markup = ""; - if (auto m = locs.matchFirst(rgx.book_index_go)) { - markup - = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk - ~ "#" ~ m["ocn"] ~ ", "); - } else { - writeln(__LINE__, ": ", locs); - } - return markup; - } - foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); - } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; - bookindex_unordered_hashes[mainkey].remove("_a"); - auto subkeys - = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; - foreach (subkey; subkeys) { - bi_tmp_scroll ~= subkey ~ ", "; - buffer.clear(); - bi_tmp_tags ~= translate(subkey, transTable); - bi_tmp_seg ~= subkey ~ ", "; - foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); - } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; - ++skn; - } - bi_tmp_scroll = (bi_tmp_scroll).replaceFirst(rgx.trailing_linebreak, ""); - bi_tmp_seg = (bi_tmp_seg).replaceFirst(rgx.trailing_linebreak, ""); - comp_obj_para = comp_obj_para.init; - comp_obj_para.metainfo.is_of_part = "backmatter"; - comp_obj_para.metainfo.is_of_section = "bookindex"; - comp_obj_para.metainfo.is_of_type = "para"; - comp_obj_para.metainfo.is_a = "bookindex"; - comp_obj_para.text = bi_tmp_scroll.to!string.strip; - comp_obj_para.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_para.tags.anchor_tags = bi_tmp_tags; - comp_obj_para.attrib.indent_hang = 0; - comp_obj_para.attrib.indent_base = 1; - comp_obj_para.attrib.bullet = false; - comp_obj_para.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_para; - comp_obj_para.text = bi_tmp_seg.to!string.strip; - bookindex_section["seg"] ~= comp_obj_para; - ++mkn; - } - } else { // no book index, (figure out what to do here) - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.text = "(skip) there is no Book Index"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; - } - auto t = tuple(bookindex_section, obj_cite_digits); - return t; - } - } - /+ +/ - struct NotesSection { - string[string] object_notes; - int previous_count; - int mkn; - static auto rgx = Rgx(); - private auto gather_notes_for_endnote_section( - ObjGenericComposite[] contents_am, - string segment_anchor_tag_that_object_belongs_to, - int cntr, - ) - in { - assert((contents_am[cntr].metainfo.is_a == "para") - || (contents_am[cntr].metainfo.is_a == "heading") - || (contents_am[cntr].metainfo.is_a == "quote") - || (contents_am[cntr].metainfo.is_a == "group") - || (contents_am[cntr].metainfo.is_a == "block") - || (contents_am[cntr].metainfo.is_a == "verse")); - assert(cntr >= previous_count); - assert( - (contents_am[cntr].text).match( - rgx.inline_notes_delimiter_al_regular_number_note) - ); - } - body { - mixin InternalMarkup; - previous_count=cntr; - static auto mkup = InlineMarkup(); - static auto munge = ObjInlineMarkupMunge(); - foreach( - m; - (contents_am[cntr].text).matchAll( - rgx.inline_notes_delimiter_al_regular_number_note - ) - ) { - debug(endnotes_build) { - writeln( - "{^{", m.captures[1], ".}^}" - ~ mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to, - ".fnSuffix#noteref_\n ", m.captures[1], " ", - m.captures[2]); // sometimes need segment name (segmented html & epub) - } - // you need anchor for segments at this point -> - object_notes["anchor"] ~= "note_" ~ m.captures[1] ~ "』"; - object_notes["notes"] ~= (segment_anchor_tag_that_object_belongs_to.empty) - ? (munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}#noteref_" - ~ m.captures[1]) ~ " " - ~ m.captures[2] ~ "』" - ) - : (munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}" - ~ mkup.mark_internal_site_lnk - ~ segment_anchor_tag_that_object_belongs_to - ~ ".fnSuffix#noteref_" - ~ m.captures[1]) ~ " " - ~ m.captures[2] ~ "』" - ); - } - return object_notes; - } - private auto gathered_notes() - in { - } - body { - string[][string] endnotes_; - if (object_notes.length > 1) { - endnotes_["notes"] = (object_notes["notes"].split(rgx.break_string))[0..$-1]; - endnotes_["anchor"] = (object_notes["anchor"].split(rgx.break_string))[0..$-1]; - } else { - endnotes_["notes"] = []; - endnotes_["anchor"] = []; - } - return endnotes_; - } - private auto endnote_objects(N,O)( - N obj_cite_digits, - O opt_action, - ) - in { - } - body { - mixin SiSUnode; - ObjGenericComposite[] the_endnotes_section; - auto endnotes_ = gathered_notes(); - string type_is; - string lev, lev_markup_number, lev_collapsed_number; - string attrib; - int[string] indent; - ObjGenericComposite comp_obj_heading_; - if ((endnotes_["notes"].length > 0) - && (opt_action.backmatter && opt_action.section_endnotes)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "endnotes"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Endnotes"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_endnotes"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_endnotes_section ~= comp_obj_heading_; - ++mkn; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "endnotes"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Endnotes"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "endnotes"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["endnotes"]; - the_endnotes_section ~= comp_obj_heading_; - ++mkn; - } else { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there are no Endnotes"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_endnotes_section ~= comp_obj_heading_; - } - if (opt_action.backmatter && opt_action.section_endnotes) { - ObjGenericComposite comp_obj_endnote_; - comp_obj_endnote_ = comp_obj_endnote_.init; - comp_obj_endnote_.metainfo.is_of_part = "backmatter"; - comp_obj_endnote_.metainfo.is_of_section = "endnote"; - comp_obj_endnote_.metainfo.is_of_type = "para"; - comp_obj_endnote_.metainfo.is_a = "endnote"; - comp_obj_endnote_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_endnote_.attrib.indent_hang = 0; - comp_obj_endnote_.attrib.indent_base = 0; - comp_obj_endnote_.attrib.bullet = false; - foreach (i, endnote; endnotes_["notes"]) { - auto m = endnote.matchFirst(rgx.note_ref); - string notenumber = m.captures[1].to!string; - string anchor_tag = "note_" ~ notenumber; - comp_obj_endnote_.tags.anchor_tags = [ endnotes_["anchor"][i] ]; - comp_obj_endnote_.has.inline_links = true; - comp_obj_endnote_.text = endnote.strip; - the_endnotes_section ~= comp_obj_endnote_; - } - } - auto t = tuple(the_endnotes_section, obj_cite_digits); - return t; - } - } - /+ +/ - struct Bibliography { - public JSONValue[] _bibliography_(Bi,BJ)( - return ref Bi biblio_unsorted_incomplete, - return ref BJ bib_arr_json - ) - in { - debug(asserts) { - static assert(is(typeof(biblio_unsorted_incomplete) == string[])); - static assert(is(typeof(bib_arr_json) == JSONValue[])); - } - } - body { - JSONValue[] biblio_unsorted - = _biblio_unsorted_complete_(biblio_unsorted_incomplete, bib_arr_json); - biblio_arr_json = []; - biblio_unsorted_incomplete = []; - JSONValue[] biblio_sorted__ = biblio_sort(biblio_unsorted); - biblio_debug(biblio_sorted__); - debug(biblio0) { - writeln("---"); - writeln("unsorted incomplete: ", biblio_unsorted_incomplete.length); - writeln("json: ", bib_arr_json.length); - writeln("unsorted: ", biblio_unsorted.length); - writeln("sorted: ", biblio_sorted__.length); - int cntr; - int[7] x; - while (cntr < x.length) { - writeln(cntr, ": ", biblio_sorted__[cntr]["fulltitle"]); - cntr++; - } - } - return biblio_sorted__; - } - final private JSONValue[] _biblio_unsorted_complete_(Bi,BJ)( - Bi biblio_unordered, - return ref BJ bib_arr_json - ) { - debug(asserts) { - static assert(is(typeof(biblio_unordered) == string[])); - static assert(is(typeof(bib_arr_json) == JSONValue[])); - } - foreach (bibent; biblio_unordered) { - /+ update bib to include deemed_author, needed for: - sort_bibliography_array_by_deemed_author_year_title - either: sort on multiple fields, or; create such sort field - +/ - JSONValue j = parseJSON(bibent); - if (!empty(j["fulltitle"].str)) { - if (!empty(j["author_raw"].str)) { - j["deemed_author"]=j["author_arr"][0]; - } else if (!empty(j["editor_raw"].str)) { - j["deemed_author"]=j["editor_arr"][0]; - } - j["sortby_deemed_author_year_title"] = ( - j["deemed_author"].str ~ - "; " ~ - j["year"].str ~ - "; " ~ - j["fulltitle"].str - ); - } - bib_arr_json ~= j; - } - JSONValue[] biblio_unsorted_array_of_json_objects - = bib_arr_json.dup; - destroy(bib_arr_json); - return biblio_unsorted_array_of_json_objects; - } - final private JSONValue[] biblio_sort(BJ)(BJ biblio_unordered) { - debug(asserts) { - static assert(is(typeof(biblio_unordered) == JSONValue[])); - } - JSONValue[] biblio_sorted_; - biblio_sorted_ - = sort!((a, b){ - return ((a["sortby_deemed_author_year_title"].str) < (b["sortby_deemed_author_year_title"].str)); - })(biblio_unordered).array; - debug(bibliosorted) { - foreach (j; biblio_sorted_) { - if (!empty(j["fulltitle"].str)) { - writeln(j["sortby_deemed_author_year_title"]); - } - } - } - return biblio_sorted_; - } - void biblio_debug(BJ)(BJ biblio_sorted) { - debug(asserts) { - static assert(is(typeof(biblio_sorted) == JSONValue[])); - } - debug(biblio0) { - foreach (j; biblio_sorted) { - if (!empty(j["fulltitle"].str)) { - writeln(j["sortby_deemed_author_year_title"]); - } - } - } - } - } - /+ +/ - struct NodeStructureMetadata { - int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; - int obj_cite_digit; - int[string] p_; // p_ parent_ - static auto rgx = Rgx(); - ObjGenericComposite node_location_emitter(Lv,Ta,N,C,P,I)( - Lv lev_markup_number, - Ta segment_anchor_tag, - N obj_cite_digits, - C cntr_, - P ptr_, - I is_ - ) - in { - debug(asserts) { - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(is_) == string)); - } - assert(is_ != "heading"); - assert(obj_cite_digits.on.to!int >= 0); - } - body { - assert(is_ != "heading"); // should not be necessary - assert(obj_cite_digits.on.to!int >= 0); // should not be necessary - if (lv7 > State.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_4; - p_["object_number"] = lv7; - } else if (lv6 > State.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_3; - p_["object_number"] = lv6; - } else if (lv5 > State.off) { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_2; - p_["object_number"] = lv5; - } else { - p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; - p_["object_number"] = lv4; - } - ObjGenericComposite comp_obj_location; - comp_obj_location = comp_obj_location.init; - comp_obj_location.metainfo.is_a = is_; - comp_obj_location.metainfo.ocn = obj_cite_digits.on; - comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; - comp_obj_location.metainfo.parent_ocn = p_["object_number"]; - comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; - debug(_node) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { - writeln("x ", _node.to!string); - } else { - writeln("- ", _node.to!string); - } - } - assert(comp_obj_location.metainfo.parent_lev_markup >= 4); - assert(comp_obj_location.metainfo.parent_lev_markup <= 7); - assert(comp_obj_location.metainfo.parent_ocn >= 0); - return comp_obj_location; - } - invariant() { - } - ObjGenericComposite node_emitter_heading(T,Lm,Lc,Ta,N,C,P,LA,I,PSn,fNr,fNs,fL)( - T _text, - Lm lev_markup_number, - Lc lev_collapsed_number, - Ta segment_anchor_tag, - N obj_cite_digits, - C cntr_, - P ptr_, - LA lv_ancestors_txt, - I is_, - PSn html_segnames_ptr, - fNr flag_notes_reg, - fNs flag_notes_star, - fL flag_links, - ) - in { - debug(asserts) { - static assert(is(typeof(_text) == string)); - static assert(is(typeof(lev) == string)); - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(lev_collapsed_number) == string)); - static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(lv_ancestors_txt) == string[])); - static assert(is(typeof(is_) == string)); - static assert(is(typeof(html_segnames_ptr) == int)); - } - assert(is_ == "heading"); - assert((obj_cite_digits.on).to!int >= 0); - assert( - lev_markup_number.match(rgx.levels_numbered), - ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ obj_cite_digits.on.to!string) - ); - if (lev_markup_number.match(rgx.levels_numbered)) { - if (lev_markup_number.to!int == 0) { - /+ TODO first hit (of two) with this assertion failure, check, fix & reinstate - assert(obj_cite_digits.on.to!int == 1, - "ERROR header lev markup number is: " ~ - lev_markup_number.to!string ~ - " obj_cite_digits.on.to!int should == 1 but is: " ~ - obj_cite_digits.on.to!string ~ - "\n" ~ _text); - +/ - } - } - } - body { - switch (lev_markup_number.to!int) { - case 0: - lv = DocStructMarkupHeading.h_sect_A; - lv0 = obj_cite_digit; - lv1=0; lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; - p_["lev_markup_number"] = 0; - p_["object_number"] = 0; - break; - case 1: - lv = DocStructMarkupHeading.h_sect_B; - lv1 = obj_cite_digit; - lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_A; - p_["object_number"] = lv0; - break; - case 2: - lv = DocStructMarkupHeading.h_sect_C; - lv2 = obj_cite_digit; - lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_B; - p_["object_number"] = lv1; - break; - case 3: - lv = DocStructMarkupHeading.h_sect_D; - lv3=obj_cite_digit; - lv4=0; lv5=0; lv6=0; lv7=0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_C; - p_["object_number"] = lv2; - break; - case 4: - lv = DocStructMarkupHeading.h_text_1; - lv4 = obj_cite_digit; - lv5=0; lv6=0; lv7=0; - if (lv3 > State.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_D; - p_["object_number"] = lv3; - } else if (lv2 > State.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_C; - p_["object_number"] = lv2; - } else if (lv1 > State.off) { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_B; - p_["object_number"] = lv1; - } else { - p_["lev_markup_number"] - = DocStructMarkupHeading.h_sect_A; - p_["object_number"] = lv0; - } - break; - case 5: - lv = DocStructMarkupHeading.h_text_2; - lv5 = obj_cite_digit; - lv6=0; lv7=0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_1; - p_["object_number"] = lv4; - break; - case 6: - lv = DocStructMarkupHeading.h_text_3; - lv6 = obj_cite_digit; - lv7=0; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_2; - p_["object_number"] = lv5; - break; - case 7: - lv = DocStructMarkupHeading.h_text_4; - lv7 = obj_cite_digit; - p_["lev_markup_number"] - = DocStructMarkupHeading.h_text_3; - p_["object_number"] = lv6; - break; - default: - break; - } - ObjGenericComposite _comp_obj_heading_; - _comp_obj_heading_ = _comp_obj_heading_.init; - _comp_obj_heading_.metainfo.is_of_part = "body"; - _comp_obj_heading_.metainfo.is_of_section = "body"; - _comp_obj_heading_.metainfo.is_of_type = "para"; - _comp_obj_heading_.metainfo.is_a = "heading"; - _comp_obj_heading_.text = _text.to!string.strip; - _comp_obj_heading_.metainfo.ocn = obj_cite_digits.on; - _comp_obj_heading_.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type; - _comp_obj_heading_.tags.segment_anchor_tag = segment_anchor_tag.to!string; - _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); - _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); - _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"]; - _comp_obj_heading_.metainfo.parent_lev_markup = p_["lev_markup_number"]; - _comp_obj_heading_.tags.heading_ancestors_text = lv_ancestors_txt; - _comp_obj_heading_.ptr.doc_object = cntr_; - _comp_obj_heading_.ptr.html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0); - _comp_obj_heading_.ptr.heading = ptr_; - _comp_obj_heading_.has.inline_notes_reg = flag_notes_reg; - _comp_obj_heading_.has.inline_notes_star = flag_notes_star; - _comp_obj_heading_.has.inline_links = flag_links; - debug(_node) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { - writeln("* ", _node.to!string); - } - } - debug(nodeheading) { - if (lev_markup_number.match(rgx.levels_numbered_headings)) { - writeln("* ", _node.to!string); - } - } - assert(_comp_obj_heading_.metainfo.parent_lev_markup <= 7); - assert(_comp_obj_heading_.metainfo.parent_ocn >= 0); - if (lev_markup_number.match(rgx.levels_numbered_headings)) { - assert(_comp_obj_heading_.metainfo.heading_lev_markup <= 7); - assert(_comp_obj_heading_.metainfo.ocn >= 0); - if (_comp_obj_heading_.metainfo.parent_lev_markup > 0) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup < _comp_obj_heading_.metainfo.heading_lev_markup); - if (_comp_obj_heading_.metainfo.ocn != 0) { - assert(_comp_obj_heading_.metainfo.parent_ocn < _comp_obj_heading_.metainfo.ocn); - } - } - if (_comp_obj_heading_.metainfo.heading_lev_markup == 0) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_B) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_C) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_B); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_D) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_C); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_1) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup <= DocStructMarkupHeading.h_sect_D); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_2) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_1); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_3) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_2); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_4) { - assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_3); - } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_5) { - } - } - return _comp_obj_heading_; - } - invariant() { - } - } - /+ abstraction functions emitters ↑ +/ - /+ ↓ abstraction functions assertions +/ - pure void assertions_doc_structure(O,Lv)( - O an_object, - Lv lv - ) { - debug(asserts) { - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(lv) == int[string])); - } - if (lv["h3"] > State.off) { - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h2"] > State.off); - } else if (lv["h2"] > State.off) { - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h3"] == State.off); - } else if (lv["h1"] > State.off) { - assert(lv["h0"] > State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - } else if (lv["h0"] > State.off) { - assert(lv["h1"] == State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - } else { - assert(lv["h0"] == State.off); - assert(lv["h1"] == State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - } - if (lv["h7"] > State.off) { - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - assert(lv["h6"] > State.off); - } else if (lv["h6"] > State.off) { - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - assert(lv["h7"] == State.off); - } else if (lv["h5"] > State.off) { - assert(lv["h4"] > State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } else if (lv["h4"] > State.off) { - assert(lv["h5"] == State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } else { - assert(lv["h4"] == State.off); - assert(lv["h5"] == State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } - if (lv["h0"] == State.off) { - assert(lv["h1"] == State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - assert(lv["h4"] == State.off); - assert(lv["h5"] == State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } - if (lv["h1"] == State.off) { - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - } - if (lv["h2"] == State.off) { - assert(lv["h3"] == State.off); - } - if (lv["h3"] == State.off) { - } - if (lv["h4"] == State.off) { - assert(lv["h5"] == State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } - if (lv["h5"] == State.off) { - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } - if (lv["h6"] == State.off) { - assert(lv["h7"] == State.off); - } - if (lv["h7"] == State.off) { - } - switch ((an_object["lev"]).to!string) { - case "A": - if (lv["h0"] == State.off) { - assert(lv["h1"] == State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - assert(lv["h4"] == State.off); - assert(lv["h5"] == State.off); - assert(lv["h6"] == State.off); - assert(lv["h7"] == State.off); - } else { // (lv["h0"] > State.off) - assert(lv["h0"] == State.off,"error should not enter level A a second time"); - } - break; - case "B": - if (lv["h1"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h2"] == State.off); - assert(lv["h3"] == State.off); - } else { // (lv["h1"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - } - break; - case "C": - if (lv["h2"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h3"] == State.off); - } else { // (lv["h2"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h2"] > State.off); - } - break; - case "D": - if (lv["h3"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h2"] > State.off); - } else { // (lv["h3"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h1"] > State.off); - assert(lv["h2"] > State.off); - assert(lv["h3"] > State.off); - } - break; - case "1": - if (lv["h4"] == State.off) { - assert(lv["h0"] > State.off); - } else { // (lv["h4"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - } - break; - case "2": - if (lv["h5"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - } else { // (lv["h5"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - } - break; - case "3": - if (lv["h6"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - } else { // (lv["h6"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - assert(lv["h6"] > State.off); - } - break; - case "4": - if (lv["h7"] == State.off) { - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - assert(lv["h6"] > State.off); - } else { // (lv["h7"] > State.off) - assert(lv["h0"] > State.off); - assert(lv["h4"] > State.off); - assert(lv["h5"] > State.off); - assert(lv["h6"] > State.off); - assert(lv["h7"] > State.off); - } - break; - default: - break; - } - } - pure void assertions_flag_types_block_status_none_or_closed(T)(T obj_type_status) { - debug(asserts) { - static assert(is(typeof(obj_type_status) == int[string])); - } - assert( - (obj_type_status["code"] == TriState.off) - || (obj_type_status["code"] == TriState.closing), - "code block status: off or closing"); - assert( - (obj_type_status["poem"] == TriState.off) - || (obj_type_status["poem"] == TriState.closing), - "poem status: off or closing"); - assert( - (obj_type_status["table"] == TriState.off) - || (obj_type_status["table"] == TriState.closing), - "table status: off or closing"); - assert( - (obj_type_status["group"] == TriState.off) - || (obj_type_status["group"] == TriState.closing), - "group block status: off or closing"); - assert( - (obj_type_status["block"] == TriState.off) - || (obj_type_status["block"] == TriState.closing), - "block status: off or closing"); - } - /+ abstraction functions assertions ↑ +/ -} /+ ← closed: template SiSUdocAbstraction +/ -template docSectKeysSeq() { - auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { - struct doc_sect_keys_seq { - auto seg() { - return document_section_keys_sequenced["seg"]; - } - auto scroll() { - return document_section_keys_sequenced["scroll"]; - } - auto sql() { - return document_section_keys_sequenced["sql"]; - } - } - return doc_sect_keys_seq(); - } -} diff --git a/src/sdp/meta/metadoc_summary.d b/src/sdp/meta/metadoc_summary.d deleted file mode 100644 index 2ac2454..0000000 --- a/src/sdp/meta/metadoc_summary.d +++ /dev/null @@ -1,101 +0,0 @@ -module sdp.meta.metadoc_summary; -template SiSUabstractionSummary() { - auto SiSUabstractionSummary(S,T)( - auto ref const S doc_abstraction, - auto ref T doc_matters, - ) { - import - sdp.meta.defaults, - sdp.meta.rgx; - import - std.array, - std.exception, - std.regex, - std.stdio, - std.string, - std.traits, - std.typecons, - std.uni, - std.utf, - std.conv : to; - mixin InternalMarkup; - auto markup = InlineMarkup(); - if (doc_matters.opt.action.verbose) { - string[string] check = [ - "last_object_number" : "NA [debug \"checkdoc\" not run]", - "last_object_number_body" : "0", - "last_object_number_book_index" : "0", - ]; - foreach (k; doc_matters.xml.keys_seq.seg) { - foreach (obj; doc_abstraction[k]) { - if (obj.metainfo.is_of_part != "empty") { - if (!empty(obj.metainfo.object_number)) { - if (k == "body") { - check["last_object_number_body"] = obj.metainfo.object_number; - } - if (!(obj.metainfo.object_number.empty)) { - check["last_object_number"] = obj.metainfo.object_number; - } - } - if (k == "bookindex_seg") { - if (obj.metainfo.object_number_type == 2) { - check["last_object_number_book_index"] = obj.metainfo.object_number_book_index; - } - } - } - } - } - auto min_repeat_number = 66; - auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length - + doc_matters.conf_make_meta.meta.creator_author.length + 4); - char_repeat_number = (char_repeat_number > min_repeat_number) - ? char_repeat_number - : min_repeat_number; - writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", - markup.repeat_character_by_number_provided("-", char_repeat_number), - doc_matters.conf_make_meta.meta.title_full, - doc_matters.conf_make_meta.meta.creator_author, - doc_matters.src.filename, - markup.repeat_character_by_number_provided("-", char_repeat_number), - "length toc arr:", - to!int(doc_abstraction["toc_seg"].length), - "length doc_abstraction arr:", - to!int(doc_abstraction["body"].length), - "last doc body ocn:", - to!int(check["last_object_number_body"]), - "last object_number:", - to!int(check["last_object_number"]), - "length endnotes:", // subtract headings - (doc_abstraction["endnotes"].length > 2) - ? (to!int(doc_abstraction["endnotes"].length - 2)) - : 0, - "length glossary:", - (doc_abstraction["glossary"].length > 1) - ? (to!int(doc_abstraction["glossary"].length)) - : 0, - "length biblio:", - (doc_abstraction["bibliography"].length > 1) - ? (to!int(doc_abstraction["bibliography"].length)) - : 0, - "length bookindex:", - (doc_abstraction["bookindex_seg"].length > 1) - ? (to!int(doc_abstraction["bookindex_seg"].length)) - : 0, - " last book idx ocn:", - to!int(check["last_object_number_book_index"]), - "length blurb:", - (doc_abstraction["blurb"].length > 1) - ? (to!int(doc_abstraction["blurb"].length)) - : 0, - "number of segments:", - (doc_matters.xml.segnames.length > 1) - ? (to!int(doc_matters.xml.segnames.length)) - : 0, - __FILE__, - __LINE__, - markup.repeat_character_by_number_provided("-", min_repeat_number), - ); - } - } -} diff --git a/src/sdp/meta/object_setter.d b/src/sdp/meta/object_setter.d deleted file mode 100644 index fc0781e..0000000 --- a/src/sdp/meta/object_setter.d +++ /dev/null @@ -1,126 +0,0 @@ -/++ - object setter: - setting of sisu objects for downstream processing - meta_object_setter.d -+/ -module sdp.meta.object_setter; -template ObjectSetter() { - /+ structs +/ - struct DocObj_MetaInfo_ { - string is_of_part = ""; // frontmatter, body, backmatter - string is_of_section = ""; // toc, body, glossary, biography, book index, blurb - string is_of_type = ""; // para, block ? - string is_a = ""; // heading, para, table, code block, group, ... - alias of_part = is_of_part; - alias of_section = is_of_section; - alias is_of = is_of_type; - /+ o_n +/ - int o_n_substantive = 0; - int o_n_non_substantive = 0; - int o_n_glossary = 0; - int o_n_bibliography = 0; - int o_n_book_index = 0; - int o_n_blurb = 0; - string object_number_substantive() const @property { - return (o_n_substantive==0) ? "" : o_n_substantive.to!string; - } - string object_number_non_substantive() const @property { - return (o_n_non_substantive==0) ? "" : o_n_non_substantive.to!string; - } - string object_number_glossary() const @property { - return (o_n_glossary==0) ? "" : o_n_glossary.to!string; - } - string object_number_bibliography() const @property { - return (o_n_bibliography==0) ? "" : o_n_bibliography.to!string; - } - string object_number_book_index() const @property { - return (o_n_book_index==0) ? "" : o_n_book_index.to!string; - } - string object_number_blurb() const @property { - return (o_n_blurb==0) ? "" : o_n_blurb.to!string; - } - string object_number_off = ""; - bool visible_object_number = false; - // enum ONtype { none, substantive, non_substantive, glossary, bibliography, book_index, blurb, comment } - int object_number_type = 0; // { ocn, non, bkidx } - /+ node +/ - string[string][string] node; - int ocn = 0; - string object_number() const @property { - return (ocn==0) ? "" : ocn.to!string; - } - int o_n_type = 0; - int heading_lev_markup = 9; - int heading_lev_collapsed = 9; - string marked_up_level() const @property { - string _out; - switch (heading_lev_markup) { - case 0: _out = "A"; break; - case 1: _out = "B"; break; - case 2: _out = "C"; break; - case 3: _out = "D"; break; - case 4: _out = "1"; break; - case 5: _out = "2"; break; - case 6: _out = "3"; break; - case 7: _out = "4"; break; - default: _out = ""; break; - } - return _out; - } - int[] markedup_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] collapsed_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int parent_lev_markup = 0; - int parent_ocn = 0; - int last_decendant_ocn = 0; - } - struct DocObj_TxtAttrib_ { - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; // not implemented, consider - } - struct DocObj_Has_ { // has - bool inline_links = false; - bool inline_notes_reg = false; - bool inline_notes_star = false; - bool contains_image_without_dimensions = false; - } - struct DocObj_Table_ { - int number_of_columns = 0; - double[] column_widths = []; - string[] column_aligns = []; - bool heading = false; - bool walls = false; // not implemented - } - struct DocObj_CodeBlock_ { - string syntax = ""; - } - struct DocObj_Pointer_ { - int doc_object = 0; - int html_segnames = 0; - int heading = 0; - } - struct DocObj_Tags_ { - string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE - string segment_anchor_tag = ""; - string segname_prev = ""; - string segname_next = ""; - string[] lev4_subtoc = []; - string[] anchor_tags = []; - } - struct ObjGenericComposite { - string text = ""; - DocObj_MetaInfo_ metainfo; - DocObj_TxtAttrib_ attrib; - DocObj_Tags_ tags; - DocObj_Has_ has; - DocObj_Table_ table; - DocObj_CodeBlock_ code_block; - DocObj_Pointer_ ptr; - } - struct TheObjects { - ObjGenericComposite[] oca; - } -} diff --git a/src/sdp/meta/package.d b/src/sdp/meta/package.d deleted file mode 100644 index fcc6b13..0000000 --- a/src/sdp/meta/package.d +++ /dev/null @@ -1,17 +0,0 @@ -module sdp.meta; -public import - sdp.meta.defaults, - sdp.meta.rgx; -/+ std +/ -public import - std.array, - std.exception, - std.range, - std.regex, - std.stdio, - std.string, - std.traits, - std.typecons, - // std.uni, - std.utf, - std.conv : to; diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d deleted file mode 100644 index b64f7ba..0000000 --- a/src/sdp/meta/rgx.d +++ /dev/null @@ -1,290 +0,0 @@ -/++ - regex: regular expressions used in sisu document parser -+/ -module sdp.meta.rgx; -static template SiSUrgxInit() { - import sdp.meta.defaults; - static struct Rgx { - /+ misc +/ - static true_dollar = ctRegex!(`\$`, "gm"); - static flag_action = ctRegex!(`^(--[a-z][a-z0-9-]+)$`); - static flag_action_str = ctRegex!(` (--[a-z][a-z0-9-]+)`); - static within_quotes = ctRegex!(`"(.+?)"`); - static make_heading_delimiter = ctRegex!(`[;][ ]*`); - static arr_delimiter = ctRegex!(`[ ]*[;][ ]*`); - static name_delimiter = ctRegex!(`^([^,]+)[ ]*,[ ]+(.+?)$`); - static book_index_go = ctRegex!("(?P<link>(?P<ocn>[0-9]+)(?:-[0-9]+)?)"); - static book_index_go_scroll = ctRegex!("(?P<link>(?P<ocn>[0-9]+)(?:-[0-9]+)?)"); - static book_index_go_seg = ctRegex!("(?P<link>(?P<ocn>[0-9]+)(?:-[0-9]+)?):(?P<seg>[a-z0-9_-]+)"); - static book_index_go_seg_ = ctRegex!("(?P<link>(?P<ocn>[0-9]+)(?:-[0-9]+)?)(:(?P<seg>[a-z0-9_-]+))?"); - static book_index_go_seg_anchorless = ctRegex!("(?P<link>(?P<ocn>[0-9]+)(?:-[0-9]+)?)"); - static trailing_comma = ctRegex!(",[ ]*$"); - static trailing_linebreak = ctRegex!(",[ ]{1,2}\\\\\\\\\n[ ]{4}$","m"); - static newline_eol_delimiter = ctRegex!("\n"); - static newline_eol_strip_preceding = ctRegex!("[ ]*\n"); - static newline_eol_delimiter_only = ctRegex!("^\n"); - static line_delimiter_ws_strip = ctRegex!("[ ]*\n[ ]*"); - static para_delimiter = ctRegex!("\n[ ]*\n+"); - static table_col_delimiter = ctRegex!("[ ]*\n+", "mg"); - static table_row_delimiter = ctRegex!("\n[ ]*\n+", "mg"); - static table_row_delimiter_special = ctRegex!("[ ]*\n", "mg"); - static table_col_delimiter_special = ctRegex!("[ ]*[|][ ]*", "mg"); - static levels_markup = ctRegex!(`^[A-D1-4]$`); - static levels_numbered = ctRegex!(`^[0-9]$`); - static levels_numbered_headings = ctRegex!(`^[0-7]$`); - static numeric = ctRegex!(`[ 0-9,.-]+`); - static numeric_col = ctRegex!(`^[ 0-9,.$£₤Є€€¥-]+$`); - /+ comments +/ - static comment = ctRegex!(`^%+ `); - static comments = ctRegex!(`^%+ |^%+$`); - /+ header +/ - static make_simple_substitutions_rb = ctRegex!(`(?P<substitution>/(?P<match>.+?)/,[ ]*['"](?P<replace>.+?)['"])`); - static make_simple_substitutions_d = ctRegex!(`(?P<substitution>` ~ '`' ~ `(?P<match>.+?)` ~ '`' ~ `,[ ]*['"](?P<replace>.+?)['"])`); - /+ header +/ - static main_headers = - ctRegex!(`^(?:creator|title|rights|date|original|classify|identifier|notes|publisher|make|links)$`, "m"); - static native_header = ctRegex!(`^@([a-z_]+):(?:\s|$)`); - static native_header_make = ctRegex!(`^@(make):(?:\s|$)`); - static native_header_meta = - ctRegex!(`^@(?:creator|title|rights|date|original|classify|identifier|notes|publisher|links):(?:\s|$)`); - static native_header_main = ctRegex!(`^@(?P<header>[a-z_]+):\s*(?P<content>.*)`, "m"); - static native_header_sub = ctRegex!(`^[ ]*:(?P<subheader>[a-z_]+):\s+(?P<content>.+)`, "m"); - static native_header_meta_title = ctRegex!(`^@title:\s`, "m"); - static variable_doc_title = ctRegex!(`@title`); - static variable_doc_author = ctRegex!(`@author|@creator`); - static raw_author_munge = ctRegex!(`(\S.+?),\s+(.+)`,"i"); - static toml_header_meta_title = ctRegex!(`^\s*(title\s*=\s*"|\[title\])`, "m"); - /+ head +/ - static native_subhead_creator = ctRegex!(`^(?:author|translator|illustrator)$`, "m"); - static native_subhead_title = ctRegex!(`^(?:main|sub(?:title)?|full|language|edition|note)$`, "m"); - static native_subhead_rights = ctRegex!(`^(?:copyright|illustrations|license|cover)$`, "m"); - static native_subhead_date = ctRegex!(`^(?:published|created|issued|available|valid|modified|added_to_site)$`, "m"); - static native_subhead_original = ctRegex!(`^(?:title|language|source)$`, "m"); - static native_subhead_classify = ctRegex!(`^(?:topic_register|subject|keywords|loc|dewey)$`, "m"); - static native_subhead_identifier = ctRegex!(`^(?:oclc|pg|isbn)$`, "m"); - static native_subhead_notes = ctRegex!(`^(?:abstract|description)$`, "m"); - static native_subhead_publisher = ctRegex!(`^(?:name)$`, "m"); - static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_image|home_button_text|footer|headings|num_top|auto_num_depth|breaks|substitute|bold|italics|emphasis|texpdf_font|css)$`, "m"); - /+ heading & paragraph operators +/ - static heading_a = ctRegex!(`^:?[A][~] `, "m"); - static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); - static heading_seg_and_above = ctRegex!(`^:?([A-D1])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); - static heading_marker = ctRegex!(`^:?([A-D1-4])[~]`); - static heading_anchor_tag = ctRegex!(`^:?[A-D1-4][~]([a-z0-9_.-]+) `,"i"); - static heading_identify_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(?:(?:(?:chapter|article|section|clause)\s+[0-9.]+)|(?:[0-9]+))`,"i"); - static heading_extract_named_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(chapter|article|section|clause)\s+((?:[0-9]+[.:])*[0-9]+)(?:[.:;, ]|$)`,"i"); - static heading_extract_unnamed_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+((?:[0-9]+.)*[0-9]+)(?:[.:;, ]|$)`); - static heading_marker_missing_tag = ctRegex!(`^:?([A-D1-4])[~] `); - static heading_anchor_tag_plus_colon = ctRegex!(`^:?([A-D1-4][~])([a-z0-9_.:-]+) `,"i"); - static heading_marker_tag_has_colon = ctRegex!(`([:])`); - static heading_title = ctRegex!(`^:?[A-D1-4][~][a-z0-9_.-]*[?]?\s+(.+?)$`); - static heading_all = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+(.+?)$`); - static heading_backmatter = ctRegex!(`^:?1[~][!](glossary|bibliography|biblio|blurb)\s+`,"i"); - static heading_biblio = ctRegex!(`^:?(1)[~][!](biblio(?:graphy)?|references?)`); - static heading_glossary = ctRegex!(`^:?(1)[~][!](glossary)`); - static heading_blurb = ctRegex!(`^:?(1)[~][!](blurb)`); - static heading_biblio_glossary = ctRegex!(`^:?(?:(1)[~][!](?:(?:biblio(?:graphy)?|references?)|glossary)|[A-D1][~])`); - static heading_biblio_blurb = ctRegex!(`^:?(?:(1)[~][!](?:(?:biblio(?:graphy)?|references?)|blurb)|[A-D1][~])`); - static heading_blurb_glossary = ctRegex!(`^:?(?:(1)[~][!](?:blurb|glossary)|[A-D1][~])`); - static para_bullet = ctRegex!(`^_[*] `); - static para_bullet_indent = ctRegex!(`^_([1-9])[*] `); - static para_indent = ctRegex!(`^_([1-9]) `); - static para_indent_hang = ctRegex!(`^_([0-9])_([0-9]) `); - static para_attribs = ctRegex!(`^_(?:(?:[0-9])(?:_([0-9]))?|(?:[1-9])?[*]) `); - /+ blocked markup +/ - static block_open = ctRegex!("^((code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)[{].*?$)|^`{3} (code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)|^[{]table(~h)?(?P<columns>(?:[ ]+[0-9]+;)+)[}]"); - static block_poem_open = ctRegex!("^((poem[{].*?$)|`{3} poem)"); - /+ blocked markup tics +/ - static block_tic_open = ctRegex!("^`{3} (code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)"); // what of numbered code? - static block_tic_code_open = ctRegex!("^`{3} (?:code)(?:[.]([a-z][0-9a-z_]+))?(?:[ ]+([#]))?"); // extract additional info - static block_tic_poem_open = ctRegex!("^`{3} (poem)"); - static block_tic_group_open = ctRegex!("^`{3} (group)"); - static block_tic_block_open = ctRegex!("^`{3} (block)"); - static block_tic_quote_open = ctRegex!("^`{3} (quote)"); - static block_tic_table_open = ctRegex!("^`{3} table(.*)"); - static block_tic_close = ctRegex!("^(`{3})$","m"); - /+ blocked markup curly +/ - static block_curly_open = ctRegex!(`^((code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)[{].*?$)`); - static block_curly_code_open = ctRegex!(`^(?:code(?:[.]([a-z][0-9a-z_]+))?[{]([#]?)\s*$)`); // extract additional info - static block_curly_code_close = ctRegex!(`^([}]code)`); - static block_curly_poem_open = ctRegex!(`^(poem[{].*?$)`); - static block_curly_poem_close = ctRegex!(`^([}]poem)`); - static block_curly_group_open = ctRegex!(`^(group[{].*?$)`); - static block_curly_group_close = ctRegex!(`^([}]group)`); - static block_curly_block_open = ctRegex!(`^(block[{].*?$)`); - static block_curly_block_close = ctRegex!(`^([}]block)`); - static block_curly_quote_open = ctRegex!(`^(quote[{].*?$)`); - static block_curly_quote_close = ctRegex!(`^([}]quote)`); - static block_curly_table_open = ctRegex!(`^table[{](.*)`); - static block_curly_table_close = ctRegex!(`^([}]table)`); - static block_curly_table_special_markup = ctRegex!(`^[{]table((~h)?(?P<columns>(?:[ ]+[0-9]+;)+))[}]`, "mg"); - static table_head_instructions = ctRegex!(`(?P<c_heading>h)?(?:[ ]+c(?P<c_num>[0-9]);)?(?P<c_widths>(?:[ ]+[0-9]+[lr]?;)+)`); - static table_col_widths_and_alignment = ctRegex!(`(?P<width>[0-9]+)(?P<align>[lr]?)`); - static table_col_widths = ctRegex!(`(?P<widths>[0-9]+)`); - static table_col_align = ctRegex!(`(?P<align>[lr]?)`); - static table_col_align_match = ctRegex!(`(?P<align>[lr])`); - static table_col_separator = ctRegex!(`┊`); - static table_col_separator_nl = ctRegex!(`[┊]$`, "mg"); - /+ inline markup footnotes endnotes +/ - static inline_notes_curly_gen = ctRegex!(`~\{.+?\}~`, "m"); - static inline_notes_curly = ctRegex!(`~\{\s*(.+?)\}~`, "mg"); - static inline_curly_delimiter_open_and_close_regular = ctRegex!(`~\{\s*|\s*\}~`, "m"); - static inline_notes_delimiter_curly_regular = ctRegex!(`~\{[ ]*(.+?)\}~`, "m"); - static inline_notes_curly_sp = ctRegex!(`~\{[*+]+\s+(.+?)\}~`, "m"); - static inline_notes_curly_sp_asterisk = ctRegex!(`~\{[*]+\s+(.+?)\}~`, "m"); - static inline_notes_curly_sp_plus = ctRegex!(`~\{[+]+\s+(.+?)\}~`, "m"); - static inline_note_curly_delimiters = ctRegex!(`(~\{[*+]?\s*)(.+?)(\}~)`, "mg"); - static inline_notes_square = ctRegex!(`~\[\s*(.+?)\]~`, "mg"); - static inline_text_and_note_square_sp = ctRegex!(`(.+?)~\[[*+]+\s+(.+?)\]~`, "mg"); - static inline_text_and_note_square = ctRegex!(`(.+?)~\[\s*(.+?)\]~`, "mg"); - static inline_note_square_delimiters = ctRegex!(`(~\[\s*)(.+?)(\]~)`, "mg"); - static inline_curly_delimiter_open_regular = ctRegex!(`~\{\s*`, "m"); - static inline_curly_delimiter_open_symbol_star = ctRegex!(`~\{[*]\s`, "m"); - static inline_curly_delimiter_open_symbol_plus = ctRegex!(`~\{[+]\s`, "m"); - static inline_curly_delimiter_open_star_or_plus = ctRegex!(`~\{[+*]`, "m"); - static inline_curly_delimiter_close_regular = ctRegex!(`\s*\}~`, "m"); - static inline_text_and_note_curly = ctRegex!(`(?P<text>.+?)(?:(?:[~])[{][*+ ]*)(?P<note>.+?)(?:[}][~])`, "mg"); - static note_ref = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg"); // {^{73.}^}#noteref_73 - static smid_inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); - static smid_inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); - static smid_inline_link_naked_url = ctRegex!(`(?P<pre>^|[ ])(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?P<post>[.,;:?!'"]?(?:[ ]|$))`, "mg"); // issue with #link #32 - static smid_inline_link_markup_regular = ctRegex!(`(?P<pre>^|[ ]|[^\S]?)\{\s*(?P<content>.+?)\s*\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P<post>[;:!,?.]?(?:[ )\]]|$))`, "mg"); // NEXT - static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P<after>[.,;:?!]?(?:[ ]|$))`, "mg"); - static smid_inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P<content>.+?)\}(?P<link>(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); - static image = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg"); - static smid_image_generic = ctRegex!(`(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*)\S+\.(?:png|gif|jpg).+?\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)[;:!,?.]?(?:[ )\]]|$)`, "mg"); - static smid_image_with_dimensions = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s+(?P<width>\d+)x(?P<height>\d+)\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?:[;:!,?.]?(?:[ )\]]|$)))`, "mg"); - static smid_image = ctRegex!(`(?P<pre>(?:^|[ ]|[^\S]?)\{(?:~\^\s+|\s*))(?P<image>\S+\.(?:png|gif|jpg))\s*(?P<post>(?:.+?)\s*\}(?:image|(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?:[;:!,?.]?(?:[ )\]]|$)))`, "mg"); - static smid_mod_image_without_dimensions = ctRegex!(`\{(?:~\^\s+|\s*)☼\S+\.(?:png|gif|jpg),w0h0\s+(?:.+?)\s*\}(?:image|(?:https?|git):\/\/\S+?)(?:[;:!,?.]?(?:[ )\]]|$))`, "mg"); - /+ inline markup book index +/ - static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m"); - static book_index_open = ctRegex!(`^=\{\s*([^}]+?)$`); - static book_index_close = ctRegex!(`^(.*?)\}$`, "m"); - /+ no object_number object +/ - static object_number_off = ctRegex!(`~#$`, "m"); - static object_number_off_dh = ctRegex!(`-#$`, "m"); - static object_number_off_all = ctRegex!(`[~-]#$`, "m"); - /+ no object_number block +/ - static object_number_off_block = ctRegex!(`^--~#$`); - static object_number_off_block_dh = ctRegex!(`^---#$`); - static object_number_off_block_close = ctRegex!(`^--\+#$`); - static object_number_block_marks = ctRegex!(`^--[+~-]#$`); - /+ ignore outside code blocks +/ - static skip_from_regular_parse = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); - /+ line & page breaks +/ - static break_line_within_object = ctRegex!(`[\\]{2}( |$)`); - static break_page = ctRegex!(`^-[\\]{2}-$`); - static break_page_new = ctRegex!(`^=[\\]{2}=$`); - static break_page_line_across = ctRegex!(`^=[.]{2}=$`); - static break_string = ctRegex!(`』`); - static parent = ctRegex!(`([0-7]):([0-9]+)`); - static header_regex_content = ctRegex!(`([0-7]):([0-9]+)`); - /+ json +/ - static tailing_comma = ctRegex!(`,$`, "m"); - /+ biblio tags +/ - static biblio_tags = ctRegex!(`^(is|au|author_raw|author|author_arr|editor_raw|ed|editor_arr|ti|title|subtitle|fulltitle|lng|language|trans|src|jo|journal|in|vol|volume|edn|edition|yr|year|pl|place|pb|pub|publisher|url|pg|pages|note|short_name|id):\s+(.+)`); - static biblio_abbreviations = ctRegex!(`^(au|ed|ti|lng|jo|vol|edn|yr|pl|pb|pub|pg|pgs|sn)$`); - /+ bookindex split +/ - static bi_main_terms_split = ctRegex!(`\s*;\s*`); - static bi_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); - static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); - static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); - /+ language codes +/ - auto language_codes = - ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)"); - auto language_code_and_filename = - ctRegex!("(?:^|[/])(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$"); - static newline = ctRegex!("\n", "mg"); - static strip_br = ctRegex!("^<br>\n|<br>\n*$"); - static space = ctRegex!(`[ ]`, "mg"); - static spaces_line_start = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg"); - static spaces_multiple = ctRegex!(`(?P<multiple_spaces>[ ]{2,})`, "mg"); - static two_spaces = ctRegex!(`[ ]{2}`, "mg"); - static nbsp_char = ctRegex!(`░`, "mg"); - static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); - static nbsp_and_space = ctRegex!(` [ ]`, "mg"); - static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); - static special_markup_chars = ctRegex!(`[【】〖〗┥┝┤├¤░┘┙┚┼┿╂┊┏┚┆■]`, "mg"); - static src_pth_sst_or_ssm = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`); - static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); - static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisupod[.]manifest$`); - static src_pth_pod_root = ctRegex!(`^(?P<podroot>(?:[/]?(?:[a-zA-Z0-9._-]+/)*)(sisupod))$`); - static src_pth_zip = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); - static src_pth_unzip_pod = ctRegex!(`^(?P<path>media/text/[a-z]{2}/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); - static src_pth_types = - ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/sisupod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); - static pod_content_location = - ctRegex!(`^(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])(?P<languages>(?:\s+[a-z]{2}(?:,|$))+)`, "mg"); - static src_fn = - ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); - static src_fn_master = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); - static src_fn_text = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]sst)$`); - static src_fn_insert = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssi)$`); - static src_fn_find_inserts = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); - static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); - static src_base_parent_dir_name = ctRegex!(`[/](?P<dir>(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure - static src_base_parent_path = ctRegex!(`(?P<dir>(?:[/a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure - static src_formalised_file_path_parts = ctRegex!(`(?P<pth>(?:[/a-zA-Z0-9._-]+?)(?P<dir>[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure - /+ line breaks +/ - static br_line = ctRegex!(`┘`, "mg"); - static br_nl = ctRegex!(`┙`, "mg"); - static br_paragraph = ctRegex!(`┚`, "mg"); - static br_page_line = ctRegex!(`┼`, "mg"); - static br_page = ctRegex!(`┿`, "mg"); - static br_page_new = ctRegex!(`╂`, "mg"); - /+ inline markup footnotes endnotes +/ - static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); - static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented - static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); - static inline_notes_al_gen_text = ctRegex!(`【(?P<text>.+?)】`, "m"); - static inline_notes_al_gen_ref = ctRegex!(`【(?P<ref>[*+]\s+)\s*(?P<text>.+?)】`, "mg"); - static inline_al_delimiter_open_regular = ctRegex!(`【\s`, "m"); - static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); - static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); - static inline_al_delimiter_close_regular = ctRegex!(`】`, "m"); - static inline_al_delimiter_open_and_close_regular = ctRegex!(`【|】`, "m"); - static inline_notes_delimiter_al_regular = ctRegex!(`【(.+?)】`, "mg"); - static inline_notes_delimiter_al_regular_number_note = ctRegex!(`【(\d+)\s+(.+?)】`, "mg"); - static inline_al_delimiter_open_asterisk = ctRegex!(`【\*`, "m"); - static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); - static inline_text_and_note_al = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg"); - static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); - /+ inline markup footnotes endnotes +/ - static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg"); - static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); - static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); - static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); - static url = ctRegex!(`https?://`, "mg"); - static inline_link_subtoc = ctRegex!(`^(?P<level>[5-7])~ ┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg"); - static fn_suffix = ctRegex!(`\.fnSuffix`, "mg"); - static inline_link_fn_suffix = ctRegex!(`¤(.+?)(\.fnSuffix)`, "mg"); - static inline_seg_link = ctRegex!(`(¤)(?:.+?)\.fnSuffix`, "mg"); - static mark_internal_site_lnk = ctRegex!(`¤`, "mg"); - static quotation_mark_sql_insert_delimiter = ctRegex!("[']", "mg"); - static quotation_mark_various = ctRegex!(q"¶['‘’“”"`´¨]¶", "mg"); - /+ inline markup font face mod +/ - static inline_faces = ctRegex!(`(?P<markup>(?P<mod>[*!_^,+#-])\{(?P<text>.+?)\}[*!_^,+#-])`, "mg"); - static inline_emphasis = ctRegex!(`\*\{(?P<text>.+?)\}\*`, "mg"); - static inline_bold = ctRegex!(`!\{(?P<text>.+?)\}!`, "mg"); - static inline_underscore = ctRegex!(`_\{(?P<text>.+?)\}_`, "mg"); - static inline_italics = ctRegex!(`/\{(?P<text>.+?)\}/`, "mg"); - static inline_superscript = ctRegex!(`\^\{(?P<text>.+?)\}\^`, "mg"); - static inline_subscript = ctRegex!(`,\{(?P<text>.+?)\},`, "mg"); - static inline_strike = ctRegex!(`-\{(?P<text>.+?)\}-`, "mg"); - static inline_insert = ctRegex!(`\+\{(?P<text>.+?)\}\+`, "mg"); - static inline_mono = ctRegex!(`#\{(?P<text>.+?)\}#`, "mg"); - static inline_mono_box = ctRegex!(`■\{(?P<text>.+?)\}■`, "mg"); - static inline_cite = ctRegex!(`"\{(?P<text>.+?)\}"`, "mg"); - static inline_faces_line = ctRegex!(`^[*!/_]_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); - static inline_emphasis_line = ctRegex!(`^\*_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); - static inline_bold_line = ctRegex!(`^!_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); - static inline_italics_line = ctRegex!(`^/_ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); - static inline_underscore_line = ctRegex!(`^__ (?P<text>.+?)((?: [\\]{2}|[~]#){0,2}$)`); - static inline_fontface_clean = ctRegex!(`[*!_/^,+#■"-]\{|\}[*!_/^,+#■"-]`, "mg"); - static no_header_rgx = ctRegex!(`^=NULL$`); - /+ table delimiters +/ - static table_delimiter_col = ctRegex!("[ ]*[┊][ ]*", "mg"); - static table_delimiter_row = ctRegex!("[ ]*\n", "mg"); - } -} |