diff options
Diffstat (limited to 'org')
-rw-r--r-- | org/meta_abstraction.org | 63 | ||||
-rw-r--r-- | org/meta_conf_make_meta.org | 281 |
2 files changed, 155 insertions, 189 deletions
diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 03da5cf..959de0c 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -538,6 +538,7 @@ int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; #+name: make_tests #+BEGIN_SRC d +enum Substitute { match, markup, } debug (substitutions) { writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); if (!(conf_make_meta.make.headings.empty)) { @@ -545,21 +546,21 @@ debug (substitutions) { } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { - writeln("regex to match: ", substitution_pair[0]); - writeln("substitution to make: ", substitution_pair[1]); + writeln("regex to match: ", substitution_pair[Substitute.match]); + writeln("substitution to make: ", substitution_pair[Substitute.markup]); } } - if (!(conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.bold_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.bold_substitute_html); + 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_rgxmatch == "=NULL" || conf_make_meta.make.emphasis_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.emphasis_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.emphasis_substitute_html); + 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_rgxmatch == "=NULL" || conf_make_meta.make.italics_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.italics_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.italics_substitute_html); + 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]); } } #+END_SRC @@ -857,6 +858,7 @@ if there is a blurb section you need to: #+BEGIN_SRC d } 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; @@ -869,6 +871,7 @@ if there is a blurb section you need to: /+ 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"); @@ -882,6 +885,7 @@ if there is a blurb section you need to: #+BEGIN_SRC d } 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) @@ -938,7 +942,6 @@ if (line.matchFirst(rgx.block_poem_open)) { processing.remove("verse"); obj_cite_number_poem["start"] = obj_cite_digits.on.to!string; } -line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); _start_block_(line, obj_type_status, obj_cite_number_poem); continue; #+END_SRC @@ -1044,10 +1047,12 @@ if (line.matchFirst(rgx.book_index) +/ 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); } @@ -1075,6 +1080,7 @@ if (line.matchFirst(rgx.book_index) 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"]; @@ -2574,11 +2580,12 @@ auto _doc_header_and_make_substitutions_(L,CMM)( 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(substitution_pair[0]), - substitution_pair[1] + regex(substitution_pair[Substitute.match]), + substitution_pair[Substitute.markup] ); } } @@ -2597,31 +2604,23 @@ auto _doc_header_and_make_substitutions_fontface_(L,CMM)( debug(asserts) { static assert(is(typeof(line) == char[])); } - if (!( - conf_make_meta.make.bold_rgxmatch == "=NULL" - || conf_make_meta.make.bold_rgxmatch.empty - )) { + enum Substitute { match, markup, } + if ( conf_make_meta.make.bold) { line = line.replaceAll( - regex(conf_make_meta.make.bold_rgxmatch), - conf_make_meta.make.bold_substitute_sisu_markup + regex(conf_make_meta.make.bold[Substitute.match]), + conf_make_meta.make.bold[Substitute.markup] ); } - if (!( - conf_make_meta.make.emphasis_rgxmatch == "=NULL" - || conf_make_meta.make.emphasis_rgxmatch.empty - )) { + if (conf_make_meta.make.emphasis) { line = line.replaceAll( - regex(conf_make_meta.make.emphasis_rgxmatch), - conf_make_meta.make.emphasis_substitute_sisu_markup + regex(conf_make_meta.make.emphasis[Substitute.match]), + conf_make_meta.make.emphasis[Substitute.markup] ); } - if (!( - conf_make_meta.make.italics_rgxmatch == "=NULL" - || conf_make_meta.make.italics_rgxmatch.empty - )) { + if (conf_make_meta.make.italics) { line = line.replaceAll( - regex(conf_make_meta.make.italics_rgxmatch), - conf_make_meta.make.italics_substitute_sisu_markup + regex(conf_make_meta.make.italics[Substitute.match]), + conf_make_meta.make.italics[Substitute.markup] ); } return line; diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index c6c4b2c..fff5275 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -64,36 +64,28 @@ import #+name: meta_defaults_template_structs #+BEGIN_SRC d struct ConfCompositeMakeStr { - string bold = ""; - string breaks = ""; - string cover_image = ""; - string css = ""; - string emphasis = ""; - string footer = ""; + string bold; + string breaks; + string cover_image; + string css; + string emphasis; + string footer; string[] headings; - string home_button_image = ""; - string home_button_text = ""; - string italics = ""; - string num_top = ""; - string num_depth = ""; + string home_button_image; + string home_button_text; + string italics; + string num_top; + string num_depth; string[][] substitute; - string texpdf_font = ""; + string texpdf_font; } struct confCompositeMakeBuild { - auto bold_rgxmatch(string _mk) { - auto _rgxtxt = (_mk.empty) - ? `=NULL` - : `(` ~ _mk.dup ~ `)`; - return (cast(char[]) (_rgxtxt)); - } - auto bold_substitute_abstract() { - return "*{$1}*"; - } - auto bold_substitute_sisu_markup() { - return "*{$1}*"; - } - auto bold_substitute_html() { - return "<b>$1</b>"; + 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; @@ -104,20 +96,12 @@ struct confCompositeMakeBuild { auto css(string _mk) { return _mk; } - auto emphasis_rgxmatch(string _mk) { - auto _rgxtxt = (_mk.empty) - ? `=NULL` - : `(` ~ _mk.dup ~ `)`; - return (cast(char[]) (_rgxtxt)); - } - auto emphasis_substitute_abstract() { - return "!{$1}!"; - } - auto emphasis_substitute_sisu_markup() { - return "!{$1}!"; - } - auto emphasis_substitute_html() { - return "<em>$1</em>"; + auto emphasis(string _mk) { + string[] _out; + if (_mk) { + _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "!{$1}!", "<em>$1</em>" ]; + } + return _out; } auto footer(string _mk) { return _mk; @@ -131,20 +115,12 @@ struct confCompositeMakeBuild { auto home_button_text(string _mk) { return _mk; } - auto italics_rgxmatch(string _mk) { - auto _rgxtxt = (_mk.empty) - ? `=NULL` - : `(` ~ _mk.dup ~ `)`; - return (cast(char[]) (_rgxtxt)); - } - auto italics_substitute_abstract() { - return "/{$1}/"; - } - auto italics_substitute_sisu_markup() { - return "/{$1}/"; - } - auto italics_substitute_html() { - return "<i>$1</i>"; + auto italics(string _mk) { + string[] _out; + if (_mk) { + _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "/{$1}/", "<i>$1</i>" ]; + } + return _out; } auto num_top(string _mk) { return _mk; @@ -167,29 +143,20 @@ struct confCompositeMakeBuild { #+name: meta_defaults_template_structs #+BEGIN_SRC d struct ConfCompositeMakeInit { - char[] bold_rgxmatch = `=NULL`.dup; - auto bold_substitute_abstract = "*{$1}*"; - auto bold_substitute_sisu_markup = "*{$1}*"; - auto bold_substitute_html = "<b>$1</b>"; - string breaks = ""; - string cover_image = ""; - string css = ""; - char[] emphasis_rgxmatch = `=NULL`.dup; - auto emphasis_substitute_abstract = "!{$1}!"; - auto emphasis_substitute_sisu_markup = "!{$1}!"; - auto emphasis_substitute_html = "<em>$1</em>"; - string footer = ""; + string[] bold; + string breaks; + string cover_image; + string css; + string[] emphasis; + string footer; string[] headings; - string home_button_image = ""; - string home_button_text = ""; - char[] italics_rgxmatch = `=NULL`.dup; - auto italics_substitute_abstract = "/{$1}/"; - auto italics_substitute_sisu_markup = "/{$1}/"; - auto italics_substitute_html = "<i>$1</i>"; - string num_top = ""; - string num_depth = ""; + string home_button_image; + string home_button_text; + string[] italics; + string num_top; + string num_depth; string[][] substitute; - string texpdf_font = ""; + string texpdf_font; } #+END_SRC @@ -198,38 +165,38 @@ struct ConfCompositeMakeInit { #+name: meta_defaults_template_structs #+BEGIN_SRC d 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 = ""; + 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; } #+END_SRC @@ -238,53 +205,53 @@ struct ConfCompositeSiteLocal { #+name: meta_defaults_template_structs #+BEGIN_SRC d 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 = ""; + 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; } #+END_SRC @@ -557,16 +524,16 @@ if ("make" in _json.object) { ) { _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; } - _struct_composite.make.bold_rgxmatch = _mk.bold_rgxmatch(_struct_composite.make_str.bold); + _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_rgxmatch = _mk.emphasis_rgxmatch(_struct_composite.make_str.emphasis); + _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_rgxmatch = _mk.italics_rgxmatch(_struct_composite.make_str.italics); + _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); _struct_composite.make.num_top = _mk.num_top(_struct_composite.make_str.num_top); _struct_composite.make.num_depth = _mk.num_depth(_struct_composite.make_str.num_depth); _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); |