From 1d30d4b2225be7f152de94b007d81a5d7b7a1c3a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Jun 2016 22:28:53 -0400 Subject: associated array instead of json --- org/ao_abstract_doc_source.org | 6 +- org/ao_defaults.org | 238 +++++++++++------ org/ao_header_extract.org | 576 +++++++++++++++++++++++++++++++---------- org/sdp.org | 33 +-- 4 files changed, 610 insertions(+), 243 deletions(-) (limited to 'org') diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 6c150e1..1942b5e 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -2165,7 +2165,7 @@ auto heading_matched( ref int[string] lv, ref int[string] collapsed_lev, ref int[string] type, - ref JSONValue[string] dochead_meta_json + ref string[string][string] dochead_meta_json ) { if (auto m = match(line, rgx.heading)) { /+ heading match +/ @@ -4039,8 +4039,8 @@ template SiSUdocAbstraction() { /+ ↓ abstract marked up document +/ auto abstract_doc_source( char[][] markup_sourcefile_content, - JSONValue[string] dochead_make_json, - JSONValue[string] dochead_meta_json + string[string][string] dochead_make_json, + string[string][string] dochead_meta_json ) { /+ ↓ abstraction init +/ <> diff --git a/org/ao_defaults.org b/org/ao_defaults.org index ec007b0..3412ae8 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -16,93 +16,157 @@ * default templates :template:defaults: [[./sdp.org][sdp]] [[./][org/]] -** template: header :header: +** template: settings metadata associative array indexes :settings: + #+name: ao_defaults_templates #+BEGIN_SRC d template SiSUregisters() { - string make_jsonstr = `{ - "make": { - "bold" : "", - "breaks" : "", - "cover_image" : "", - "css" : "", - "emphasis" : "", - "footer" : "", - "headings" : "", - "home_button_image" : "", - "home_button_text" : "", - "italics" : "", - "num_top" : "", - "substitute" : "", - "texpdf_font" : "" - } - }`; - auto meta_jsonstr = `{ - "classify": { - "dewey" : "", - "keywords" : "", - "loc" : "", - "subject" : "", - "topic_register" : "" - }, - "creator": { - "author" : "", - "author_email" : "", - "illustrator" : "", - "translator" : "" - }, - "date": { - "added_to_site" : "", - "available" : "", - "created" : "", - "issued" : "", - "modified" : "", - "published" : "", - "valid" : "" - }, - "identifier": { - "isbn" : "", - "oclc" : "", - "pg" : "" - }, - "links": { - "link" : "" - }, - "notes": { - "abstract" : "", - "description" : "" - }, - "original": { - "language" : "", - "source" : "", - "title" : "" - }, - "publisher": { - "name" : "" - }, - "rights": { - "copyright" : "", - "cover" : "", - "illustrations" : "", - "license" : "" - }, - "title": { - "edition" : "", - "full" : "", - "language" : "", - "main" : "", - "note" : "", - "sub" : "" - } - }`; // links - auto pointer_head_sub_classify = - [ - "dewey", - "keywords", // - "loc", - "subject", - "topic_register" + string[string][string] conf_aa() { + auto conf_ = [ + "webserv": [ + "url_root" : "", + "path" : "~/sdp_www" , + "images" : "" , + "cgi" : "/usr/local/lib/sdp-cgi" + ], + "webserv_cgi": [ + "host" : "localhost", + "base_path" : "", + "port" : "8081", + "user" : "", + "file_links" : "www.sisudoc.org" + ], + "processing": [ + "path" : "~", + "dir" : "_sisu_processing", + "concord_max" : "400000" + ], + "flag": [ + "act0" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest --verbose", + "act1" : "--digest --text --html --manifest", + "act2" : "--digest --text --html --epub --pdf --manifest", + "act3" : "--digest --qrcode --text --html --epub --concordance --pdf --manifest", + "act4" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --manifest", + "act5" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --sqlite --manifest", + "act6" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest", + "act7" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod --manifest", + "act8" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --manifest", + "act9" : "--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod --manifest" + ], + "default": [ + "papersize" : "a4,letter", + "text_wrap" : "78", + "emphasis" : "bold", + "language" : "en", + "digest" : "sha256" + ], + "permission": [ + "share_source" : "" + ], + "program_select": [ + "editor" : "vim", + "epub_viewer" : "ebook-viewer", + "html_viewer" : "xombrero", + "odf_viewer" : "lowriter", + "pdf_viewer" : "evince", + "xml_viewer" : "xml-viewer" + ], + "search": [ + "flag" : "", + "action" : "", + "db" : "", + "title" : "" + ] + ]; + return conf_; + } + string[string][string] make_aa() { + auto make_ = [ + "make": [ + "bold" : "", + "breaks" : "", + "cover_image" : "", + "css" : "", + "emphasis" : "", + "footer" : "", + "headings" : "", + "home_button_image" : "", + "home_button_text" : "", + "italics" : "", + "num_top" : "", + "substitute" : "", + "texpdf_font" : "" + ] ]; + return make_; + } + string[string][string] meta_aa() { + auto meta_ = [ + "classify": [ + "dewey" : "", + "keywords" : "", + "loc" : "", + "subject" : "", + "topic_register" : "" + ], + "creator": [ + "author" : "", + "author_email" : "", + "illustrator" : "", + "translator" : "" + ], + "date": [ + "added_to_site" : "", + "available" : "", + "created" : "", + "issued" : "", + "modified" : "", + "published" : "", + "valid" : "" + ], + "identifier": [ + "isbn" : "", + "oclc" : "", + "pg" : "" + ], + "links": [ + "link" : "" + ], + "notes": [ + "abstract" : "", + "description" : "" + ], + "original": [ + "language" : "", + "source" : "", + "title" : "" + ], + "publisher": [ + "name" : "" + ], + "rights": [ + "copyright" : "", + "cover" : "", + "illustrations" : "", + "license" : "" + ], + "title": [ + "edition" : "", + "full" : "", + "language" : "", + "main" : "", + "note" : "", + "sub" : "" + ] + ]; + return meta_; + } +#+END_SRC + +** template: metadata associative array indexes :header: + +#+name: ao_defaults_templates +#+BEGIN_SRC d auto pointer_head_main = [ "classify", @@ -116,6 +180,14 @@ template SiSUregisters() { "rights", "title" ]; + auto pointer_head_sub_classify = + [ + "dewey", + "keywords", + "loc", + "subject", + "topic_register" + ]; auto pointer_head_sub_creator = [ "author", diff --git a/org/ao_header_extract.org b/org/ao_header_extract.org index a0b87d4..04ebdb6 100644 --- a/org/ao_header_extract.org +++ b/org/ao_header_extract.org @@ -13,107 +13,417 @@ #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) [[./sdp.org][sdp]] [[./][org/]] -* conf make sdlang +* 0. sdlang to AA #+name: ao_header_extract_sdl #+BEGIN_SRC d -private auto documentMakeSDLangToJSONmake(Tag document_make_sdlang) { +private auto configSettingsSDLangToAAmake(Tag conf_sdlang) { + /+ config settings +/ + string hm; + string hs; + auto conf = conf_aa; + hm = "webserv"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "url_root"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "path"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "images"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "cgi"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "webserv_cgi"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "host"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "base_path"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "port"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "user"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "file_links"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "processing"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "path"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "dir"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "concord_max"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "flag"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "act0"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act0"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act1"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act2"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act3"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act4"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act5"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act6"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act7"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act8"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "act9"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "default"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "papersize"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "text_wrap"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "emphasis"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "language"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "digest"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "permission"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "share_source"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "program_select"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "editor"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "epub_viewer"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "html_viewer"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "odf_viewer"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "pdf_viewer"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "xml_viewer"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + hm = "search"; + if (!(conf_sdlang.maybe.tags[hm].empty)) { + hs = "flag"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "action"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "db"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + hs = "title"; + if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) + && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { + writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); + conf[hm][hs] = + to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); + } + } + return conf; +} +#+END_SRC + +* B. conf make sdlang + +#+name: ao_header_extract_sdl +#+BEGIN_SRC d +private auto documentMakeSDLangToAAmake(Tag document_make_sdlang) { /+ dochead +/ string hm; string hs; /+ make +/ - auto dochead_make = parseJSON(make_jsonstr).object; + auto dochead_make = make_aa; if (!(document_make_sdlang.maybe.tags["make"].empty)) { hm = "make"; hs = "bold"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "breaks"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "cover_image"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "css"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "emphasis"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "footer"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "headings"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "home_button_image"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "home_button_text"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "italics"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "num_top"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "substitute"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "texpdf_font"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -127,7 +437,7 @@ private auto documentMakeSDLangToJSONmake(Tag document_make_sdlang) { // if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) // && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { // writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); - // dochead_meta[hm][hs].str = + // dochead_meta[hm][hs] = // to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value); // } } @@ -137,19 +447,19 @@ private auto documentMakeSDLangToJSONmake(Tag document_make_sdlang) { } #+END_SRC -* header native :header:native: +* C.a. header native :header:native: // mixin SiSUheader; -// auto set_header = HeaderDocMetadataAndMakeNativeToJson(); // reintroduce +// auto set_header = HeaderDocMetadataAndMakeNativeToAA(); // reintroduce -** native header document metadata in json :json: +** native header document metadata in associative array :aa: #+name: ao_markup_header_extract_native #+BEGIN_SRC d -auto header_metadata_and_make_jsonstr( +auto header_metadata_and_make_aa( string header, - JSONValue[string] dochead_meta, - JSONValue[string] dochead_make + string[string][string] dochead_meta, + string[string][string] dochead_make ) in { } body { @@ -169,13 +479,13 @@ body { if (auto m = match(line, rgx.native_header_main)) { if (!empty(m.captures[2])) { if (hm == "creator") { - dochead_meta[hm]["author"].str = + dochead_meta[hm]["author"] = to!string(m.captures[2]); } else if (hm == "title") { - dochead_meta[hm]["main"].str = + dochead_meta[hm]["main"] = to!string(m.captures[2]); } else if (hm == "publisher") { - dochead_meta[hm]["name"].str = + dochead_meta[hm]["name"] = to!string(m.captures[2]); } } @@ -183,12 +493,12 @@ body { if (!empty(s.captures[2])) { auto hs = to!string(s.captures[1]); if ((hm == "make" ) - && (dochead_make[hm].type() == JSON_TYPE.OBJECT)) { + && (dochead_make[hm])) { switch (hm) { case "make": if (match(hs, rgx.native_subhead_make)) { - if (dochead_make[hm][hs].type() == JSON_TYPE.STRING) { - dochead_make[hm][hs].str = to!string(s.captures[2]); + if (dochead_make[hm][hs]) { + dochead_make[hm][hs] = to!string(s.captures[2]); } } else { writeln("not a valid header type:", hm, ":", hs); @@ -199,12 +509,12 @@ body { default: break; } - } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) { + } else if (dochead_meta[hm]) { switch (hm) { case "creator": if (match(hs, rgx.native_subhead_creator)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -216,11 +526,11 @@ body { case "title": if (match(hs, rgx.native_subhead_title)) { if ((hs == "subtitle") - && (dochead_meta[hm]["sub"].type() == JSON_TYPE.STRING)) { - dochead_meta[hm]["sub"].str = + && (dochead_meta[hm]["sub"])) { + dochead_meta[hm]["sub"] = to!string(s.captures[2]); - } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + } else if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -231,8 +541,8 @@ body { break; case "rights": if (match(hs, rgx.native_subhead_rights)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -243,8 +553,8 @@ body { break; case "date": if (match(hs, rgx.native_subhead_date)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -255,8 +565,8 @@ body { break; case "original": if (match(hs, rgx.native_subhead_original)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -267,8 +577,8 @@ body { break; case "classify": if (match(hs, rgx.native_subhead_classify)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -279,8 +589,8 @@ body { break; case "identifier": if (match(hs, rgx.native_subhead_identifier)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -291,8 +601,8 @@ body { break; case "notes": if (match(hs, rgx.native_subhead_notes)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -303,8 +613,8 @@ body { break; case "publisher": if (match(hs, rgx.native_subhead_publisher)) { - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = + if (dochead_meta[hm][hs]) { + dochead_meta[hm][hs] = to!string(s.captures[2]); } } else { @@ -317,8 +627,8 @@ body { destroy(hm); destroy(hs); // if (match(hs, rgx.native_subhead_links)) { - // if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - // dochead_meta[hm][hs].str = to!string(s.captures[2]); + // if (dochead_meta[hm][hs]) { + // dochead_meta[hm][hs] = to!string(s.captures[2]); // } // } else { // writeln("not a valid header type:", hm, ":", hs); @@ -412,7 +722,7 @@ auto header_reset_states_common( #+name: ao_markup_header_extract_native #+BEGIN_SRC d -private auto headerNativeToJSON(in char[] src_header) { +private auto headerNativeToAA(in char[] src_header) { auto type = flags_type_init; type = [ "header" : State.off, @@ -421,9 +731,9 @@ private auto headerNativeToJSON(in char[] src_header) { ]; string[string] an_object; int[string] line_occur; - auto dochead_make = parseJSON(make_jsonstr).object; - auto dochead_meta = parseJSON(meta_jsonstr).object; - auto set_header = HeaderDocMetadataAndMakeNativeToJson(); + auto dochead_make = make_aa; + auto dochead_meta = meta_aa; + auto set_header = HeaderDocMetadataAndMakeNativeToAA(); char[][] source_header_arr = split(cast(char[]) src_header, rgx.line_delimiter); foreach(header_line; source_header_arr) { @@ -443,7 +753,7 @@ private auto headerNativeToJSON(in char[] src_header) { if (header_line.length == 0) { /+ header_make instructions (current line empty) +/ auto dochead_metadata_and_make = - set_header.header_metadata_and_make_jsonstr(strip(an_object["obj"]), dochead_meta, dochead_make); + set_header.header_metadata_and_make_aa(strip(an_object["obj"]), 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]; @@ -466,7 +776,7 @@ private auto headerNativeToJSON(in char[] src_header) { } #+END_SRC -* header sdlang :header:sdl: +* C.b. header sdlang :header:sdl: ** sdlang header parse and extract root Tag :sdlang:root:tag: #+name: ao_header_extract_sdl @@ -529,24 +839,11 @@ private auto headerSDLangGet(in char[] src_header) { } #+END_SRC -** sdlang header to json make sdlTag in :sdlang:json: +** sdlang header to associative array make sdlTag in :sdlang:aa: #+name: ao_header_extract_sdl #+BEGIN_SRC d -private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead_make) { - /+ TODO json next +/ - /+ TODO - auto dochead_make = parseJSON(make_jsonstr).object; - auto dochead_meta = parseJSON(meta_jsonstr).object; - auto hm = to!string(t.captures[1]); - auto hs = to!string(s.captures[1]); - if (dochead_make[hm][hs].type() == JSON_TYPE.STRING) { - dochead_make[hm][hs].str = to!string(s.captures[2]); - } - if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) { - dochead_meta[hm][hs].str = to!string(s.captures[2]); - } - +/ +private auto headerSDLangToAAmake(Tag header_sdlang, string[string][string] dochead_make) { /+ dochead +/ string hm; string hs; @@ -557,96 +854,96 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "breaks"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "cover_image"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "css"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "emphasis"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "footer"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "headings"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "home_button_image"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "home_button_text"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "italics"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "num_top"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "substitute"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "texpdf_font"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_make[hm][hs].str = + dochead_make[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } /+ meta +/ - auto dochead_meta = parseJSON(meta_jsonstr).object; + auto dochead_meta = meta_aa; hm = "title"; if (!(header_sdlang.maybe.tags[hm].empty)) { /+ TODO Title REQUIRED +/ @@ -654,13 +951,13 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm].empty) && (header_sdlang.tags[hm][0].values[0].length > 1)) { writeln(header_sdlang.tags[hm][0].values[0]); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].values[0]); // to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } else if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } else { writeln("Required header metadata Title, missing"); @@ -669,12 +966,12 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } else if (!(header_sdlang.tags[hm][0].maybe.attributes["subtitle"].empty) && (header_sdlang.tags[hm][0].attributes["subtitle"][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes["subtitle"][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes["subtitle"][0].value); } // full title composite (main + sub) @@ -684,26 +981,26 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes["lang"].empty) && (header_sdlang.tags[hm][0].attributes["lang"][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes["lang"][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes["lang"][0].value); } else if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "edition"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "note"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -719,28 +1016,28 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "author_email"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "illustrator"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "translator"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -750,35 +1047,35 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "keywords"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "loc"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "subject"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "topic_register"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -788,49 +1085,49 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "available"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "created"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "issued"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "modified"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "published"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "valid"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -840,21 +1137,21 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "oclc"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "pg"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -867,7 +1164,7 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead // if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) // && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { // writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - // dochead_meta[hm][hs].str = + // dochead_meta[hm][hs] = // to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); // } } @@ -877,14 +1174,14 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "description"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -894,21 +1191,21 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "source"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "title"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -918,7 +1215,7 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } @@ -928,47 +1225,45 @@ private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "cover"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "illustrations"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "license"; if (!(header_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (header_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(header_sdlang.tags[hm][0].attributes[hs][0].value); - dochead_meta[hm][hs].str = + dochead_meta[hm][hs] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } - // writeln(dochead_make); - // writeln(dochead_meta); auto t = tuple(dochead_make, dochead_meta); static assert(!isTypeTuple!(t)); return t; } #+END_SRC -** hub: get sdlang header and convert to json :hub:sdlang:json: +** hub: get sdlang header and convert to associative array :hub:sdlang:aa: #+name: ao_header_extract_sdl #+BEGIN_SRC d -private auto headerSDLangToJSON(char[] header_sdlang_src, JSONValue[string] conf_doc_make_json) { +private auto headerSDLangToAA(char[] header_sdlang_src, string[string][string] conf_doc_make_aa) { auto header_sdlang_tag = headerSDLangGet(header_sdlang_src); // sdlang.ast.Tag - auto header_json_tuple = headerSDLangToJSONmake(header_sdlang_tag, conf_doc_make_json); - return header_json_tuple; + auto header_aa_tuple = headerSDLangToAAmake(header_sdlang_tag, conf_doc_make_aa); + return header_aa_tuple; } #+END_SRC @@ -980,11 +1275,11 @@ 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. +program internally. Moved to associative array. #+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract.d /+ - extract native/orig header return json + extract native/orig header return associative array +/ template SiSUheaderExtractHub() { private import @@ -995,13 +1290,13 @@ template SiSUheaderExtractHub() { mixin SiSUheaderExtractNative; mixin SiSUheaderExtractSDLang; auto rgx = Rgx(); - private auto headerContentJSON(char[] header_src, JSONValue[string] conf_doc_make_json) { - auto head_native = HeaderDocMetadataAndMakeNativeToJson(); + private auto headerContentAA(char[] header_src, string[string][string] conf_doc_make_aa) { + auto head_native = HeaderDocMetadataAndMakeNativeToAA(); auto head_sdlang = HeaderExtractSDL(); writeln(__LINE__); auto header_make_and_meta_tuple = (match(header_src, rgx.native_header_meta_title)) - ? (head_native.headerNativeToJSON(header_src)) - : (head_sdlang.headerSDLangToJSON(header_src, conf_doc_make_json)); + ? (head_native.headerNativeToAA(header_src)) + : (head_sdlang.headerSDLangToAA(header_src, conf_doc_make_aa)); writeln(__LINE__); static assert(!isTypeTuple!(header_make_and_meta_tuple)); return header_make_and_meta_tuple; @@ -1010,12 +1305,11 @@ template SiSUheaderExtractHub() { } #+END_SRC -// Tuple!(JSONValue[string], JSONValue[string]) header_make_and_meta_tuple; ** 2a. Header Native :ao_markup_header_extract_native: #+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract_native.d /+ - extract native/orig header return json + extract native/orig header return associative array +/ template SiSUheaderExtractNative() { private import @@ -1025,7 +1319,7 @@ template SiSUheaderExtractNative() { std.conv : to; private import ao_rgx; - struct HeaderDocMetadataAndMakeNativeToJson { + struct HeaderDocMetadataAndMakeNativeToAA { mixin SiSUregisters; mixin SiSUrgxInitFlags; mixin RgxInit; @@ -1053,7 +1347,7 @@ template SiSUheaderExtractSDLang() { mixin RgxInit; auto rgx = Rgx(); <> - <> + <> } } #+END_SRC diff --git a/org/sdp.org b/org/sdp.org index 014cb0c..73882c6 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -28,7 +28,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 6, 0); +enum ver = Version(0, 6, 1); #+END_SRC ** pre loop init @@ -140,7 +140,7 @@ struct SDPoutput { auto html=SDPoutputHTML(); html.css_write; html.scroll(contents, bookindex_unordered_hashes, biblio, fn_src, opt_action_bool); - // html.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make_json, dochead_meta_json, fn_src, opt_action_bool); + // html.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make_aa, dochead_meta_aa, fn_src, opt_action_bool); } if (opt_action_bool["epub"]) { writeln("epub processing"); @@ -198,8 +198,8 @@ auto output = SDPoutput(); /+ struct DocumentParts { string[string][] contents; - JSONValue[string] meta_json; - JSONValue[string] make_json; + string[string][string] meta_aa; + string[string][string] make_aa; string[][string][string] bookindex_unordered_hashes; JSONValue[] biblio; } @@ -312,9 +312,10 @@ foreach(arg; args) { #+BEGIN_SRC d auto conf = ConfigHub(); auto sdl_root_configuration = conf.configSDLang("conf.sdl"); -auto sdl_root_document_make = conf.configSDLang("sisu_document_make"); +auto sdl_root_doc_make = conf.configSDLang("sisu_document_make"); auto confsdl = HeaderExtractSDL(); -auto conf_doc_make_json = confsdl.documentMakeSDLangToJSONmake(sdl_root_document_make); +auto conf_settings_aa = confsdl.configSettingsSDLangToAAmake(sdl_root_configuration); +auto conf_doc_make_aa = confsdl.documentMakeSDLangToAAmake(sdl_root_doc_make); #+END_SRC ** each file (loop) [+2] :loop:files: @@ -365,17 +366,17 @@ debug(header_and_content) { **** [#A] read doc header: metadata & make :doc:header:metadata:make: #+NAME: sdp_each_file_do #+BEGIN_SRC d -auto header_make_and_meta_tuple = head.headerContentJSON(header, conf_doc_make_json); +auto header_make_and_meta_tuple = head.headerContentAA(header, conf_doc_make_aa); static assert(!isTypeTuple!(header_make_and_meta_tuple)); -JSONValue[string] dochead_make_json = header_make_and_meta_tuple[0]; -JSONValue[string] dochead_meta_json = header_make_and_meta_tuple[1]; +string[string][string] dochead_make_aa = header_make_and_meta_tuple[0]; +string[string][string] dochead_meta_aa = header_make_and_meta_tuple[1]; #+END_SRC **** [#A] processing: document abstraction, tuple :processing: #+NAME: sdp_each_file_do #+BEGIN_SRC d /+ ↓ process document, return abstraction as tuple +/ -auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_json, dochead_meta_json); +auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_aa, dochead_meta_aa); static assert(!isTypeTuple!(t)); auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex; // static assert(!isIterable!(doc_ao_contents)); @@ -394,8 +395,8 @@ debug(checkdoc) { // checkbook & dumpdoc doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - dochead_make_json, - dochead_meta_json, + dochead_make_aa, + dochead_meta_aa, fn_src, opt_action_bool ); @@ -411,8 +412,8 @@ output.hub( doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - // doc_ao_make_json, - // doc_ao_meta_json, + // doc_ao_make_aa, + // doc_ao_meta_aa, fn_src, opt_action_bool ); @@ -431,8 +432,8 @@ scope(exit) { destroy(sourcefile_content); destroy(t); destroy(doc_ao_contents); - // destroy(doc_ao_make_json); - // destroy(doc_ao_meta_json); + // destroy(doc_ao_make_aa); + // destroy(doc_ao_meta_aa); // destroy(doc_ao_bookindex_unordered_hashes); destroy(doc_ao_biblio); destroy(fn_src); -- cgit v1.2.3