From 4ff01a81f048c0b496cc03627324b69b7aebd368 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 7 Sep 2017 16:54:23 -0400 Subject: 0.19.0 conf make meta, composite struct, instead of associative array * remove conf make meta associative arrays, including native doc header (which revisit) --- org/meta_conf_make_meta.org | 729 +++++++++++--------------------------------- 1 file changed, 183 insertions(+), 546 deletions(-) (limited to 'org/meta_conf_make_meta.org') diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 2f06970..67207d4 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -15,7 +15,7 @@ #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) [[./sdp.org][sdp]] [[./][org/]] -* 0. header extract (native & sdlang) to AA :module:sdp:meta_conf_make_meta: +* 0. header extract (native & sdlang) to Struct :module:sdp:meta_conf_make_meta: ** module template #+BEGIN_SRC d :tangle ../src/sdp/meta/conf_make_meta.d @@ -30,7 +30,7 @@ program internally. Moved to associative array. +/ module sdp.meta.conf_make_meta; -template docHeaderMakeAndMetaTupExtractAndConvertToAA() { +static template docHeaderMakeAndMetaTupExtractAndConvertToStruct() { import std.exception, std.regex, @@ -41,31 +41,20 @@ template docHeaderMakeAndMetaTupExtractAndConvertToAA() { std.conv : to; import sdlang; import - sdp.meta.conf_make_meta_native, sdp.meta.conf_make_meta_sdlang, sdp.meta.rgx; mixin SiSUrgxInit; - mixin SiSUheaderExtractNative; mixin SiSUextractSDLang; static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupExtractAndConvertToAA(DocMake, Src)( - DocMake conf_doc_make_aa, + auto docHeaderMakeAndMetaTupExtractAndConvertToStruct(CCm, Src)( + CCm conf_composite_make, Src header_src, ) { - debug(asserts){ - static assert(is(typeof(header_src) == char[])); - static assert(is(typeof(conf_doc_make_aa) == string[string][string])); - } - auto head_native = HeaderDocMetadataAndMakeNativeToAA(); auto header_sdlang_tag = (!(header_src.match(rgx.native_header_meta_title))) ? extractSDL().docHeaderSDLtagGet(header_src) // sdlang.ast.Tag : null; - auto header_make_and_meta_tuple = (header_src.match(rgx.native_header_meta_title)) - ? (head_native.headerNativeToAA(header_src)) - : (extractSDL().docHeaderSDLtoAA(conf_doc_make_aa, header_sdlang_tag)); - static assert(!isTypeTuple!(header_make_and_meta_tuple)); - static assert(header_make_and_meta_tuple.length==2); - return header_make_and_meta_tuple; + auto header_make_and_meta_struct = extractSDL().docSDLtoStruct(conf_composite_make, header_sdlang_tag); + return header_make_and_meta_struct; } } #+END_SRC @@ -79,7 +68,7 @@ template docHeaderMakeAndMetaTupExtractAndConvertToAA() { extract sdlang header return sdlang +/ module sdp.meta.conf_make_meta_sdlang; -template SiSUextractSDLang() { +static template SiSUextractSDLang() { import std.exception, std.regex, @@ -156,110 +145,179 @@ private auto docHeaderSDLtagGet(Hs)(Hs src_header) { } #+END_SRC -** 2a. _sdlang to associative array_ +** 2a. _sdlang to struct_ #+name: meta_conf_make_meta_sdl #+BEGIN_SRC d -private auto sdlangToAA(C,Tag)(C conf, Tag conf_sdlang) { - debug(asserts){ - static assert(is(typeof(conf) == string[string][string])); +private auto docSDLtoStruct(C,Tag)(C _conf_composite, Tag header_sdlang) { + mixin SiSUregisters; + /+ make +/ + if ("make" in header_sdlang.maybe.tags) { + _conf_composite.make_str.bold = _conf_composite.make.bold = extractSDLangTabOrAttrib(header_sdlang, "make", "bold"); + _conf_composite.make_str.breaks = _conf_composite.make.breaks = extractSDLangTabOrAttrib(header_sdlang, "make", "breaks"); + _conf_composite.make_str.cover_image = _conf_composite.make.cover_image = extractSDLangTabOrAttrib(header_sdlang, "make", "cover_image"); + _conf_composite.make_str.css = _conf_composite.make.css = extractSDLangTabOrAttrib(header_sdlang, "make", "css"); + _conf_composite.make_str.emphasis = _conf_composite.make.emphasis = extractSDLangTabOrAttrib(header_sdlang, "make", "emphasis"); + _conf_composite.make_str.footer = _conf_composite.make.footer = extractSDLangTabOrAttrib(header_sdlang, "make", "footer"); + _conf_composite.make_str.headings = _conf_composite.make.headings = extractSDLangTabOrAttrib(header_sdlang, "make", "headings"); + _conf_composite.make_str.home_button_image = _conf_composite.make.home_button_image = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_image"); + _conf_composite.make_str.home_button_text = _conf_composite.make.home_button_text = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_text"); + _conf_composite.make_str.italics = _conf_composite.make.italics = extractSDLangTabOrAttrib(header_sdlang, "make", "italics"); + _conf_composite.make_str.num_top = _conf_composite.make.num_top = extractSDLangTabOrAttrib(header_sdlang, "make", "num_top"); + _conf_composite.make_str.num_depth = _conf_composite.make.num_depth = extractSDLangTabOrAttrib(header_sdlang, "make", "num_depth"); + _conf_composite.make_str.substitute = _conf_composite.make.substitute = extractSDLangTabOrAttrib(header_sdlang, "make", "substitute"); + _conf_composite.make_str.texpdf_font = _conf_composite.make.texpdf_font = extractSDLangTabOrAttrib(header_sdlang, "make", "texpdf_font"); } - foreach (maintag, subtags; conf) { - /+ writeln(__LINE__, ": ", maintag, ":- ", subtags); +/ - foreach (subtag, content; subtags) { - if (maintag in conf_sdlang.maybe.tags) { - Tag _maintag = conf_sdlang.getTag(maintag); - if ((subtag in _maintag.maybe.tags) - && (_maintag.getTagValues(subtag).length > 0)) { - debug(headersdlang) { - writeln(__LINE__, ": ", maintag, ":", subtag, ": ", _maintag.getTagValues(subtag)[0]); - } - if (_maintag.getTagValues(subtag).length == 1) { - conf[maintag][subtag] = - (_maintag.getTagValues(subtag)[0]).to!string; - } else if (_maintag.getTagValues(subtag).length > 1) { - foreach (st; _maintag.getTagValues(subtag)) { - conf[maintag][subtag] ~= - st.to!string ~ ";"; - } - } - } else if ((subtag in _maintag.maybe.attributes) - && (_maintag.maybe.attributes[subtag][0].value.length > 0)) { - debug(headersdlang) { - writeln(__LINE__, ": ", maintag, ":", subtag, ": ", conf_sdlang.tags[maintag][0].attributes[subtag][0].value); - } - conf[maintag][subtag] = - (conf_sdlang.tags[maintag][0].attributes[subtag][0].value).to!string; - } - } - } + /+ conf +/ + if ("webserv" in header_sdlang.maybe.tags) { + _conf_composite.conf.webserv_url_root = extractSDLangTabOrAttrib(header_sdlang, "webserv", "url_root"); + _conf_composite.conf.webserv_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "path"); + _conf_composite.conf.webserv_images = extractSDLangTabOrAttrib(header_sdlang, "webserv", "images"); + _conf_composite.conf.webserv_cgi = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi"); + _conf_composite.conf.webserv_cgi_host = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host"); + _conf_composite.conf.webserv_cgi_host_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host_path"); + _conf_composite.conf.webserv_cgi_port = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_port"); + _conf_composite.conf.webserv_cgi_user = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_user"); + _conf_composite.conf.webserv_cgi_file_links = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_file_links"); } - return conf; -} -#+END_SRC - -** 2b. sdlang header to _associative array_ make sdlTag in :sdlang:aa: - -#+name: meta_conf_make_meta_sdl -#+BEGIN_SRC d -private auto docHeaderSDLtoAA(Ma, Tag)(Ma dochead_make, Tag header_sdlang) { - debug(asserts){ - static assert(is(typeof(dochead_make) == string[string][string])); + if ("processing" in header_sdlang.maybe.tags) { + _conf_composite.conf.processing_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_path"); + _conf_composite.conf.processing_dir = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_dir"); + _conf_composite.conf.processing_concord_max = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_concord_max"); + } + if("flag" in header_sdlang.maybe.tags) { + _conf_composite.conf.flag_act0 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act0"); + _conf_composite.conf.flag_act1 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act1"); + _conf_composite.conf.flag_act2 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act2"); + _conf_composite.conf.flag_act3 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act3"); + _conf_composite.conf.flag_act4 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act4"); + _conf_composite.conf.flag_act5 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act5"); + _conf_composite.conf.flag_act6 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act6"); + _conf_composite.conf.flag_act7 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act7"); + _conf_composite.conf.flag_act8 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act8"); + _conf_composite.conf.flag_act9 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act9"); + } + if ("default" in header_sdlang.maybe.tags) { + _conf_composite.conf.default_papersize = extractSDLangTabOrAttrib(header_sdlang, "default", "papersize"); + _conf_composite.conf.default_text_wrap = extractSDLangTabOrAttrib(header_sdlang, "default", "text_wrap"); + _conf_composite.conf.default_emphasis = extractSDLangTabOrAttrib(header_sdlang, "default", "emphasis"); + _conf_composite.conf.default_language = extractSDLangTabOrAttrib(header_sdlang, "default", "language"); + _conf_composite.conf.default_digest = extractSDLangTabOrAttrib(header_sdlang, "default", "digest"); + } + if ("search" in header_sdlang.maybe.tags) { + _conf_composite.conf.search_flag = extractSDLangTabOrAttrib(header_sdlang, "search", "flag"); + _conf_composite.conf.search_action = extractSDLangTabOrAttrib(header_sdlang, "search", "action"); + _conf_composite.conf.search_db = extractSDLangTabOrAttrib(header_sdlang, "search", "db"); + _conf_composite.conf.search_title = extractSDLangTabOrAttrib(header_sdlang, "search", "title"); } - dochead_make = sdlangToAA(dochead_make, header_sdlang); - auto dochead_meta = sdlangToAA(meta_aa_empty, header_sdlang); - if (dochead_meta["title"]["main"].empty) { - { + /+ meta +/ + if ("classify" in header_sdlang.maybe.tags) { + _conf_composite.meta.classify_dewey = extractSDLangTabOrAttrib(header_sdlang, "classify", "dewey"); + _conf_composite.meta.classify_keywords = extractSDLangTabOrAttrib(header_sdlang, "classify", "keywords"); + _conf_composite.meta.classify_loc = extractSDLangTabOrAttrib(header_sdlang, "classify", "loc"); + _conf_composite.meta.classify_subject = extractSDLangTabOrAttrib(header_sdlang, "classify", "subject"); + _conf_composite.meta.classify_topic_register = extractSDLangTabOrAttrib(header_sdlang, "classify", "topic_register"); + } + if ("date" in header_sdlang.maybe.tags) { + _conf_composite.meta.date_added_to_site = extractSDLangTabOrAttrib(header_sdlang, "date", "added_to_site"); + _conf_composite.meta.date_available = extractSDLangTabOrAttrib(header_sdlang, "date", "available"); + _conf_composite.meta.date_created = extractSDLangTabOrAttrib(header_sdlang, "date", "created"); + _conf_composite.meta.date_issued = extractSDLangTabOrAttrib(header_sdlang, "date", "issued"); + _conf_composite.meta.date_modified = extractSDLangTabOrAttrib(header_sdlang, "date", "modified"); + _conf_composite.meta.date_published = extractSDLangTabOrAttrib(header_sdlang, "date", "published"); + _conf_composite.meta.date_valid = extractSDLangTabOrAttrib(header_sdlang, "date", "valid"); + } + if("identifier" in header_sdlang.maybe.tags) { + _conf_composite.meta.identifier_isbn = extractSDLangTabOrAttrib(header_sdlang, "identifier", "isbn"); + _conf_composite.meta.identifier_oclc = extractSDLangTabOrAttrib(header_sdlang, "identifier", "oclc"); + _conf_composite.meta.identifier_pg = extractSDLangTabOrAttrib(header_sdlang, "identifier", "pg"); + } + if ("links" in header_sdlang.maybe.tags) { + // _conf_composite.meta.links = extractSDLangTabOrAttrib(header_sdlang, "links", ""); + } + if ("notes" in header_sdlang.maybe.tags) { + _conf_composite.meta.notes_abstract = extractSDLangTabOrAttrib(header_sdlang, "notes", "abstract"); + _conf_composite.meta.notes_description = extractSDLangTabOrAttrib(header_sdlang, "notes", "description"); + } + if ("original" in header_sdlang.maybe.tags) { + _conf_composite.meta.original_language = extractSDLangTabOrAttrib(header_sdlang, "original", "language"); + _conf_composite.meta.original_source = extractSDLangTabOrAttrib(header_sdlang, "original", "source"); + _conf_composite.meta.original_title = extractSDLangTabOrAttrib(header_sdlang, "original", "title"); + } + if ("publisher" in header_sdlang.maybe.tags) { + // _conf_composite.meta.publisher = extractSDLangTabOrAttrib(header_sdlang, "publisher", ""); + } + if ("rights" in header_sdlang.maybe.tags) { + _conf_composite.meta.rights_copyright = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright"); + _conf_composite.meta.rights_cover = extractSDLangTabOrAttrib(header_sdlang, "rights", "cover"); + _conf_composite.meta.rights_illustrations = extractSDLangTabOrAttrib(header_sdlang, "rights", "illustrations"); + _conf_composite.meta.rights_license = extractSDLangTabOrAttrib(header_sdlang, "rights", "license"); + } + if (_conf_composite.meta.creator_author.empty) { + if ("creator" in header_sdlang.maybe.tags) { + _conf_composite.meta.creator_author = extractSDLangTabOrAttrib(header_sdlang, "creator", "author"); + _conf_composite.meta.creator_author_email = extractSDLangTabOrAttrib(header_sdlang, "creator", "author_email"); + _conf_composite.meta.creator_illustrator = extractSDLangTabOrAttrib(header_sdlang, "creator", "illustrator"); + _conf_composite.meta.creator_translator = extractSDLangTabOrAttrib(header_sdlang, "creator", "translator"); + } + // dochead_meta["creator"]["author_raw"] = dochead_meta["creator"]["author"]; + string[] authors_arr; + auto authors_raw_arr = _conf_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"); + } + _conf_composite.meta.creator_author = join(authors_arr, ", ").chomp.chomp; + } + if (_conf_composite.meta.title_main.empty) { + if ("title" in header_sdlang.maybe.tags) { + _conf_composite.meta.title_edition = extractSDLangTabOrAttrib(header_sdlang, "title", "edition"); + _conf_composite.meta.title_language = extractSDLangTabOrAttrib(header_sdlang, "title", "language"); + _conf_composite.meta.title_main = extractSDLangTabOrAttrib(header_sdlang, "title", "main"); + _conf_composite.meta.title_note = extractSDLangTabOrAttrib(header_sdlang, "title", "note"); + _conf_composite.meta.title_sub = extractSDLangTabOrAttrib(header_sdlang, "title", "sub"); + _conf_composite.meta.title_subtitle = extractSDLangTabOrAttrib(header_sdlang, "title", "subtitle"); + } + if (_conf_composite.meta.title_main.empty) { Tag _maintag = header_sdlang.getTag("title"); if (_maintag !is null) { if ("main" in _maintag.maybe.tags) { - dochead_meta["title"]["main"] = + _conf_composite.meta.title_main = to!string(_maintag.getTagValues("main")); } else if ("main" !in _maintag.maybe.attributes) { writeln(__LINE__, ": ", _maintag.values[0]); - dochead_meta["title"]["main"] = + _conf_composite.meta.title_main = (_maintag.values[0]).to!string; // test that this exists } } } + if ((!(_conf_composite.meta.title_subtitle.empty)) + && (_conf_composite.meta.title_sub.empty)) { + _conf_composite.meta.title_sub = _conf_composite.meta.title_subtitle; + } + if (_conf_composite.meta.title_sub.empty) { + _conf_composite.meta.title_full = _conf_composite.meta.title_main; + } else { + _conf_composite.meta.title_full = format( + "%s - %s", + _conf_composite.meta.title_main, + _conf_composite.meta.title_sub, + ); + } } - if (!(dochead_meta["title"]["subtitle"].empty) - && (dochead_meta["title"]["sub"].empty)) { - dochead_meta["title"]["sub"] ~= dochead_meta["title"]["subtitle"]; - } - dochead_meta["title"].remove("subtitle"); - if (dochead_meta["title"]["sub"].empty) { - dochead_meta["title"]["full"] ~= dochead_meta["title"]["main"]; - } else { - dochead_meta["title"]["full"] ~= format( - "%s - %s", - dochead_meta["title"]["main"], - dochead_meta["title"]["sub"], - ); - } - dochead_meta["creator"]["author_raw"] = dochead_meta["creator"]["author"]; - string[] authors_arr; - auto authors_raw_arr = dochead_meta["creator"]["author"].split(rgx.arr_delimiter); - foreach (author_raw; authors_raw_arr) { - authors_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - } - dochead_meta["creator"]["author"] = join(authors_arr, ", ").chomp.chomp; - auto t = tuple(dochead_make, dochead_meta); - static assert(t.length==2); - return t; + return _conf_composite; } #+END_SRC -* B. module native document header :module:sdp:meta_conf_make_meta_native: -** module template +* C. module conf files make composite +** TODO 0. module template -#+BEGIN_SRC d :tangle ../src/sdp/meta/conf_make_meta_native.d +#+BEGIN_SRC d :tangle ../src/sdp/meta/conf_make_meta_composite.d /++ - native headers using
@title:
:subtitle:
type tags
- extract native/orig header return associative array + return composite make from config files +/ -module sdp.meta.conf_make_meta_native; -template SiSUheaderExtractNative() { +module sdp.meta.conf_make_meta_composite; +<> +template confFilesSDLtoStruct() { import std.exception, std.regex, @@ -272,460 +330,39 @@ template SiSUheaderExtractNative() { import sdp.meta.defaults, sdp.meta.rgx; - struct HeaderDocMetadataAndMakeNativeToAA { - mixin SiSUregisters; - mixin SiSUrgxInitFlags; - mixin SiSUrgxInit; - static auto rgx = Rgx(); - enum State { off, on } - string hm, hs; - <> - } + <> } #+END_SRC -** native header document metadata in associative array :aa: - -#+name: meta_markup_header_extract_native -#+BEGIN_SRC d -auto header_metadata_and_make_aa(H,Me,Ma)( - H header, - Me dochead_meta, - Ma dochead_make -) -in { - debug(asserts){ - static assert(is(typeof(header) == string)); - static assert(is(typeof(dochead_meta) == string[string][string])); - static assert(is(typeof(dochead_make) == string[string][string])); - } -} -body { - scope(exit) { - destroy(header); - destroy(dochead_meta); - destroy(dochead_make); - } - if (auto t = header.match(rgx.native_header_main)) { - char[][] header_obj_spl = - (cast(char[]) header).split(rgx.line_delimiter_ws_strip); - auto hm = to!string(t.captures[1]); - if (hm.match(rgx.main_headers)) { - foreach (line; header_obj_spl) { - if (auto m = line.match(rgx.native_header_main)) { - if (!empty(m.captures[2])) { - if (hm == "creator") { - dochead_meta[hm]["author"] = - to!string(m.captures[2]); - } else if (hm == "title") { - dochead_meta[hm]["main"] = - to!string(m.captures[2]); - } else if (hm == "publisher") { - dochead_meta[hm]["name"] = - to!string(m.captures[2]); - } - } - } else if (auto s = match(line, rgx.native_header_sub)) { - if (!empty(s.captures[2])) { - auto hs = to!string(s.captures[1]); - if ((hm == "make" ) - && (dochead_make[hm])) { - switch (hm) { - case "make": - if (hs.match(rgx.native_subhead_make)) { - if (dochead_make[hm][hs]) { - dochead_make[hm][hs] = to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - default: - break; - } - } else if (dochead_meta[hm]) { - switch (hm) { - case "creator": - if (hs.match(rgx.native_subhead_creator)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "title": - if (hs.match(rgx.native_subhead_title)) { - if ((hs == "subtitle") - && (dochead_meta[hm]["sub"])) { - dochead_meta[hm]["sub"] = - to!string(s.captures[2]); - } else if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "rights": - if (hs.match(rgx.native_subhead_rights)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "date": - if (hs.match(rgx.native_subhead_date)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "original": - if (hs.match(rgx.native_subhead_original)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "classify": - if (hs.match(rgx.native_subhead_classify)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "identifier": - if (hs.match(rgx.native_subhead_identifier)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "notes": - if (hs.match(rgx.native_subhead_notes)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "publisher": - if (hs.match(rgx.native_subhead_publisher)) { - if (dochead_meta[hm][hs]) { - dochead_meta[hm][hs] = - to!string(s.captures[2]); - } - } else { - writeln("not a valid header type:", hm, ":", hs); - destroy(hm); - destroy(hs); - } - break; - case "links": - destroy(hm); - destroy(hs); - break; - default: - break; - } - } - } - } - } - } else { - writeln("not a valid header type:", hm); - } - } - auto t = tuple(dochead_meta, dochead_make); - static assert(t.length==2); - return t; -} -#+END_SRC - -** native header extract to string object :string: - -#+name: meta_markup_header_extract_native -#+BEGIN_SRC d -private auto native_header_extract(L,Lo,O,T)( - L line, - return ref Lo line_occur, - return ref O an_object, - return ref T type -) { - 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(type) == int[string])); - } - if (line.matchFirst(rgx.native_header_make)) { /+ matched header_make +/ - debug(header1) { /+ writeln(line); +/ } - type["header"] = State.on; - type["header_make"] = State.on; - type["header_meta"] = State.off; - ++line_occur["header_make"]; - an_object["body_nugget"] ~= line ~= "\n"; - } else if (line.matchFirst(rgx.native_header)) { /+ matched header_metadata +/ - /+ (generic header match and not previously caught by header_make) +/ - debug(header1) { /+ writeln(line); +/ } - type["header"] = State.on; - type["header_make"] = State.off; - type["header_meta"] = State.on; - ++line_occur["header_meta"]; - an_object["body_nugget"] ~= line ~= "\n"; - } else if (type["header_make"] == State.on - && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/ - if (line.matchFirst(rgx.native_header_sub)) { /+ sub-header +/ - debug(header1) { /+ writeln(line); +/ } - ++line_occur["header_make"]; - an_object["body_nugget"] ~= line ~= "\n"; - } - } else if (type["header_meta"] == State.on - && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/ - if (line.matchFirst(rgx.native_header_sub)) { /+ sub-header +/ - debug(header1) { /+ writeln(line); +/ } - ++line_occur["header_meta"]; - an_object["body_nugget"] ~= line ~= "\n"; - } - } - return an_object; -} -#+END_SRC - -** native header reset states :reset: - -#+name: meta_markup_header_extract_native -#+BEGIN_SRC d -auto header_reset_states_common(Lo,O,T)( - return ref Lo line_occur, - return ref O an_object, - return ref T type -) { - debug(asserts){ - static assert(is(typeof(line_occur) == int[string])); - static assert(is(typeof(an_object) == string[string])); - static assert(is(typeof(type) == int[string])); - } - line_occur["header_make"] = State.off; - line_occur["header_meta"] = State.off; - type["header"] = State.off; - an_object.remove("body_nugget"); - an_object.remove("is"); - an_object.remove("attrib"); -} -#+END_SRC - -** hub: native header start :hub: +** module template -#+name: meta_markup_header_extract_native +#+name: meta_conf_make_meta_composite #+BEGIN_SRC d -private auto headerNativeToAA(Hn)(Hn src_header) { - debug(asserts){ - static assert(is(typeof(src_header) == char[])); - } - auto type = flags_type_init; - type = [ - "header" : State.off, - "header_make" : State.off, - "header_meta" : State.off, - ]; - string[string] an_object; - int[string] line_occur; - auto dochead_make = conf_aa_empty; - auto dochead_meta = meta_aa_empty; - auto set_header = HeaderDocMetadataAndMakeNativeToAA(); - char[][] source_header_arr = - (cast(char[]) src_header).split(rgx.newline_eol_delimiter); - foreach(header_line; source_header_arr) { - if (auto m = header_line.matchFirst(rgx.comment)) { - /+ matched comment +/ - debug(comment) { - } - header_reset_states_common(line_occur, an_object, type); - } else if ((header_line.matchFirst(rgx.native_header)) - || (type["header_make"] == State.on - && (line_occur["header_make"] > State.off)) - || (type["header_meta"] == State.on - && (line_occur["header_meta"] > State.off))) { - if (header_line.length == 0) { - /+ header_make instructions (current line empty) +/ - auto dochead_metadata_and_make = - set_header.header_metadata_and_make_aa(strip(an_object["body_nugget"]), dochead_meta, dochead_make); - static assert(!isTypeTuple!(dochead_metadata_and_make)); - dochead_meta = dochead_metadata_and_make[0]; - dochead_make = dochead_metadata_and_make[1]; - header_reset_states_common(line_occur, an_object, type); - type["header_make"] = State.off; - type["header_meta"] = State.off; - debug(headersdlang) { - writeln(dochead_metadata_and_make); - } - } else { - an_object = native_header_extract(header_line, line_occur, an_object, type); - } - } - } - auto t = tuple( - dochead_make, - dochead_meta, - ); - return t; -} -#+END_SRC - -* 0. composite make :module:sdp:meta_composite_make: -** TODO 0. template -*** composite make - -#+BEGIN_SRC d :tangle ../src/sdp/meta/composite_make.d -/++ - output hub
- check & generate output types requested -+/ -module sdp.meta.composite_make; -template compositeMkCnf() { - <> - mixin SiSUrgxInit; - string[] _substitutions; - string[string][] _sub; - string _bold; - string _italics; - string _emphasis; - auto compositeMkCnf(Mks...)(Mks makes) { - static auto rgx = Rgx(); - foreach (make; makes) { - if (auto z = "make" in make) { - if (auto x = "substitute" in *z) { - foreach (m; (*x).matchAll(rgx.make_simple_substitutions_d)) { - _sub ~= ["match": (m["match"]), "replace": (m["replace"])]; - _substitutions ~= format("`%s`,\"%s\"", - m["match"], - m["replace"], - ); - } - foreach (m; (*x).matchAll(rgx.make_simple_substitutions_rb)) { - _sub ~= ["match": (m["match"]), "replace": (m["replace"])]; - _substitutions ~= format("`%s`,\"%s\"", - m["match"], - m["replace"], - ); - } - } - if (auto x = "bold" in *z) { - _bold = (*x).to!string; - } - if (auto x = "italics" in *z) { - _italics = (*x).to!string; - } - if (auto x = "emphasis" in *z) { - _emphasis = (*x).to!string; - } - } - } - struct _composite_make { - auto substitutions() { - auto _k = _sub; - return _k; - } - auto substitute() { - auto _k = _substitutions; - return _k; - } - auto italics() { - auto _k = _italics; - return _k; - } - auto bold() { - auto _k = _bold; - return _k; - } - auto emphasis() { - auto _k = _emphasis; - return _k; - } - } - return _composite_make(); - } -} -#+END_SRC - -*** composite make aa -#+BEGIN_SRC d :tangle ../src/sdp/meta/composite_make.d -/++ - output hub
- check & generate output types requested -+/ -template compositeMkCnfAA() { - <> - mixin SiSUrgxInit; - string[] _substitutions; - string[string][] _sub; - static auto rgx = Rgx(); - auto compositeMkCnfAA(Mks...)(Mks makes) { - /+ - - skip.first_make which is the "composite make output" - - pass config files as associative arrays, - - skip.last_make which is getopt, treat separately - +/ - auto _composite_make = makes[0]; - auto _opts = makes[$-1]; - foreach (make; makes[1..$-1]) { - if (auto z = "make" in make) { // document head: make (part of individual document) - if (auto x = "substitute" in *z) { - _composite_make["make"]["substitute"] = *x; - } - if (auto x = "italics" in *z) { - _composite_make["make"]["italics"] = *x; - } - if (auto x = "bold" in *z) { - _composite_make["make"]["bold"] = *x; - } - if (auto x = "emphasis" in *z) { - _composite_make["make"]["emphasis"] = *x; - } - } +auto confFilesSDLtoStruct(S,L)( + S sdl_root_config_share, + L sdl_root_config_local, +){ + mixin SiSUregisters; + ConfCompositePlus _conf_composite; + foreach (conf_sdlang; [sdl_root_config_share, sdl_root_config_local]) { + if ("make" in conf_sdlang.maybe.tags) { + _conf_composite.make_str.bold = _conf_composite.make.bold = extractSDLangTabOrAttrib(conf_sdlang, "make", "bold"); + _conf_composite.make_str.breaks = _conf_composite.make.breaks = extractSDLangTabOrAttrib(conf_sdlang, "make", "breaks"); + _conf_composite.make_str.cover_image = _conf_composite.make.cover_image = extractSDLangTabOrAttrib(conf_sdlang, "make", "cover_image"); + _conf_composite.make_str.css = _conf_composite.make.css = extractSDLangTabOrAttrib(conf_sdlang, "make", "css"); + _conf_composite.make_str.emphasis = _conf_composite.make.emphasis = extractSDLangTabOrAttrib(conf_sdlang, "make", "emphasis"); + _conf_composite.make_str.footer = _conf_composite.make.footer = extractSDLangTabOrAttrib(conf_sdlang, "make", "footer"); + _conf_composite.make_str.headings = _conf_composite.make.headings = extractSDLangTabOrAttrib(conf_sdlang, "make", "headings"); + _conf_composite.make_str.home_button_image = _conf_composite.make.home_button_image = extractSDLangTabOrAttrib(conf_sdlang, "make", "home_button_image"); + _conf_composite.make_str.home_button_text = _conf_composite.make.home_button_text = extractSDLangTabOrAttrib(conf_sdlang, "make", "home_button_text"); + _conf_composite.make_str.italics = _conf_composite.make.italics = extractSDLangTabOrAttrib(conf_sdlang, "make", "italics"); + _conf_composite.make_str.num_top = _conf_composite.make.num_top = extractSDLangTabOrAttrib(conf_sdlang, "make", "num_top"); + _conf_composite.make_str.num_depth = _conf_composite.make.num_depth = extractSDLangTabOrAttrib(conf_sdlang, "make", "num_depth"); + _conf_composite.make_str.substitute = _conf_composite.make.substitute = extractSDLangTabOrAttrib(conf_sdlang, "make", "substitute"); + _conf_composite.make_str.texpdf_font = _conf_composite.make.texpdf_font = extractSDLangTabOrAttrib(conf_sdlang, "make", "texpdf_font"); } - /+ logic for adding _opts make instructions to _composite make +/ - return _composite_make; } + return _conf_composite; } #+END_SRC -- cgit v1.2.3