aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-06-25 06:37:22 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-04 14:48:18 -0400
commitf0c845eba3718fd0c732aebf25eb33e689798e03 (patch)
treec2ea36e199950647b1d3cce153691bb8f4fec378
parentstep5.1 headers sdlang (like native headers) converted to json for common int... (diff)
step6 headers (&config), native & sdlang to json internally
-rw-r--r--maker.org22
-rw-r--r--org/ao_abstract_doc_source.org35
-rw-r--r--org/ao_defaults.org2
-rw-r--r--org/ao_header_extract.org1305
-rw-r--r--org/ao_output_debugs.org10
-rw-r--r--org/ao_read_source_files.org104
-rw-r--r--org/sdp.org106
-rwxr-xr-xsrc/sdp.d57
-rw-r--r--src/sdp/ao_abstract_doc_source.d121
-rw-r--r--src/sdp/ao_defaults.d2
-rw-r--r--src/sdp/ao_header_extract.d1312
-rw-r--r--src/sdp/ao_header_extract_native.d320
-rw-r--r--src/sdp/ao_header_extract_sdlang.d516
-rw-r--r--src/sdp/ao_output_debugs.d154
-rw-r--r--src/sdp/ao_read_config_files.d56
-rw-r--r--src/sdp/ao_read_source_files.d7
-rw-r--r--views/version.txt2
17 files changed, 1752 insertions, 2379 deletions
diff --git a/maker.org b/maker.org
index 61c0826..7aba886 100644
--- a/maker.org
+++ b/maker.org
@@ -16,7 +16,7 @@
* sdp makefile :makefile:
** TODO settings [+2] :settings:
*** alternative D compilers (dmd/ldc2/gdc) [+1] :compiler:
-**** [#A] dmd :dmd:
+**** dmd [#A] :dmd:
#+BEGIN_SRC makefile :tangle makefile
DMD=dmd
@@ -25,7 +25,7 @@ DMD_FLAGS_RELEASE=-O -release
DMD_FLAG_BINOF=-of
#+END_SRC
-**** [#A] ldc2 :ldc:
+**** ldc2 [#A] :ldc:
#+BEGIN_SRC makefile :tangle makefile
LDC=ldc2
@@ -52,7 +52,7 @@ RDMD=rdmd
RDMD_FLAGS=--build-only --compiler=
#+END_SRC
-**** [#A] dub :dub:
+**** dub [#A] :dub:
#+BEGIN_SRC makefile :tangle makefile
DUB=dub
@@ -225,7 +225,7 @@ makefile_new:
make -k tangle_maker
#+END_SRC
-***** dub build rebuild :dub:
+***** TODO dub build rebuild [#A] :dub:
#+BEGIN_SRC makefile :tangle makefile
dub: $(PRG_SRCDIR)/$(PRG_SRC)
@@ -430,7 +430,7 @@ gitsnapshot: distclean tangle
** dub :dub:description:
Every DUB package should contain a [[http://code.dlang.org/package-format?lang=json][dub.json]] (or [[http://code.dlang.org/package-format?lang=sdl][dub.sdl]])
-*** dub.sdl :sdl:
+*** dub.sdl [#A] :sdl:
#+BEGIN_SRC sh :tangle dub.sdl
name "sdp"
@@ -506,7 +506,7 @@ dflags platform="dmd" "-v --force -de -w -J./views -I./src/sdp -of./bin/s
dflags platform="dmd" "-O -release"
#buildOptions "-O -release"
-*** +dub.json+ :json:
+*** +dub.json+ :json:
**** +sdp+
#+BEGIN_SRC json :tangle no
@@ -526,7 +526,7 @@ dflags platform="dmd" "-O -release"
}
#+END_SRC
-**** +sdlang+ :sdlang:
+**** +sdlang+ :sdlang:
#+BEGIN_SRC json :tangle ./src/sdlang/dub.json
{
"name": "sdlang-d",
@@ -654,7 +654,7 @@ time dub --compiler=ldc2 -v --force
#+END_SRC
* D build notes :notes:
** compilers :compiler:
-*** [#A] dmd :dmd:
+*** dmd [#A] :dmd:
#+BEGIN_SRC sh
dmd -de -w -J./views -I./src/sdp -unittest -debug=checkdoc -debug=summary -debug=dumpdoc -of./bin/sdp ./src/sdp.d
@@ -662,7 +662,7 @@ dmd -de -w -J./views -I./src/sdp -of./bin/sdp ./src/sdp.d
dmd -de -w -J./views -I./src/sdp -O -release -of./bin/sdp ./src/sdp.d
#+END_SRC
-*** [#A] ldc2 :ldc2:
+*** ldc2 [#A] :ldc2:
#+BEGIN_SRC sh
ldc2 -de -w -J./views -I./src/sdp -unittest -d-debug=checkdoc -d-debug=summary -d-debug=dumpdoc -of=./bin/sdp ./src/sdp.d
@@ -684,7 +684,7 @@ not done
re: dmd "one can easily get 2x (and even more) speedup by simply switching to gdc -O2", ketmar
** build tools :build:tool:
-*** [#B] rdmd :rdmd:
+*** rdmd [#B] :rdmd:
flags similar to dmd
@@ -700,7 +700,7 @@ rdmd -de -w -J./views -I./src/sdp -unittest -debug=checkdoc -debug=summary -debu
rdmd -de -w -J./views -I./src/sdp -unittest -d-debug=checkdoc -d-debug=summary -d-debug=dumpdoc --compiler=ldc2 -of./bin/sdp ./src/sdp.d
#+END_SRC
-*** [#A] dub :dub:
+*** dub [#A] :dub:
https://github.com/dlang/dub/
http://code.dlang.org/getting_started
http://code.dlang.org/docs/commandline
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org
index f124a71..6c150e1 100644
--- a/org/ao_abstract_doc_source.org
+++ b/org/ao_abstract_doc_source.org
@@ -463,24 +463,24 @@ if (matchFirst(line, rgx.block_open)) {
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading or para but neither flag nor line exists +/
- // if ((to!string(dochead_make_json["make"]["headings"]).length > 2)
- // && (type["make_headings"] == State.off)) {
- // /+ heading found +/
- // auto dochead_make_headings =
- // to!string(dochead_make_json["make"]["headings"]);
- // heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
- // }
+ if ((to!string(dochead_make_json["make"]["headings"]).length > 2)
+ && (type["make_headings"] == State.off)) {
+ /+ heading found +/
+ auto dochead_make_headings =
+ to!string(dochead_make_json["make"]["headings"]);
+ heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
+ }
if ((type["make_headings"] == State.on)
&& ((line_occur["para"] == State.off)
&& (line_occur["heading"] == State.off))
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading make set +/
- // heading_make_set(line, line_occur, heading_match_rgx, type);
+ heading_make_set(line, line_occur, heading_match_rgx, type);
}
if (matchFirst(line, rgx.heading)) {
/+ heading match +/
- heading_matched(line, line_occur, an_object, lv, collapsed_lev, type);
+ heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json);
} else if (line_occur["para"] == State.off) {
/+ para match +/
para_match(line, an_object, indent, bullet, type, line_occur);
@@ -2000,7 +2000,7 @@ auto book_index(
** heading or paragraph :heading:paragraph:
*** heading found :heading:
-##+name: abs_functions
+#+name: abs_functions
#+BEGIN_SRC d
auto heading_found(
char[] line,
@@ -2164,8 +2164,8 @@ auto heading_matched(
ref string[string] an_object,
ref int[string] lv,
ref int[string] collapsed_lev,
- ref int[string] type
- // ref JSONValue[string] dochead_meta_json
+ ref int[string] type,
+ ref JSONValue[string] dochead_meta_json
) {
if (auto m = match(line, rgx.heading)) {
/+ heading match +/
@@ -2179,8 +2179,8 @@ auto heading_matched(
assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels
switch (an_object["lev"]) {
case "A":
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"]));
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"]));
+ an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"]));
+ an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"]));
collapsed_lev["h0"] = 1;
an_object["lev_collapsed_number"] =
to!string(collapsed_lev["h0"]);
@@ -4037,8 +4037,11 @@ template SiSUdocAbstraction() {
<<abs_init_struct>>
/+ ↓ abstract marked up document +/
- auto abstract_doc_source(char[][] markup_sourcefile_content) {
-
+ auto abstract_doc_source(
+ char[][] markup_sourcefile_content,
+ JSONValue[string] dochead_make_json,
+ JSONValue[string] dochead_meta_json
+ ) {
/+ ↓ abstraction init +/
<<abs_init_rest>>
/+ abstraction init ↑ +/
diff --git a/org/ao_defaults.org b/org/ao_defaults.org
index cf473e0..00fe102 100644
--- a/org/ao_defaults.org
+++ b/org/ao_defaults.org
@@ -19,7 +19,7 @@
** template: header :header:
#+name: ao_defaults_templates
#+BEGIN_SRC d
-template SiSUheaderSkel() {
+template SiSUheaderRegister() {
auto header_make_jsonstr = `{
"make": {
"bold" : "",
diff --git a/org/ao_header_extract.org b/org/ao_header_extract.org
index 3e06358..586a0ff 100644
--- a/org/ao_header_extract.org
+++ b/org/ao_header_extract.org
@@ -9,12 +9,341 @@
#+PROPERTY: header-args :padline no :exports code :noweb yes
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
-#+FILETAGS: :sdp:niu:ao:
+#+FILETAGS: :sdp:rel:ao:
#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n)
[[./sdp.org][sdp]] [[./][org/]]
-* header sdlang :header:sdlang:
-** sdlang header parse and extract root Tag :root:tag:
+* header native :header:native:
+
+// mixin SiSUheader;
+// auto set_header = HeaderDocMetadataAndMakeNativeToJson(); // reintroduce
+
+** native header document metadata in json :json:
+
+#+name: ao_markup_header_extract_native
+#+BEGIN_SRC d
+auto header_metadata_and_make_jsonstr(
+ string header,
+ JSONValue[string] dochead_meta,
+ JSONValue[string] dochead_make
+)
+in { }
+body {
+ scope(exit) {
+ destroy(header);
+ destroy(dochead_meta);
+ destroy(dochead_make);
+ }
+ if (auto t = match(header, rgx.native_header_main)) {
+ char[][] header_obj_spl = split(
+ cast(char[]) header,
+ rgx.line_delimiter_ws_strip
+ );
+ auto hm = to!string(t.captures[1]);
+ if (match(hm, rgx.main_headers)) {
+ foreach (line; header_obj_spl) {
+ if (auto m = match(line, rgx.native_header_main)) {
+ if (!empty(m.captures[2])) {
+ if (hm == "creator") {
+ dochead_meta[hm]["author"].str =
+ to!string(m.captures[2]);
+ } else if (hm == "title") {
+ dochead_meta[hm]["main"].str =
+ to!string(m.captures[2]);
+ } else if (hm == "publisher") {
+ dochead_meta[hm]["name"].str =
+ 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].type() == JSON_TYPE.OBJECT)) {
+ 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]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ default:
+ break;
+ }
+ } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) {
+ 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 =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ 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 =
+ to!string(s.captures[2]);
+ } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "rights":
+ if (match(hs, rgx.native_subhead_rights)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "date":
+ if (match(hs, rgx.native_subhead_date)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "original":
+ if (match(hs, rgx.native_subhead_original)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "classify":
+ if (match(hs, rgx.native_subhead_classify)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "identifier":
+ if (match(hs, rgx.native_subhead_identifier)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "notes":
+ if (match(hs, rgx.native_subhead_notes)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "publisher":
+ if (match(hs, rgx.native_subhead_publisher)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ 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);
+ // 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]);
+ // }
+ // } else {
+ // writeln("not a valid header type:", hm, ":", hs);
+ // destroy(hm);
+ // destroy(hs);
+ // }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ writeln("not a valid header type:", hm);
+ }
+ }
+ auto t = tuple(dochead_meta, dochead_make);
+ static assert(!isTypeTuple!(t));
+ return t;
+}
+#+END_SRC
+
+** native header extract to string object :string:
+
+#+name: ao_markup_header_extract_native
+#+BEGIN_SRC d
+private auto native_header_extract(
+ char[] line,
+ ref int[string] line_occur,
+ ref string[string] an_object,
+ ref int[string] type
+) {
+ if (matchFirst(line, 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["obj"] ~= line ~= "\n";
+ } else if (matchFirst(line, 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["obj"] ~= line ~= "\n";
+ } else if (type["header_make"] == State.on
+ && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/
+ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
+ debug(header1) { /+ writeln(line); +/ }
+ ++line_occur["header_make"];
+ an_object["obj"] ~= line ~= "\n";
+ }
+ } else if (type["header_meta"] == State.on
+ && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/
+ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
+ debug(header1) { /+ writeln(line); +/ }
+ ++line_occur["header_meta"];
+ an_object["obj"] ~= line ~= "\n";
+ }
+ }
+ return an_object;
+}
+#+END_SRC
+
+** native header reset states :reset:
+
+#+name: ao_markup_header_extract_native
+#+BEGIN_SRC d
+auto header_reset_states_common(
+ ref int[string] line_occur,
+ ref string[string] an_object,
+ ref int[string] type
+) {
+ // line_occur["header"] = State.off;
+ line_occur["header_make"] = State.off;
+ line_occur["header_meta"] = State.off;
+ type["header"] = State.off;
+ // type["header_make"] = State.off;
+ // type["header_meta"] = State.off;
+ an_object.remove("obj");
+ an_object.remove("is");
+ an_object.remove("attrib");
+}
+#+END_SRC
+
+** hub: native header start :hub:
+
+#+name: ao_markup_header_extract_native
+#+BEGIN_SRC d
+private auto headerNativeToJSON(in char[] src_header) {
+ 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 = parseJSON(header_make_jsonstr).object;
+ auto dochead_meta = parseJSON(header_meta_jsonstr).object;
+ auto set_header = HeaderDocMetadataAndMakeNativeToJson();
+ char[][] source_header_arr =
+ split(cast(char[]) src_header, rgx.line_delimiter);
+ foreach(header_line; source_header_arr) {
+ if (auto m = matchFirst(header_line, rgx.comment)) {
+ /+ matched comment +/
+ debug(comment) {
+ // tell_l("blue", header_line);
+ }
+ header_reset_states_common(line_occur, an_object, type);
+ // type["header_make"] = State.off;
+ // type["header_meta"] = State.off;
+ } else if ((matchFirst(header_line, 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_jsonstr(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];
+ header_reset_states_common(line_occur, an_object, type);
+ type["header_make"] = State.off;
+ type["header_meta"] = State.off;
+ writeln(dochead_metadata_and_make);
+ } else {
+ an_object = native_header_extract(header_line, line_occur, an_object, type);
+ }
+ } else {
+ // writeln(__LINE__);
+ }
+ }
+ auto t = tuple(
+ dochead_make,
+ dochead_meta,
+ );
+ return t;
+}
+#+END_SRC
+
+* header sdlang :header:sdl:
+** sdlang header parse and extract root Tag :sdlang:root:tag:
#+name: ao_header_extract_sdl
#+BEGIN_SRC d
@@ -46,10 +375,11 @@ final private auto headerMakeSDLang(in string src_header) {
}
#+END_SRC
-** sdlang header to json :header:
+** sdlang header get :sdlang:get:src:
+
#+name: ao_header_extract_sdl
#+BEGIN_SRC d
-private auto headerSDLangToJSON(in char[] src_header) {
+private auto headerSDLangGet(in char[] src_header) {
char[][] source_header_arr =
split(cast(char[]) src_header, rgx.line_delimiter);
char[] header_clean;
@@ -71,10 +401,15 @@ private auto headerSDLangToJSON(in char[] src_header) {
writeln(header_sdlang.maybe.tags["title"]);
writeln(header_sdlang.maybe.tags["title"][0].maybe.attributes["subtitle"]);
}
- /+ TODO separate modules? sdlang then json
- return header_sdlang;
- // then do json module?
- +/
+ return header_sdlang; // sdlang.ast.Tag
+}
+#+END_SRC
+
+** sdlang header to json make :sdlang:json:
+
+#+name: ao_header_extract_sdl
+#+BEGIN_SRC d
+private auto headerSDLangToJSONmake(Tag header_sdlang) {
/+ TODO json next +/
/+ TODO
auto dochead_make = parseJSON(header_make_jsonstr).object;
@@ -503,893 +838,85 @@ private auto headerSDLangToJSON(in char[] src_header) {
}
#+END_SRC
-/+
-namespace:name values attributes {
- children
-}
-+/
+** hub: get sdlang header and convert to json :hub:sdlang:json:
-** +sdlang header to associative array+ :header:
#+name: ao_header_extract_sdl
#+BEGIN_SRC d
-private auto headerSDLangToHash(in char[] src_header) {
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- char[] header_clean;
- string[string] header_make;
- string[string][string] header_metadata;
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- header_clean ~= header_line ~ "\n";
- // writeln(header_line);
- }
- }
- /+ get sdlang tags +/
- auto header_sdlang=headerMakeSDLang(to!string(header_clean));
- Value test = header_sdlang.tags["title"][0].values[0];
- // assert(test == typeid(string));
- // writeln(header_sdlang.maybe.tags["title"]);
- // writeln(header_sdlang.maybe.tags["title"][0].attributes["subtitle"]);
- if (!(header_sdlang.maybe.tags["make"].empty)) {
- if (!(header_sdlang.tags["make"][0].maybe.attributes["bold"].empty)
- && (header_sdlang.tags["make"][0].attributes["bold"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["bold"][0].value);
- header_make["bold"] =
- to!string(header_sdlang.tags["make"][0].attributes["bold"][0].value);
- } else {
- header_make["bold"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["breaks"].empty)
- && (header_sdlang.tags["make"][0].attributes["breaks"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["breaks"][0].value);
- header_make["breaks"] =
- to!string(header_sdlang.tags["make"][0].attributes["breaks"][0].value);
- } else {
- header_make["breaks"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["cover_image"].empty)
- && (header_sdlang.tags["make"][0].attributes["cover_image"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["cover_image"][0].value);
- header_make["cover_image"] =
- to!string(header_sdlang.tags["make"][0].attributes["cover_image"][0].value);
- } else {
- header_make["cover_image"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["css"].empty)
- && (header_sdlang.tags["make"][0].attributes["css"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["css"][0].value);
- header_make["css"] =
- to!string(header_sdlang.tags["make"][0].attributes["css"][0].value);
- } else {
- header_make["css"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["emphasis"].empty)
- && (header_sdlang.tags["make"][0].attributes["emphasis"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["emphasis"][0].value);
- header_make["emphasis"] =
- to!string(header_sdlang.tags["make"][0].attributes["emphasis"][0].value);
- } else {
- header_make["emphasis"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["footer"].empty)
- && (header_sdlang.tags["make"][0].attributes["footer"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["footer"][0].value);
- header_make["footer"] =
- to!string(header_sdlang.tags["make"][0].attributes["footer"][0].value);
- } else {
- header_make["footer"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["headings"].empty)
- && (header_sdlang.tags["make"][0].attributes["headings"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["headings"][0].value);
- header_make["headings"] =
- to!string(header_sdlang.tags["make"][0].attributes["headings"][0].value);
- } else {
- header_make["headings"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["home_button_image"].empty)
- && (header_sdlang.tags["make"][0].attributes["home_button_image"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["home_button_image"][0].value);
- header_make["home_button_image"] =
- to!string(header_sdlang.tags["make"][0].attributes["home_button_image"][0].value);
- } else {
- header_make["home_button_image"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["home_button_text"].empty)
- && (header_sdlang.tags["make"][0].attributes["home_button_text"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["home_button_text"][0].value);
- header_make["home_button_text"] =
- to!string(header_sdlang.tags["make"][0].attributes["home_button_text"][0].value);
- } else {
- header_make["home_button_text"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["italics"].empty)
- && (header_sdlang.tags["make"][0].attributes["italics"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["italics"][0].value);
- header_make["italics"] =
- to!string(header_sdlang.tags["make"][0].attributes["italics"][0].value);
- } else {
- header_make["italics"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["num_top"].empty)
- && (header_sdlang.tags["make"][0].attributes["num_top"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["num_top"][0].value);
- header_make["num_top"] =
- to!string(header_sdlang.tags["make"][0].attributes["num_top"][0].value);
- } else {
- header_make["num_top"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["substitute"].empty)
- && (header_sdlang.tags["make"][0].attributes["substitute"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["substitute"][0].value);
- header_make["substitute"] =
- to!string(header_sdlang.tags["make"][0].attributes["substitute"][0].value);
- } else {
- header_make["substitute"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["texpdf_font"].empty)
- && (header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value);
- header_make["texpdf_font"] =
- to!string(header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value);
- } else {
- header_make["texpdf_font"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["title"].empty)) {
- /+ Title REQUIRED +/
- if (!(header_sdlang.tags["title"].empty)
- && (header_sdlang.tags["title"][0].values[0].length > 1)) {
- writeln(header_sdlang.tags["title"][0].values[0]);
- header_metadata["title"]["main"] =
- to!string(header_sdlang.tags["title"][0].values[0]);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["main"].empty)
- && (header_sdlang.tags["title"][0].attributes["main"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["main"][0].value);
- header_metadata["title"]["main"] =
- to!string(header_sdlang.tags["title"][0].attributes["main"][0].value);
- } else {
- writeln("Required header metadata Title, missing");
- header_metadata["title"]["main"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["sub"].empty)
- && (header_sdlang.tags["title"][0].attributes["sub"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["sub"][0].value);
- header_metadata["title"]["sub"] =
- to!string(header_sdlang.tags["title"][0].attributes["sub"][0].value);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["subtitle"].empty)
- && (header_sdlang.tags["title"][0].attributes["subtitle"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["subtitle"][0].value);
- header_metadata["title"]["sub"] =
- to!string(header_sdlang.tags["title"][0].attributes["subtitle"][0].value);
- } else {
- header_metadata["title"]["sub"] = "";
- }
- // full title composite (main + sub)
- header_metadata["title"]["full"] = header_metadata["title"]["main"] ~ header_metadata["title"]["sub"];
- if (!(header_sdlang.tags["title"][0].maybe.attributes["lang"].empty)
- && (header_sdlang.tags["title"][0].attributes["lang"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["lang"][0].value);
- header_metadata["title"]["language"] =
- to!string(header_sdlang.tags["title"][0].attributes["lang"][0].value);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["language"].empty)
- && (header_sdlang.tags["title"][0].attributes["language"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["language"][0].value);
- header_metadata["title"]["language"] =
- to!string(header_sdlang.tags["title"][0].attributes["language"][0].value);
- } else {
- header_metadata["title"]["language"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["edition"].empty)
- && (header_sdlang.tags["title"][0].attributes["edition"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["edition"][0].value);
- header_metadata["title"]["edition"] =
- to!string(header_sdlang.tags["title"][0].attributes["edition"][0].value);
- } else {
- header_metadata["title"]["edition"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["note"].empty)
- && (header_sdlang.tags["title"][0].attributes["note"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["note"][0].value);
- header_metadata["title"]["note"] =
- to!string(header_sdlang.tags["title"][0].attributes["note"][0].value);
- } else {
- header_metadata["title"]["note"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["creator"].empty)) {
- /+ Creator / Author REQUIRED +/
- /+ TODO
- - decide on representation for & deal with multiple authors;
- - author(s) full name;
- - author(s) surname & other parts
- +/
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["author"].empty)
- && (header_sdlang.tags["creator"][0].attributes["author"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["author"][0].value);
- header_metadata["creator"]["author"] =
- to!string(header_sdlang.tags["creator"][0].attributes["author"][0].value);
- } else {
- header_metadata["creator"]["author"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["author_email"].empty)
- && (header_sdlang.tags["creator"][0].attributes["author_email"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["author_email"][0].value);
- header_metadata["creator"]["author_email"] =
- to!string(header_sdlang.tags["creator"][0].attributes["author_email"][0].value);
- } else {
- header_metadata["creator"]["author_email"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["illustrator"].empty)
- && (header_sdlang.tags["creator"][0].attributes["illustrator"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["illustrator"][0].value);
- header_metadata["creator"][""] =
- to!string(header_sdlang.tags["creator"][0].attributes["illustrator"][0].value);
- } else {
- header_metadata["creator"]["illustrator"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["translator"].empty)
- && (header_sdlang.tags["creator"][0].attributes["translator"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["translator"][0].value);
- header_metadata["creator"]["translator"] =
- to!string(header_sdlang.tags["creator"][0].attributes["translator"][0].value);
- } else {
- header_metadata["creator"][""] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["classify"].empty)) {
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["dewey"].empty)
- && (header_sdlang.tags["classify"][0].attributes["dewey"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["dewey"][0].value);
- header_metadata["classify"]["dewey"] =
- to!string(header_sdlang.tags["classify"][0].attributes["dewey"][0].value);
- } else {
- header_metadata["classify"]["dewey"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["keyword"].empty)
- && (header_sdlang.tags["classify"][0].attributes["keyword"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["keyword"][0].value);
- header_metadata["classify"]["keyword"] =
- to!string(header_sdlang.tags["classify"][0].attributes["keyword"][0].value);
- } else {
- header_metadata["classify"]["keyword"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["loc"].empty)
- && (header_sdlang.tags["classify"][0].attributes["loc"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["loc"][0].value);
- header_metadata["classify"]["loc"] =
- to!string(header_sdlang.tags["classify"][0].attributes["loc"][0].value);
- } else {
- header_metadata["classify"]["loc"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["subject"].empty)
- && (header_sdlang.tags["classify"][0].attributes["subject"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["subject"][0].value);
- header_metadata["classify"]["subject"] =
- to!string(header_sdlang.tags["classify"][0].attributes["subject"][0].value);
- } else {
- header_metadata["classify"]["subject"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["topic_register"].empty)
- && (header_sdlang.tags["classify"][0].attributes["topic_register"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["topic_register"][0].value);
- header_metadata["classify"]["topic_register"] =
- to!string(header_sdlang.tags["classify"][0].attributes["topic_register"][0].value);
- } else {
- header_metadata["classify"]["topic_register"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["date"].empty)) {
- if (!(header_sdlang.tags["date"][0].maybe.attributes["added_to_site"].empty)
- && (header_sdlang.tags["date"][0].attributes["added_to_site"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["added_to_site"][0].value);
- header_metadata["date"]["added_to_site"] =
- to!string(header_sdlang.tags["date"][0].attributes["added_to_site"][0].value);
- } else {
- header_metadata["date"]["added_to_site"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["available"].empty)
- && (header_sdlang.tags["date"][0].attributes["available"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["available"][0].value);
- header_metadata["date"]["available"] =
- to!string(header_sdlang.tags["date"][0].attributes["available"][0].value);
- } else {
- header_metadata["date"]["available"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["created"].empty)
- && (header_sdlang.tags["date"][0].attributes["created"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["created"][0].value);
- header_metadata["date"]["created"] =
- to!string(header_sdlang.tags["date"][0].attributes["created"][0].value);
- } else {
- header_metadata["date"]["created"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["issued"].empty)
- && (header_sdlang.tags["date"][0].attributes["issued"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["issued"][0].value);
- header_metadata["date"]["issued"] =
- to!string(header_sdlang.tags["date"][0].attributes["issued"][0].value);
- } else {
- header_metadata["date"]["issued"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["modified"].empty)
- && (header_sdlang.tags["date"][0].attributes["modified"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["modified"][0].value);
- header_metadata["date"]["modified"] =
- to!string(header_sdlang.tags["date"][0].attributes["modified"][0].value);
- } else {
- header_metadata["date"]["modified"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["published"].empty)
- && (header_sdlang.tags["date"][0].attributes["published"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["published"][0].value);
- header_metadata["date"]["published"] =
- to!string(header_sdlang.tags["date"][0].attributes["published"][0].value);
- } else {
- header_metadata["date"]["published"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["valid"].empty)
- && (header_sdlang.tags["date"][0].attributes["valid"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["valid"][0].value);
- header_metadata["date"]["valid"] =
- to!string(header_sdlang.tags["date"][0].attributes["valid"][0].value);
- } else {
- header_metadata["date"]["valid"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["identifier"].empty)) {
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["isbn"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["isbn"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["isbn"][0].value);
- header_metadata["identifier"]["isbn"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["isbn"][0].value);
- } else {
- header_metadata["identifier"]["isbn"] = "";
- }
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["oclc"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["oclc"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["oclc"][0].value);
- header_metadata["identifier"]["oclc"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["oclc"][0].value);
- } else {
- header_metadata["identifier"]["oclc"] = "";
- }
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["pg"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["pg"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["pg"][0].value);
- header_metadata["identifier"]["pg"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["pg"][0].value);
- } else {
- header_metadata["identifier"]["pg"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["links"].empty)) {
- /+ TODO
- stuff to fix
- +/
- if (!(header_sdlang.tags["links"][0].maybe.attributes["link"].empty)
- && (header_sdlang.tags["links"][0].attributes["link"][0].value.length > 1)) {
- writeln(header_sdlang.tags["links"][0].attributes["link"][0].value);
- // header_metadata["links"]["list"] =
- // to!string(header_sdlang.tags["links"][0].attributes["link"][0].value);
- header_metadata["links"]["list"] = "";
- } else {
- header_metadata["links"]["list"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["notes"].empty)) {
- if (!(header_sdlang.tags["notes"][0].maybe.attributes["abstract"].empty)
- && (header_sdlang.tags["notes"][0].attributes["abstract"][0].value.length > 1)) {
- writeln(header_sdlang.tags["notes"][0].attributes["abstract"][0].value);
- header_metadata["notes"]["abstract"] =
- to!string(header_sdlang.tags["notes"][0].attributes["abstract"][0].value);
- } else {
- header_metadata["notes"]["abstract"] = "";
- }
- if (!(header_sdlang.tags["notes"][0].maybe.attributes["description"].empty)
- && (header_sdlang.tags["notes"][0].attributes["description"][0].value.length > 1)) {
- writeln(header_sdlang.tags["notes"][0].attributes["description"][0].value);
- header_metadata["notes"]["description"] =
- to!string(header_sdlang.tags["notes"][0].attributes["description"][0].value);
- } else {
- header_metadata["notes"]["description"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["original"].empty)) {
- if (!(header_sdlang.tags["original"][0].maybe.attributes["language"].empty)
- && (header_sdlang.tags["original"][0].attributes["language"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["language"][0].value);
- header_metadata["original"]["language"] =
- to!string(header_sdlang.tags["original"][0].attributes["language"][0].value);
- } else {
- header_metadata["original"]["language"] = "";
- }
- if (!(header_sdlang.tags["original"][0].maybe.attributes["source"].empty)
- && (header_sdlang.tags["original"][0].attributes["source"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["source"][0].value);
- header_metadata["original"]["source"] =
- to!string(header_sdlang.tags["original"][0].attributes["source"][0].value);
- } else {
- header_metadata["original"]["source"] = "";
- }
- if (!(header_sdlang.tags["original"][0].maybe.attributes["title"].empty)
- && (header_sdlang.tags["original"][0].attributes["title"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["title"][0].value);
- header_metadata["original"]["title"] =
- to!string(header_sdlang.tags["original"][0].attributes["title"][0].value);
- } else {
- header_metadata["original"]["title"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["publisher"].empty)) {
- if (!(header_sdlang.tags["publisher"][0].maybe.attributes["name"].empty)
- && (header_sdlang.tags["publisher"][0].attributes["name"][0].value.length > 1)) {
- writeln(header_sdlang.tags["publisher"][0].attributes["name"][0].value);
- header_metadata["publisher"]["name"] =
- to!string(header_sdlang.tags["publisher"][0].attributes["name"][0].value);
- } else {
- header_metadata["publisher"]["name"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["rights"].empty)) {
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["copyright"].empty)
- && (header_sdlang.tags["rights"][0].attributes["copyright"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["copyright"][0].value);
- header_metadata["rights"]["copyright"] =
- to!string(header_sdlang.tags["rights"][0].attributes["copyright"][0].value);
- } else {
- header_metadata["rights"]["copyright"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["cover"].empty)
- && (header_sdlang.tags["rights"][0].attributes["cover"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["cover"][0].value);
- header_metadata["rights"]["cover"] =
- to!string(header_sdlang.tags["rights"][0].attributes["cover"][0].value);
- } else {
- header_metadata["rights"]["cover"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["illustrations"].empty)
- && (header_sdlang.tags["rights"][0].attributes["illustrations"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["illustrations"][0].value);
- header_metadata["rights"]["illustrations"] =
- to!string(header_sdlang.tags["rights"][0].attributes["illustrations"][0].value);
- } else {
- header_metadata["rights"]["illustrations"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["license"].empty)
- && (header_sdlang.tags["rights"][0].attributes["license"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["license"][0].value);
- header_metadata["rights"]["license"] =
- to!string(header_sdlang.tags["rights"][0].attributes["license"][0].value);
- } else {
- header_metadata["rights"]["license"] = "";
- }
- }
- writeln("--------------");
- stdout.rawWrite( header_sdlang.toSDLDocument() );
- writeln("--------------");
- /+
- namespace:name values attributes {
- children
- }
- +/
- return header_sdlang;
+private auto headerSDLangToJSON(char[] header_sdlang_src) {
+ auto header_sdlang_tag = headerSDLangGet(header_sdlang_src); // sdlang.ast.Tag
+ auto header_json_tuple = headerSDLangToJSONmake(header_sdlang_tag);
+ return header_json_tuple;
}
#+END_SRC
-** +sdlang header+ :header:
-KEEP not used because have problems passing the root sdl Tag to other structs
-
-#+name: ao_header_extract_sdl
-#+BEGIN_SRC d
-private auto headerSDLang(in char[] src_header) {
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- char[] header_clean;
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- header_clean ~= header_line ~ "\n";
- // writeln(header_line);
- }
- }
- // writeln(header_clean); // consider
- auto header_sdlang=headerMakeSDLang(to!string(header_clean));
- return header_sdlang;
-}
-#+END_SRC
-
-* header native :header:native:
-
-// mixin SiSUheader;
-// auto set_header = HeaderDocMetadataAndMakeNativeToJson(); // reintroduce
+* tangles (code structure) :tangle:
+** 1. Header Hub :ao_markup_header_extract:
-** native header document metadata in json :json:
+the header is passed as text (lopped off top of a sisu markup file until the
+required first heading ^A~), determine whether is a native header or sdlang one
+with a regex check if whether it contains the "native header" required tag/field
+@title: then process accordingly as a "native header" or "sdlang header"
+converting the metadata and make instructions to a common json format used by
+program internally.
-#+name: ao_markup_header_extract_native
-#+BEGIN_SRC d
-auto header_metadata_and_make_jsonstr(
- string header,
- JSONValue[string] dochead_meta,
- JSONValue[string] dochead_make
-)
-in { }
-body {
- scope(exit) {
- destroy(header);
- destroy(dochead_meta);
- destroy(dochead_make);
- }
- if (auto t = match(header, rgx.native_header_main)) {
- char[][] header_obj_spl = split(
- cast(char[]) header,
- rgx.line_delimiter_ws_strip
- );
- auto hm = to!string(t.captures[1]);
- if (match(hm, rgx.main_headers)) {
- foreach (line; header_obj_spl) {
- if (auto m = match(line, rgx.native_header_main)) {
- if (!empty(m.captures[2])) {
- if (hm == "creator") {
- dochead_meta[hm]["author"].str =
- to!string(m.captures[2]);
- } else if (hm == "title") {
- dochead_meta[hm]["main"].str =
- to!string(m.captures[2]);
- } else if (hm == "publisher") {
- dochead_meta[hm]["name"].str =
- 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].type() == JSON_TYPE.OBJECT)) {
- 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]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- default:
- break;
- }
- } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) {
- 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 =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- 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 =
- to!string(s.captures[2]);
- } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "rights":
- if (match(hs, rgx.native_subhead_rights)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "date":
- if (match(hs, rgx.native_subhead_date)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "original":
- if (match(hs, rgx.native_subhead_original)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "classify":
- if (match(hs, rgx.native_subhead_classify)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "identifier":
- if (match(hs, rgx.native_subhead_identifier)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "notes":
- if (match(hs, rgx.native_subhead_notes)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "publisher":
- if (match(hs, rgx.native_subhead_publisher)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- 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);
- // 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]);
- // }
- // } else {
- // writeln("not a valid header type:", hm, ":", hs);
- // destroy(hm);
- // destroy(hs);
- // }
- break;
- default:
- break;
- }
- }
- }
- }
- }
- } else {
- writeln("not a valid header type:", hm);
+#+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract.d
+/+
+ extract native/orig header return json
++/
+template SiSUheaderExtractHub() {
+ private import
+ std.regex;
+ private import
+ ao_rgx;
+ struct HeaderDocMetadataAndMake {
+ mixin SiSUheaderExtractNative;
+ mixin SiSUheaderExtractSDLang;
+ auto rgx = Rgx();
+ private auto headerContentJSON(char[] header_src) {
+ auto head_native = HeaderDocMetadataAndMakeNativeToJson();
+ 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));
+ writeln(__LINE__);
+ static assert(!isTypeTuple!(header_make_and_meta_tuple));
+ return header_make_and_meta_tuple;
}
}
- auto t = tuple(dochead_meta, dochead_make);
- static assert(!isTypeTuple!(t));
- return t;
}
#+END_SRC
-** native header extract to string object :string:
-#+name: ao_markup_header_extract_native
-#+BEGIN_SRC d
-private auto native_header_extract(
- char[] line,
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
-) {
- if (matchFirst(line, 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["obj"] ~= line ~= "\n";
- } else if (matchFirst(line, 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["obj"] ~= line ~= "\n";
- } else if (type["header_make"] == State.on
- && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/
- if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
- debug(header1) { /+ writeln(line); +/ }
- ++line_occur["header_make"];
- an_object["obj"] ~= line ~= "\n";
- }
- } else if (type["header_meta"] == State.on
- && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/
- if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
- debug(header1) { /+ writeln(line); +/ }
- ++line_occur["header_meta"];
- an_object["obj"] ~= line ~= "\n";
- }
- }
- return an_object;
-}
-#+END_SRC
+// Tuple!(JSONValue[string], JSONValue[string]) header_make_and_meta_tuple;
+** 2a. Header Native :ao_markup_header_extract_native:
-** native header reset states :reset:
-#+name: ao_markup_header_extract_native
-#+BEGIN_SRC d
-auto header_reset_states_common(
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
-) {
- // line_occur["header"] = State.off;
- line_occur["header_make"] = State.off;
- line_occur["header_meta"] = State.off;
- type["header"] = State.off;
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- an_object.remove("obj");
- an_object.remove("is");
- an_object.remove("attrib");
-}
-#+END_SRC
-
-** native header start :start:
-#+name: ao_markup_header_extract_native
-#+BEGIN_SRC d
-private auto headerContentJSON(in char[] src_header) {
- 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 = parseJSON(header_make_jsonstr).object;
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
- auto set_header = HeaderDocMetadataAndMakeNativeToJson();
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- foreach(header_line; source_header_arr) {
- if (auto m = matchFirst(header_line, rgx.comment)) {
- /+ matched comment +/
- debug(comment) {
- // tell_l("blue", header_line);
- }
- header_reset_states_common(line_occur, an_object, type);
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- } else if ((matchFirst(header_line, 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_jsonstr(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];
- header_reset_states_common(line_occur, an_object, type);
- type["header_make"] = State.off;
- type["header_meta"] = State.off;
- writeln(dochead_metadata_and_make);
- } else {
- an_object = native_header_extract(header_line, line_occur, an_object, type);
- }
- } else {
- // writeln(__LINE__);
- }
+#+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract_native.d
+/+
+ extract native/orig header return json
++/
+template SiSUheaderExtractNative() {
+ private import
+ std.exception,
+ std.regex,
+ std.utf,
+ std.conv : to;
+ private import
+ ao_rgx;
+ struct HeaderDocMetadataAndMakeNativeToJson {
+ mixin SiSUheaderRegister;
+ mixin SiSUrgxInitFlags;
+ mixin RgxInit;
+ auto rgx = Rgx();
+ enum State { off, on }
+ string hm, hs;
+ <<ao_markup_header_extract_native>>
}
- auto t = tuple(
- dochead_make,
- dochead_meta,
- );
- return t;
}
#+END_SRC
-** +header document metadata+ :document:metadata:
-*** +within abstraction loop+
-
-**** +line exist: header make+ :header:make:
-# #+name: abs_in_loop_body_not_block_obj
-# #+BEGIN_SRC d
-# } else if (line_occur["header_make"] > State.off) {
-# /+ header_make +/
-# // should be caught by sub-header
-# debug(header) {
-# tell_l("red", line);
-# }
-# an_object["obj"] ~= line ~= "\n";
-# ++line_occur["header_make"];
-# #+END_SRC
-
-**** +line exist: header metadata+ :header:metadata:
-# #+name: abs_in_loop_body_not_block_obj
-# #+BEGIN_SRC d
-# } else if (line_occur["header_meta"] > State.off) {
-# /+ header_metadata +/
-# // should be caught by sub-header
-# debug(header) { // para
-# tell_l("red", line);
-# }
-# an_object["obj"] ~= line ~= "\n";
-# ++line_occur["header_meta"];
-# #+END_SRC
-
-**** +header_make instructions+ :header:make:instructions:
-
-# #+name: abs_in_loop_body_not_block_obj_line_empty
-# #+BEGIN_SRC d
-# if ((type["header_make"] == State.on)
-# && (line_occur["header_make"] > State.off)) {
-# /+ 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);
-# 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);
-# processing.remove("verse");
-# #+END_SRC
+** 2b. Header SDLang :ao_markup_header_extract_sdlang:
-**** +header_metadata+ :header:metadata:
-
-# #+name: abs_in_loop_body_not_block_obj_line_empty
-# #+BEGIN_SRC d
-# } else if ((type["header_meta"] == State.on)
-# && (line_occur["header_meta"] > State.off)) {
-# /+ header_meta (current line empty) +/
-# auto dochead_metadata_and_make =
-# set_header.header_metadata_and_make_jsonstr(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];
-# header_reset_states_common(line_occur, an_object, type);
-# type["header_make"] = State.off;
-# type["header_meta"] = State.off;
-# processing.remove("verse");
-# #+END_SRC
-
-* tangles (code structure) :tangle:
-** SDLang ao_markup_header_extract.d: :ao_markup_header_extract.d:
-#+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract.d
+#+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract_sdlang.d
/+
extract sdl header return sdl
+/
@@ -1399,6 +926,7 @@ template SiSUheaderExtractSDLang() {
private import
ao_rgx;
struct HeaderExtractSDL {
+ mixin SiSUheaderRegister;
mixin RgxInit;
auto rgx = Rgx();
<<ao_header_extract_sdl>>
@@ -1425,26 +953,3 @@ template SiSUheaderExtractSDLang() {
}
}
#+END_SRC
-** Native ao_markup_header_extract.d: :ao_markup_header_extract.d:
-#+BEGIN_SRC d :tangle ../src/sdp/ao_header_extract.d
-/+
- extract native/orig header return json
-+/
-template SiSUheaderExtractNative() {
- private import
- std.exception,
- std.regex,
- std.utf,
- std.conv : to;
- private import
- ao_rgx;
- struct HeaderDocMetadataAndMakeNativeToJson {
- mixin SiSUrgxInitFlags;
- mixin RgxInit;
- auto rgx = Rgx();
- enum State { off, on }
- string hm, hs;
- <<ao_markup_header_extract_native>>
- }
-}
-#+END_SRC
diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org
index 99a3301..7b84fdd 100644
--- a/org/ao_output_debugs.org
+++ b/org/ao_output_debugs.org
@@ -87,7 +87,7 @@ debug(objects) {
}
#+END_SRC
** (headermakejson) :json:header:
-##+name: ao_output_debugs
+#+name: ao_output_debugs
#+BEGIN_SRC d
debug(headermakejson) {
writefln(
@@ -117,7 +117,7 @@ debug(headermakejson) {
}
#+END_SRC
** (headermetadatajson) :json:header:
-##+name: ao_output_debugs
+#+name: ao_output_debugs
#+BEGIN_SRC d
debug(headermetadatajson) {
writefln(
@@ -323,10 +323,12 @@ debug(checkdoc) {
if (auto mfn=match(fn_src, rgx.src_fn)) {
if (opt_action_bool["assertions"]) {
switch (mfn.captures[2]) {
+ // live manual:
case "live-manual.ssm":
assert(check["last_obj_cite_number"] ==
"1019","last obj_cite_number should be: 1019 (check test, document is frequently updated)"); // ok
break;
+ // sisu_markup:
case "sisu_markup.sst":
assert(check["last_obj_cite_number"] ==
"297","last obj_cite_number expected to be: 297 rather than " ~ check["last_obj_cite_number"]); // ok
@@ -460,8 +462,8 @@ template SiSUoutputDebugs() {
auto ref const S contents,
string[][string][string] bookindex_unordered_hashes,
JSONValue[] biblio,
- // JSONValue[string] dochead_make,
- // JSONValue[string] dochead_meta,
+ JSONValue[string] dochead_make,
+ JSONValue[string] dochead_meta,
string fn_src,
bool[string] opt_action_bool
) {
diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org
index 52537be..c3c68ad 100644
--- a/org/ao_read_source_files.org
+++ b/org/ao_read_source_files.org
@@ -9,17 +9,17 @@
#+PROPERTY: header-args :padline no :exports code :noweb yes
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
-#+FILETAGS: :sdp:niu:ao:
+#+FILETAGS: :sdp:rel:ao:
#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n)
[[./sdp.org][sdp]] [[./][org/]]
* get config file :config:
** [#A] read config file, source string :string:
-*** config file :file:config:
-#+name: ao_config_file
+*** config file (conf.sdl & sisu_document_make) :file:config:
+#+name: ao_config_file_in
#+BEGIN_SRC d
-final private string readInConfigFile() {
+final private string readInConfigFile(string conf_sdl) {
// enforce(
// exists(fn_src)!=0,
// "file not found"
@@ -30,7 +30,6 @@ final private string readInConfigFile() {
environment["HOME"] ~ "/.sisu",
"/etc/sisu"
];
- string conf_sdl = "conf.sdl";
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = format(
@@ -72,6 +71,50 @@ final private string readInConfigFile() {
}
#+END_SRC
+*** config file get sdl root tag :file:conf:sdlang:
+
+#+name: ao_config_file_sdlang
+#+BEGIN_SRC d
+private auto configSDLangRootTag(string configuration, string conf_sdl_filename) {
+ Tag sdl_root_conf;
+ try {
+ sdl_root_conf = parseSource(configuration);
+ }
+ catch(SDLangParseException e) {
+ stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
+ // Error messages of the form:
+ // myFile.sdl(5:28): Error: Invalid integer suffix.
+ stderr.writeln(e.msg);
+ }
+ debug(sdlang) {
+ // Value is a std.variant.Algebraic
+ Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
+ assert(output_dir_structure_by.type == typeid(string));
+ writeln(output_dir_structure_by);
+ // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0];
+ // writeln("Name: ", person.attributes["name"][0].value);
+ //
+ // int age = person.tags["age"][0].values[0].get!int();
+ // writeln("Age: ", age);
+ writeln("conf SDL:");
+ writeln(sdl_root_conf.toSDLDocument());
+ }
+ return sdl_root_conf;
+}
+#+END_SRC
+
+*** config file (conf.sdl & sisu_document_make) :file:config:hub:
+#+name: ao_config_file_sdlang_hub
+#+BEGIN_SRC d
+final private auto configSDLang(string conf_sdl) {
+ auto conf_get = ConfigIn();
+ auto configuration = conf_get.readInConfigFile(conf_sdl);
+ auto conf = ConfigSDLangRootTag();
+ auto sdl_root = conf.configSDLangRootTag(configuration, conf_sdl);
+ return sdl_root;
+}
+#+END_SRC
+
* get markup source, read file :source:markup:
** [#A] read file, source string :string:
@@ -138,7 +181,7 @@ catch (ErrnoException ex) {
// }
}
-** array[0..1]: split header content :array:
+** array[0..1]: split header content :array:
#+name: ao_markup_source_raw
#+BEGIN_SRC d
final private char[][] header0Content1(in string src_text) {
@@ -324,6 +367,13 @@ if (type["curly_code"] == 1) {
auto fn_src_insert =
to!string(markup_src_file_path ~ insert_sub_pth ~ insert_fn);
auto raw = MarkupRawUnit();
+ /+ TODO +/
+ if (auto ma = match(line, rgx.src_fn_text)) {
+ /+ .sst when inserted, not used: headers and heading level ^:?A~ so remove +/
+ writeln(__LINE__); writeln(ma);
+ // auto t =
+ // raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth);
+ }
auto markup_sourcefile_insert_content =
raw.markupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts);
debug(insert) { // insert file
@@ -365,7 +415,7 @@ return contents;
#+END_SRC
* tangles (code structure) :tangle:
-** ao_markup_source_raw.d: :ao_markup_source_raw.d:
+** ao_markup_source_raw.d: :ao_markup_source_raw:
#+BEGIN_SRC d :tangle ../src/sdp/ao_read_source_files.d
/+
@@ -444,14 +494,16 @@ INSERTS?
[[./ao_scan_inserts.org][ao_scan_inserts]]
WORK AREA
-** config files: :ao_config_files.d:
+** config files (conf.sdl & sisu_document_make) :ao_config_files:
+
+*** config files, read in
#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d
/+
ao_config_files.d
- read config files
+/
-template SiSUconfiguration() {
+template SiSUconfigIn() {
private import
std.exception,
// std.regex,
@@ -463,9 +515,37 @@ template SiSUconfiguration() {
// mixin RgxInit;
// auto rgx = Rgx();
private
- struct Config {
+ struct ConfigIn {
private import std.file;
- <<ao_config_file>>
+ <<ao_config_file_in>>
+ }
+}
+#+END_SRC
+
+*** config files get sdlang root tag
+
+#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d
+/+
+
++/
+template SiSUconfigSDLang() {
+ struct ConfigSDLangRootTag {
+ <<ao_config_file_sdlang>>
+ }
+}
+#+END_SRC
+
+*** config files hub
+
+#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d
+/+
+
++/
+template SiSUconfigSDLangHub() {
+ mixin SiSUconfigIn;
+ mixin SiSUconfigSDLang;
+ struct ConfigHub {
+ <<ao_config_file_sdlang_hub>>
}
}
#+END_SRC
@@ -488,7 +568,7 @@ from 0~ read in as content
# #+BEGIN_SRC d
/+ ↓ read file +/
// auto conf = MarkupRaw();
-auto conf = Config();
+auto conf = ConfigIn();
auto configfile_content =
conf.sourceConfig(fn_src);
# #+END_SRC
diff --git a/org/sdp.org b/org/sdp.org
index 2d4b7b9..89cd588 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -28,7 +28,7 @@ struct Version {
int minor;
int patch;
}
-enum ver = Version(0, 5, 1);
+enum ver = Version(0, 6, 0);
#+END_SRC
** pre loop init
@@ -41,7 +41,7 @@ enum ver = Version(0, 5, 1);
[[./ao_read_source_files.org][ao_read_source_files]]
[[./output_hub.org][output hub]]
-**** sdp :import:sdp:
+**** sdp :import:sdp:
***** TODO src/sdp.d
├── src
@@ -61,6 +61,8 @@ import
ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d
ao_defaults, // sdp/ao_defaults.d
ao_header_extract, // sdp/ao_header_extract.d
+ ao_header_extract_native, // sdp/ao_header_extract_native.d
+ ao_header_extract_sdlang, // sdp/ao_header_extract_sdlang.d
ao_read_config_files, // sdp/ao_read_config_files.d
ao_read_source_files, // sdp/ao_read_source_files.d
ao_output_debugs, // sdp/ao_output_debugs.d
@@ -70,14 +72,11 @@ import
// std.conv;
#+END_SRC
-**** sdlang :import:sdlang:
+**** sdlang :import:sdlang:
#+NAME: sdlang_imports_use
#+BEGIN_SRC d
/+ sdlang http://sdlang.org +/
import sdlang; // sdlang.d
- // sdlang.parser, // sdlang/parser.d
- // sdlang.exceptions; // sdp/ao_ansi_colors.d
- // // std.conv;
#+END_SRC
**** std :import:std:
@@ -163,7 +162,7 @@ struct SDPoutput {
}
#+END_SRC
-**** version.txt :version:
+**** version.txt :version:
#+NAME: sdp_version_mixin
#+BEGIN_SRC d
@@ -174,12 +173,11 @@ mixin(import("version.txt"));
#+NAME: sdp_args
#+BEGIN_SRC d
-mixin SiSUheaderSkel;
-mixin SiSUheaderExtractNative;
-mixin SiSUheaderExtractSDLang;
+mixin SiSUheaderRegister;
+mixin SiSUheaderExtractHub;
mixin SiSUbiblio;
mixin SiSUrgxInitFlags;
-mixin SiSUconfiguration;
+mixin SiSUconfigSDLangHub;
mixin SiSUmarkupRaw;
mixin SiSUdocAbstraction;
mixin SiSUoutputDebugs;
@@ -192,8 +190,7 @@ mixin ScreenTxtColors;
#+NAME: sdp_args
#+BEGIN_SRC d
auto raw = MarkupRaw();
-auto head_native = HeaderDocMetadataAndMakeNativeToJson();
-auto headsdl = HeaderExtractSDL();
+auto head = HeaderDocMetadataAndMake();
auto abs = Abstraction();
auto dbg = SDPoutputDebugs();
auto output = SDPoutput();
@@ -308,60 +305,13 @@ foreach(arg; args) {
}
#+END_SRC
-*** config files (load) :config:files:
-#+BEGIN_SRC text
-./.sisu ./_sisu ~/.sisu /etc/.sisu
-#+END_SRC
-
-#+BEGIN_SRC d
-// string[string] envVars = environment.toAA();
-// writeln(envVars);
-/+
-writefln(
- "pwd: %s; home: %s",
- environment["PWD"],
- environment["HOME"]
-);
-+/
-#+END_SRC
+*** TODO config files (load & read) (so far only SDLang) :config:files:
-**** config load
#+NAME: sdp_config_files
#+BEGIN_SRC d
-auto conf = Config();
-auto configuration = conf.readInConfigFile();
-#+END_SRC
-
-**** config read
-
-#+NAME: sdp_config_files
-#+BEGIN_SRC d
-/+ sdlang config +/
-Tag sdl_root_conf;
-try {
- sdl_root_conf = parseSource(configuration);
-}
-catch(SDLangParseException e) {
- stderr.writeln("SDLang problem with config.sdl content");
- // Error messages of the form:
- // myFile.sdl(5:28): Error: Invalid integer suffix.
- stderr.writeln(e.msg);
-}
-debug(sdlang) {
- // Value is a std.variant.Algebraic
- Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
- assert(output_dir_structure_by.type == typeid(string));
- writeln(output_dir_structure_by);
-
- // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0];
- // writeln("Name: ", person.attributes["name"][0].value);
- //
- // int age = person.tags["age"][0].values[0].get!int();
- // writeln("Age: ", age);
-
- writeln("config SDL:");
- writeln(sdl_root_conf.toSDLDocument());
-}
+auto conf = ConfigHub();
+auto sdl_root_configuration = conf.configSDLang("conf.sdl");
+auto sdl_root_document_make = conf.configSDLang("sisu_document_make");
#+END_SRC
** each file (loop) [+2] :loop:files:
@@ -412,10 +362,7 @@ debug(header_and_content) {
**** [#A] read doc header: metadata & make :doc:header:metadata:make:
#+NAME: sdp_each_file_do
#+BEGIN_SRC d
-// Tuple!(JSONValue[string], JSONValue[string]) header_make_and_meta_tuple;
-auto header_make_and_meta_tuple = (match(header, rgx.native_header_meta_title))
-? (head_native.headerContentJSON(header))
-: (headsdl.headerSDLangToJSON(header));
+auto header_make_and_meta_tuple = head.headerContentJSON(header);
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];
@@ -425,7 +372,7 @@ JSONValue[string] dochead_meta_json = header_make_and_meta_tuple[1];
#+NAME: sdp_each_file_do
#+BEGIN_SRC d
/+ ↓ process document, return abstraction as tuple +/
-auto t = abs.abstract_doc_source(sourcefile_content);
+auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_json, dochead_meta_json);
static assert(!isTypeTuple!(t));
auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex;
// static assert(!isIterable!(doc_ao_contents));
@@ -444,8 +391,8 @@ debug(checkdoc) { // checkbook & dumpdoc
doc_ao_contents,
doc_ao_bookindex_unordered_hashes,
doc_ao_biblio,
- // doc_ao_make_json,
- // doc_ao_metadata_json,
+ dochead_make_json,
+ dochead_meta_json,
fn_src,
opt_action_bool
);
@@ -674,3 +621,20 @@ democratizing_innovation.eric_von_hippel.sst
└── di_evh.png
#+END_SRC
+
+** check
+#+BEGIN_SRC text
+./.sisu ./_sisu ~/.sisu /etc/.sisu
+#+END_SRC
+
+#+BEGIN_SRC d
+// string[string] envVars = environment.toAA();
+// writeln(envVars);
+/+
+writefln(
+ "pwd: %s; home: %s",
+ environment["PWD"],
+ environment["HOME"]
+);
++/
+#+END_SRC
diff --git a/src/sdp.d b/src/sdp.d
index e19a21e..127a8ad 100755
--- a/src/sdp.d
+++ b/src/sdp.d
@@ -9,6 +9,8 @@ import
ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d
ao_defaults, // sdp/ao_defaults.d
ao_header_extract, // sdp/ao_header_extract.d
+ ao_header_extract_native, // sdp/ao_header_extract_native.d
+ ao_header_extract_sdlang, // sdp/ao_header_extract_sdlang.d
ao_read_config_files, // sdp/ao_read_config_files.d
ao_read_source_files, // sdp/ao_read_source_files.d
ao_output_debugs, // sdp/ao_output_debugs.d
@@ -18,9 +20,6 @@ import
// std.conv;
/+ sdlang http://sdlang.org +/
import sdlang; // sdlang.d
- // sdlang.parser, // sdlang/parser.d
- // sdlang.exceptions; // sdp/ao_ansi_colors.d
- // // std.conv;
/+ sdp sisu document parser +/
private import
std.getopt,
@@ -98,20 +97,18 @@ mixin CompileTimeInfo;
mixin RgxInit;
void main(string[] args) {
- mixin SiSUheaderSkel;
- mixin SiSUheaderExtractNative;
- mixin SiSUheaderExtractSDLang;
+ mixin SiSUheaderRegister;
+ mixin SiSUheaderExtractHub;
mixin SiSUbiblio;
mixin SiSUrgxInitFlags;
- mixin SiSUconfiguration;
+ mixin SiSUconfigSDLangHub;
mixin SiSUmarkupRaw;
mixin SiSUdocAbstraction;
mixin SiSUoutputDebugs;
mixin SiSUoutputHub;
mixin ScreenTxtColors;
auto raw = MarkupRaw();
- auto head_native = HeaderDocMetadataAndMakeNativeToJson();
- auto headsdl = HeaderExtractSDL();
+ auto head = HeaderDocMetadataAndMake();
auto abs = Abstraction();
auto dbg = SDPoutputDebugs();
auto output = SDPoutput();
@@ -208,34 +205,9 @@ void main(string[] args) {
arg_unrecognized ~= " " ~ arg;
}
}
- auto conf = Config();
- auto configuration = conf.readInConfigFile();
- /+ sdlang config +/
- Tag sdl_root_conf;
- try {
- sdl_root_conf = parseSource(configuration);
- }
- catch(SDLangParseException e) {
- stderr.writeln("SDLang problem with config.sdl content");
- // Error messages of the form:
- // myFile.sdl(5:28): Error: Invalid integer suffix.
- stderr.writeln(e.msg);
- }
- debug(sdlang) {
- // Value is a std.variant.Algebraic
- Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
- assert(output_dir_structure_by.type == typeid(string));
- writeln(output_dir_structure_by);
-
- // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0];
- // writeln("Name: ", person.attributes["name"][0].value);
- //
- // int age = person.tags["age"][0].values[0].get!int();
- // writeln("Age: ", age);
-
- writeln("config SDL:");
- writeln(sdl_root_conf.toSDLDocument());
- }
+ auto conf = ConfigHub();
+ auto sdl_root_configuration = conf.configSDLang("conf.sdl");
+ auto sdl_root_document_make = conf.configSDLang("sisu_document_make");
foreach(fn_src; fns_src) {
// foreach(fn_src; fns_src) {
if (!empty(fn_src)) {
@@ -270,15 +242,12 @@ void main(string[] args) {
writeln(header_and_content_tuple.length);
writeln(sourcefile_content[0]);
}
- // Tuple!(JSONValue[string], JSONValue[string]) header_make_and_meta_tuple;
- auto header_make_and_meta_tuple = (match(header, rgx.native_header_meta_title))
- ? (head_native.headerContentJSON(header))
- : (headsdl.headerSDLangToJSON(header));
+ auto header_make_and_meta_tuple = head.headerContentJSON(header);
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];
/+ ↓ process document, return abstraction as tuple +/
- auto t = abs.abstract_doc_source(sourcefile_content);
+ auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_json, dochead_meta_json);
static assert(!isTypeTuple!(t));
auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex;
// static assert(!isIterable!(doc_ao_contents));
@@ -291,8 +260,8 @@ void main(string[] args) {
doc_ao_contents,
doc_ao_bookindex_unordered_hashes,
doc_ao_biblio,
- // doc_ao_make_json,
- // doc_ao_metadata_json,
+ dochead_make_json,
+ dochead_meta_json,
fn_src,
opt_action_bool
);
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index aca4944..8c19bf3 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -120,8 +120,11 @@ template SiSUdocAbstraction() {
// mixin SiSUdocAbstractionFunctions;
/+ ↓ abstract marked up document +/
- auto abstract_doc_source(char[][] markup_sourcefile_content) {
-
+ auto abstract_doc_source(
+ char[][] markup_sourcefile_content,
+ JSONValue[string] dochead_make_json,
+ JSONValue[string] dochead_meta_json
+ ) {
/+ ↓ abstraction init +/
scope(success) {
}
@@ -338,24 +341,24 @@ template SiSUdocAbstraction() {
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading or para but neither flag nor line exists +/
- // if ((to!string(dochead_make_json["make"]["headings"]).length > 2)
- // && (type["make_headings"] == State.off)) {
- // /+ heading found +/
- // auto dochead_make_headings =
- // to!string(dochead_make_json["make"]["headings"]);
- // heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
- // }
+ if ((to!string(dochead_make_json["make"]["headings"]).length > 2)
+ && (type["make_headings"] == State.off)) {
+ /+ heading found +/
+ auto dochead_make_headings =
+ to!string(dochead_make_json["make"]["headings"]);
+ heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
+ }
if ((type["make_headings"] == State.on)
&& ((line_occur["para"] == State.off)
&& (line_occur["heading"] == State.off))
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading make set +/
- // heading_make_set(line, line_occur, heading_match_rgx, type);
+ heading_make_set(line, line_occur, heading_match_rgx, type);
}
if (matchFirst(line, rgx.heading)) {
/+ heading match +/
- heading_matched(line, line_occur, an_object, lv, collapsed_lev, type);
+ heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json);
} else if (line_occur["para"] == State.off) {
/+ para match +/
para_match(line, an_object, indent, bullet, type, line_occur);
@@ -1614,6 +1617,94 @@ template SiSUdocAbstraction() {
}
}
}
+ auto heading_found(
+ char[] line,
+ string dochead_make_headings,
+ ref string[string] heading_match_str,
+ ref Regex!(char)[string] heading_match_rgx,
+ ref int[string] type
+ ) {
+ if ((to!string(dochead_make_headings).length > 2)
+ && (type["make_headings"] == State.off)) {
+ /+ headings found +/
+ debug(headingsfound) {
+ writeln(dochead_make_headings);
+ }
+ auto make_headings_txt =
+ match(
+ to!string(dochead_make_headings),
+ rgx.within_quotes);
+ char[][] make_headings_spl =
+ split(
+ cast(char[]) make_headings_txt.captures[1],
+ rgx.make_heading_delimiter);
+ debug(headingsfound) {
+ writeln(make_headings_spl.length);
+ writeln(make_headings_spl);
+ }
+ switch (make_headings_spl.length) {
+ case 7 :
+ if (!empty(make_headings_spl[6])) {
+ heading_match_str["h_4"] =
+ "^(" ~ to!string(make_headings_spl[6]) ~ ")";
+ heading_match_rgx["h_4"] =
+ regex(heading_match_str["h_4"]);
+ }
+ goto case;
+ case 6 :
+ if (!empty(make_headings_spl[5])) {
+ heading_match_str["h_3"] =
+ "^(" ~ to!string(make_headings_spl[5]) ~ ")";
+ heading_match_rgx["h_3"] =
+ regex(heading_match_str["h_3"]);
+ }
+ goto case;
+ case 5 :
+ if (!empty(make_headings_spl[4])) {
+ heading_match_str["h_2"] =
+ "^(" ~ to!string(make_headings_spl[4]) ~ ")";
+ heading_match_rgx["h_2"] =
+ regex(heading_match_str["h_2"]);
+ }
+ goto case;
+ case 4 :
+ if (!empty(make_headings_spl[3])) {
+ heading_match_str["h_1"] =
+ "^(" ~ to!string(make_headings_spl[3]) ~ ")";
+ heading_match_rgx["h_1"] =
+ regex(heading_match_str["h_1"]);
+ }
+ goto case;
+ case 3 :
+ if (!empty(make_headings_spl[2])) {
+ heading_match_str["h_D"] =
+ "^(" ~ to!string(make_headings_spl[2]) ~ ")";
+ heading_match_rgx["h_D"] =
+ regex(heading_match_str["h_D"]);
+ }
+ goto case;
+ case 2 :
+ if (!empty(make_headings_spl[1])) {
+ heading_match_str["h_C"] =
+ "^(" ~ to!string(make_headings_spl[1]) ~ ")";
+ heading_match_rgx["h_C"] =
+ regex(heading_match_str["h_C"]);
+ }
+ goto case;
+ case 1 :
+ if (!empty(make_headings_spl[0])) {
+ heading_match_str["h_B"] =
+ "^(" ~ to!string(make_headings_spl[0]) ~ ")";
+ heading_match_rgx["h_B"] =
+ regex(heading_match_str["h_B"]);
+ }
+ break;
+ default:
+ break;
+ }
+ type["make_headings"] = State.on;
+ }
+ }
auto heading_make_set(
ref char[] line,
ref int[string] line_occur,
@@ -1676,8 +1767,8 @@ template SiSUdocAbstraction() {
ref string[string] an_object,
ref int[string] lv,
ref int[string] collapsed_lev,
- ref int[string] type
- // ref JSONValue[string] dochead_meta_json
+ ref int[string] type,
+ ref JSONValue[string] dochead_meta_json
) {
if (auto m = match(line, rgx.heading)) {
/+ heading match +/
@@ -1691,8 +1782,8 @@ template SiSUdocAbstraction() {
assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels
switch (an_object["lev"]) {
case "A":
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"]));
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"]));
+ an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"]));
+ an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"]));
collapsed_lev["h0"] = 1;
an_object["lev_collapsed_number"] =
to!string(collapsed_lev["h0"]);
diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d
index b6eeae1..48f61c9 100644
--- a/src/sdp/ao_defaults.d
+++ b/src/sdp/ao_defaults.d
@@ -2,7 +2,7 @@
defaults
ao_defaults.d
+/
-template SiSUheaderSkel() {
+template SiSUheaderRegister() {
auto header_make_jsonstr = `{
"make": {
"bold" : "",
diff --git a/src/sdp/ao_header_extract.d b/src/sdp/ao_header_extract.d
index c02bc7c..76c5a7d 100644
--- a/src/sdp/ao_header_extract.d
+++ b/src/sdp/ao_header_extract.d
@@ -1,1307 +1,25 @@
/+
- extract sdl header return sdl
-+/
-template SiSUheaderExtractSDLang() {
- private import
- std.regex;
- private import
- ao_rgx;
- struct HeaderExtractSDL {
- mixin RgxInit;
- auto rgx = Rgx();
- final private auto headerMakeSDLang(in string src_header) {
- scope(failure) {
- stderr.writefln(
- "%s\n%s\n%s:%s failed here:\n src_header: %s",
- __MODULE__, __FUNCTION__,
- __FILE__, __LINE__,
- src_header,
- );
- }
- Tag sdl_root_header;
- try {
- sdl_root_header = parseSource(src_header);
- }
- catch(SDLangParseException e) {
- stderr.writeln("SDLang problem with this document header:");
- stderr.writeln(src_header);
- // Error messages of the form:
- // myFile.sdl(5:28): Error: Invalid integer suffix.
- stderr.writeln(e.msg);
- }
- debug(sdlang) {
- writeln("header SDL:");
- writeln(sdl_root_header.toSDLDocument());
- }
- return sdl_root_header;
- }
- private auto headerSDLangToJSON(in char[] src_header) {
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- char[] header_clean;
- // TODO
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- header_clean ~= header_line ~ "\n";
- // writeln(header_line);
- }
- }
- /+ get sdlang tags +/
- auto header_sdlang=headerMakeSDLang(to!string(header_clean));
- debug(sdlang) {
- writeln("--------------");
- stdout.rawWrite( header_sdlang.toSDLDocument() );
- writeln("--------------");
- Value test = header_sdlang.tags["title"][0].values[0];
- assert(test == typeid(string));
- writeln(header_sdlang.maybe.tags["title"]);
- writeln(header_sdlang.maybe.tags["title"][0].maybe.attributes["subtitle"]);
- }
- /+ TODO separate modules? sdlang then json
- return header_sdlang;
- // then do json module?
- +/
- /+ TODO json next +/
- /+ TODO
- auto dochead_make = parseJSON(header_make_jsonstr).object;
- auto dochead_meta = parseJSON(header_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]);
- }
- +/
- /+ dochead +/
- string hm;
- string hs;
- /+ make +/
- auto dochead_make = parseJSON(header_make_jsonstr).object;
- if (!(header_sdlang.maybe.tags["make"].empty)) {
- hm = "make";
- hs = "bold";
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- /+ meta +/
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
- hm = "title";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- /+ TODO Title REQUIRED +/
- hs = "main";
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- } else {
- writeln("Required header metadata Title, missing");
- }
- hs = "sub";
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes["subtitle"][0].value);
- }
- // full title composite (main + sub)
- // hs = "full";
- // dochead_meta[hm][hs] = dochead_meta[hm]["main"] ~ dochead_meta[hm]["sub"];
- hs = "language";
- 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 =
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "creator";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- /+ Creator / Author REQUIRED +/
- /+ TODO
- - decide on representation for & deal with multiple authors;
- - author(s) full name;
- - author(s) surname & other parts
- +/
- hs = "author";
- 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 =
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "classify";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "dewey";
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "date";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "added_to_site";
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "identifier";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "isbn";
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "links";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- /+ TODO
- stuff to fix
- +/
- // hs = "link";
- // 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 =
- // to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- // }
- }
- hm = "notes";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "abstract";
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "original";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "language";
- 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 =
- 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 =
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "publisher";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "name";
- 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 =
- to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
- }
- }
- hm = "rights";
- if (!(header_sdlang.maybe.tags[hm].empty)) {
- hs = "copyright";
- 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 =
- 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 =
- 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 =
- 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 =
- 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;
- }
- private auto headerSDLangToHash(in char[] src_header) {
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- char[] header_clean;
- string[string] header_make;
- string[string][string] header_metadata;
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- header_clean ~= header_line ~ "\n";
- // writeln(header_line);
- }
- }
- /+ get sdlang tags +/
- auto header_sdlang=headerMakeSDLang(to!string(header_clean));
- Value test = header_sdlang.tags["title"][0].values[0];
- // assert(test == typeid(string));
- // writeln(header_sdlang.maybe.tags["title"]);
- // writeln(header_sdlang.maybe.tags["title"][0].attributes["subtitle"]);
- if (!(header_sdlang.maybe.tags["make"].empty)) {
- if (!(header_sdlang.tags["make"][0].maybe.attributes["bold"].empty)
- && (header_sdlang.tags["make"][0].attributes["bold"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["bold"][0].value);
- header_make["bold"] =
- to!string(header_sdlang.tags["make"][0].attributes["bold"][0].value);
- } else {
- header_make["bold"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["breaks"].empty)
- && (header_sdlang.tags["make"][0].attributes["breaks"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["breaks"][0].value);
- header_make["breaks"] =
- to!string(header_sdlang.tags["make"][0].attributes["breaks"][0].value);
- } else {
- header_make["breaks"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["cover_image"].empty)
- && (header_sdlang.tags["make"][0].attributes["cover_image"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["cover_image"][0].value);
- header_make["cover_image"] =
- to!string(header_sdlang.tags["make"][0].attributes["cover_image"][0].value);
- } else {
- header_make["cover_image"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["css"].empty)
- && (header_sdlang.tags["make"][0].attributes["css"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["css"][0].value);
- header_make["css"] =
- to!string(header_sdlang.tags["make"][0].attributes["css"][0].value);
- } else {
- header_make["css"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["emphasis"].empty)
- && (header_sdlang.tags["make"][0].attributes["emphasis"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["emphasis"][0].value);
- header_make["emphasis"] =
- to!string(header_sdlang.tags["make"][0].attributes["emphasis"][0].value);
- } else {
- header_make["emphasis"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["footer"].empty)
- && (header_sdlang.tags["make"][0].attributes["footer"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["footer"][0].value);
- header_make["footer"] =
- to!string(header_sdlang.tags["make"][0].attributes["footer"][0].value);
- } else {
- header_make["footer"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["headings"].empty)
- && (header_sdlang.tags["make"][0].attributes["headings"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["headings"][0].value);
- header_make["headings"] =
- to!string(header_sdlang.tags["make"][0].attributes["headings"][0].value);
- } else {
- header_make["headings"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["home_button_image"].empty)
- && (header_sdlang.tags["make"][0].attributes["home_button_image"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["home_button_image"][0].value);
- header_make["home_button_image"] =
- to!string(header_sdlang.tags["make"][0].attributes["home_button_image"][0].value);
- } else {
- header_make["home_button_image"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["home_button_text"].empty)
- && (header_sdlang.tags["make"][0].attributes["home_button_text"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["home_button_text"][0].value);
- header_make["home_button_text"] =
- to!string(header_sdlang.tags["make"][0].attributes["home_button_text"][0].value);
- } else {
- header_make["home_button_text"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["italics"].empty)
- && (header_sdlang.tags["make"][0].attributes["italics"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["italics"][0].value);
- header_make["italics"] =
- to!string(header_sdlang.tags["make"][0].attributes["italics"][0].value);
- } else {
- header_make["italics"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["num_top"].empty)
- && (header_sdlang.tags["make"][0].attributes["num_top"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["num_top"][0].value);
- header_make["num_top"] =
- to!string(header_sdlang.tags["make"][0].attributes["num_top"][0].value);
- } else {
- header_make["num_top"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["substitute"].empty)
- && (header_sdlang.tags["make"][0].attributes["substitute"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["substitute"][0].value);
- header_make["substitute"] =
- to!string(header_sdlang.tags["make"][0].attributes["substitute"][0].value);
- } else {
- header_make["substitute"] = "";
- }
- if (!(header_sdlang.tags["make"][0].maybe.attributes["texpdf_font"].empty)
- && (header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value.length > 1)) {
- writeln(header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value);
- header_make["texpdf_font"] =
- to!string(header_sdlang.tags["make"][0].attributes["texpdf_font"][0].value);
- } else {
- header_make["texpdf_font"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["title"].empty)) {
- /+ Title REQUIRED +/
- if (!(header_sdlang.tags["title"].empty)
- && (header_sdlang.tags["title"][0].values[0].length > 1)) {
- writeln(header_sdlang.tags["title"][0].values[0]);
- header_metadata["title"]["main"] =
- to!string(header_sdlang.tags["title"][0].values[0]);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["main"].empty)
- && (header_sdlang.tags["title"][0].attributes["main"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["main"][0].value);
- header_metadata["title"]["main"] =
- to!string(header_sdlang.tags["title"][0].attributes["main"][0].value);
- } else {
- writeln("Required header metadata Title, missing");
- header_metadata["title"]["main"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["sub"].empty)
- && (header_sdlang.tags["title"][0].attributes["sub"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["sub"][0].value);
- header_metadata["title"]["sub"] =
- to!string(header_sdlang.tags["title"][0].attributes["sub"][0].value);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["subtitle"].empty)
- && (header_sdlang.tags["title"][0].attributes["subtitle"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["subtitle"][0].value);
- header_metadata["title"]["sub"] =
- to!string(header_sdlang.tags["title"][0].attributes["subtitle"][0].value);
- } else {
- header_metadata["title"]["sub"] = "";
- }
- // full title composite (main + sub)
- header_metadata["title"]["full"] = header_metadata["title"]["main"] ~ header_metadata["title"]["sub"];
- if (!(header_sdlang.tags["title"][0].maybe.attributes["lang"].empty)
- && (header_sdlang.tags["title"][0].attributes["lang"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["lang"][0].value);
- header_metadata["title"]["language"] =
- to!string(header_sdlang.tags["title"][0].attributes["lang"][0].value);
- } else if (!(header_sdlang.tags["title"][0].maybe.attributes["language"].empty)
- && (header_sdlang.tags["title"][0].attributes["language"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["language"][0].value);
- header_metadata["title"]["language"] =
- to!string(header_sdlang.tags["title"][0].attributes["language"][0].value);
- } else {
- header_metadata["title"]["language"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["edition"].empty)
- && (header_sdlang.tags["title"][0].attributes["edition"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["edition"][0].value);
- header_metadata["title"]["edition"] =
- to!string(header_sdlang.tags["title"][0].attributes["edition"][0].value);
- } else {
- header_metadata["title"]["edition"] = "";
- }
- if (!(header_sdlang.tags["title"][0].maybe.attributes["note"].empty)
- && (header_sdlang.tags["title"][0].attributes["note"][0].value.length > 1)) {
- writeln(header_sdlang.tags["title"][0].attributes["note"][0].value);
- header_metadata["title"]["note"] =
- to!string(header_sdlang.tags["title"][0].attributes["note"][0].value);
- } else {
- header_metadata["title"]["note"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["creator"].empty)) {
- /+ Creator / Author REQUIRED +/
- /+ TODO
- - decide on representation for & deal with multiple authors;
- - author(s) full name;
- - author(s) surname & other parts
- +/
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["author"].empty)
- && (header_sdlang.tags["creator"][0].attributes["author"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["author"][0].value);
- header_metadata["creator"]["author"] =
- to!string(header_sdlang.tags["creator"][0].attributes["author"][0].value);
- } else {
- header_metadata["creator"]["author"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["author_email"].empty)
- && (header_sdlang.tags["creator"][0].attributes["author_email"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["author_email"][0].value);
- header_metadata["creator"]["author_email"] =
- to!string(header_sdlang.tags["creator"][0].attributes["author_email"][0].value);
- } else {
- header_metadata["creator"]["author_email"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["illustrator"].empty)
- && (header_sdlang.tags["creator"][0].attributes["illustrator"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["illustrator"][0].value);
- header_metadata["creator"][""] =
- to!string(header_sdlang.tags["creator"][0].attributes["illustrator"][0].value);
- } else {
- header_metadata["creator"]["illustrator"] = "";
- }
- if (!(header_sdlang.tags["creator"][0].maybe.attributes["translator"].empty)
- && (header_sdlang.tags["creator"][0].attributes["translator"][0].value.length > 1)) {
- writeln(header_sdlang.tags["creator"][0].attributes["translator"][0].value);
- header_metadata["creator"]["translator"] =
- to!string(header_sdlang.tags["creator"][0].attributes["translator"][0].value);
- } else {
- header_metadata["creator"][""] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["classify"].empty)) {
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["dewey"].empty)
- && (header_sdlang.tags["classify"][0].attributes["dewey"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["dewey"][0].value);
- header_metadata["classify"]["dewey"] =
- to!string(header_sdlang.tags["classify"][0].attributes["dewey"][0].value);
- } else {
- header_metadata["classify"]["dewey"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["keyword"].empty)
- && (header_sdlang.tags["classify"][0].attributes["keyword"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["keyword"][0].value);
- header_metadata["classify"]["keyword"] =
- to!string(header_sdlang.tags["classify"][0].attributes["keyword"][0].value);
- } else {
- header_metadata["classify"]["keyword"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["loc"].empty)
- && (header_sdlang.tags["classify"][0].attributes["loc"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["loc"][0].value);
- header_metadata["classify"]["loc"] =
- to!string(header_sdlang.tags["classify"][0].attributes["loc"][0].value);
- } else {
- header_metadata["classify"]["loc"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["subject"].empty)
- && (header_sdlang.tags["classify"][0].attributes["subject"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["subject"][0].value);
- header_metadata["classify"]["subject"] =
- to!string(header_sdlang.tags["classify"][0].attributes["subject"][0].value);
- } else {
- header_metadata["classify"]["subject"] = "";
- }
- if (!(header_sdlang.tags["classify"][0].maybe.attributes["topic_register"].empty)
- && (header_sdlang.tags["classify"][0].attributes["topic_register"][0].value.length > 1)) {
- writeln(header_sdlang.tags["classify"][0].attributes["topic_register"][0].value);
- header_metadata["classify"]["topic_register"] =
- to!string(header_sdlang.tags["classify"][0].attributes["topic_register"][0].value);
- } else {
- header_metadata["classify"]["topic_register"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["date"].empty)) {
- if (!(header_sdlang.tags["date"][0].maybe.attributes["added_to_site"].empty)
- && (header_sdlang.tags["date"][0].attributes["added_to_site"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["added_to_site"][0].value);
- header_metadata["date"]["added_to_site"] =
- to!string(header_sdlang.tags["date"][0].attributes["added_to_site"][0].value);
- } else {
- header_metadata["date"]["added_to_site"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["available"].empty)
- && (header_sdlang.tags["date"][0].attributes["available"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["available"][0].value);
- header_metadata["date"]["available"] =
- to!string(header_sdlang.tags["date"][0].attributes["available"][0].value);
- } else {
- header_metadata["date"]["available"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["created"].empty)
- && (header_sdlang.tags["date"][0].attributes["created"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["created"][0].value);
- header_metadata["date"]["created"] =
- to!string(header_sdlang.tags["date"][0].attributes["created"][0].value);
- } else {
- header_metadata["date"]["created"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["issued"].empty)
- && (header_sdlang.tags["date"][0].attributes["issued"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["issued"][0].value);
- header_metadata["date"]["issued"] =
- to!string(header_sdlang.tags["date"][0].attributes["issued"][0].value);
- } else {
- header_metadata["date"]["issued"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["modified"].empty)
- && (header_sdlang.tags["date"][0].attributes["modified"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["modified"][0].value);
- header_metadata["date"]["modified"] =
- to!string(header_sdlang.tags["date"][0].attributes["modified"][0].value);
- } else {
- header_metadata["date"]["modified"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["published"].empty)
- && (header_sdlang.tags["date"][0].attributes["published"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["published"][0].value);
- header_metadata["date"]["published"] =
- to!string(header_sdlang.tags["date"][0].attributes["published"][0].value);
- } else {
- header_metadata["date"]["published"] = "";
- }
- if (!(header_sdlang.tags["date"][0].maybe.attributes["valid"].empty)
- && (header_sdlang.tags["date"][0].attributes["valid"][0].value.length > 1)) {
- writeln(header_sdlang.tags["date"][0].attributes["valid"][0].value);
- header_metadata["date"]["valid"] =
- to!string(header_sdlang.tags["date"][0].attributes["valid"][0].value);
- } else {
- header_metadata["date"]["valid"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["identifier"].empty)) {
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["isbn"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["isbn"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["isbn"][0].value);
- header_metadata["identifier"]["isbn"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["isbn"][0].value);
- } else {
- header_metadata["identifier"]["isbn"] = "";
- }
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["oclc"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["oclc"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["oclc"][0].value);
- header_metadata["identifier"]["oclc"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["oclc"][0].value);
- } else {
- header_metadata["identifier"]["oclc"] = "";
- }
- if (!(header_sdlang.tags["identifier"][0].maybe.attributes["pg"].empty)
- && (header_sdlang.tags["identifier"][0].attributes["pg"][0].value.length > 1)) {
- writeln(header_sdlang.tags["identifier"][0].attributes["pg"][0].value);
- header_metadata["identifier"]["pg"] =
- to!string(header_sdlang.tags["identifier"][0].attributes["pg"][0].value);
- } else {
- header_metadata["identifier"]["pg"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["links"].empty)) {
- /+ TODO
- stuff to fix
- +/
- if (!(header_sdlang.tags["links"][0].maybe.attributes["link"].empty)
- && (header_sdlang.tags["links"][0].attributes["link"][0].value.length > 1)) {
- writeln(header_sdlang.tags["links"][0].attributes["link"][0].value);
- // header_metadata["links"]["list"] =
- // to!string(header_sdlang.tags["links"][0].attributes["link"][0].value);
- header_metadata["links"]["list"] = "";
- } else {
- header_metadata["links"]["list"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["notes"].empty)) {
- if (!(header_sdlang.tags["notes"][0].maybe.attributes["abstract"].empty)
- && (header_sdlang.tags["notes"][0].attributes["abstract"][0].value.length > 1)) {
- writeln(header_sdlang.tags["notes"][0].attributes["abstract"][0].value);
- header_metadata["notes"]["abstract"] =
- to!string(header_sdlang.tags["notes"][0].attributes["abstract"][0].value);
- } else {
- header_metadata["notes"]["abstract"] = "";
- }
- if (!(header_sdlang.tags["notes"][0].maybe.attributes["description"].empty)
- && (header_sdlang.tags["notes"][0].attributes["description"][0].value.length > 1)) {
- writeln(header_sdlang.tags["notes"][0].attributes["description"][0].value);
- header_metadata["notes"]["description"] =
- to!string(header_sdlang.tags["notes"][0].attributes["description"][0].value);
- } else {
- header_metadata["notes"]["description"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["original"].empty)) {
- if (!(header_sdlang.tags["original"][0].maybe.attributes["language"].empty)
- && (header_sdlang.tags["original"][0].attributes["language"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["language"][0].value);
- header_metadata["original"]["language"] =
- to!string(header_sdlang.tags["original"][0].attributes["language"][0].value);
- } else {
- header_metadata["original"]["language"] = "";
- }
- if (!(header_sdlang.tags["original"][0].maybe.attributes["source"].empty)
- && (header_sdlang.tags["original"][0].attributes["source"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["source"][0].value);
- header_metadata["original"]["source"] =
- to!string(header_sdlang.tags["original"][0].attributes["source"][0].value);
- } else {
- header_metadata["original"]["source"] = "";
- }
- if (!(header_sdlang.tags["original"][0].maybe.attributes["title"].empty)
- && (header_sdlang.tags["original"][0].attributes["title"][0].value.length > 1)) {
- writeln(header_sdlang.tags["original"][0].attributes["title"][0].value);
- header_metadata["original"]["title"] =
- to!string(header_sdlang.tags["original"][0].attributes["title"][0].value);
- } else {
- header_metadata["original"]["title"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["publisher"].empty)) {
- if (!(header_sdlang.tags["publisher"][0].maybe.attributes["name"].empty)
- && (header_sdlang.tags["publisher"][0].attributes["name"][0].value.length > 1)) {
- writeln(header_sdlang.tags["publisher"][0].attributes["name"][0].value);
- header_metadata["publisher"]["name"] =
- to!string(header_sdlang.tags["publisher"][0].attributes["name"][0].value);
- } else {
- header_metadata["publisher"]["name"] = "";
- }
- }
- if (!(header_sdlang.maybe.tags["rights"].empty)) {
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["copyright"].empty)
- && (header_sdlang.tags["rights"][0].attributes["copyright"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["copyright"][0].value);
- header_metadata["rights"]["copyright"] =
- to!string(header_sdlang.tags["rights"][0].attributes["copyright"][0].value);
- } else {
- header_metadata["rights"]["copyright"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["cover"].empty)
- && (header_sdlang.tags["rights"][0].attributes["cover"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["cover"][0].value);
- header_metadata["rights"]["cover"] =
- to!string(header_sdlang.tags["rights"][0].attributes["cover"][0].value);
- } else {
- header_metadata["rights"]["cover"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["illustrations"].empty)
- && (header_sdlang.tags["rights"][0].attributes["illustrations"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["illustrations"][0].value);
- header_metadata["rights"]["illustrations"] =
- to!string(header_sdlang.tags["rights"][0].attributes["illustrations"][0].value);
- } else {
- header_metadata["rights"]["illustrations"] = "";
- }
- if (!(header_sdlang.tags["rights"][0].maybe.attributes["license"].empty)
- && (header_sdlang.tags["rights"][0].attributes["license"][0].value.length > 1)) {
- writeln(header_sdlang.tags["rights"][0].attributes["license"][0].value);
- header_metadata["rights"]["license"] =
- to!string(header_sdlang.tags["rights"][0].attributes["license"][0].value);
- } else {
- header_metadata["rights"]["license"] = "";
- }
- }
- writeln("--------------");
- stdout.rawWrite( header_sdlang.toSDLDocument() );
- writeln("--------------");
- /+
- namespace:name values attributes {
- children
- }
- +/
- return header_sdlang;
- }
- private auto headerSDLang(in char[] src_header) {
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- char[] header_clean;
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- header_clean ~= header_line ~ "\n";
- // writeln(header_line);
- }
- }
- // writeln(header_clean); // consider
- auto header_sdlang=headerMakeSDLang(to!string(header_clean));
- return header_sdlang;
- }
-
- }
- struct HeaderUseSDL {
- mixin RgxInit;
- auto rgx = Rgx();
- // Tag = sdl_header;
- auto headerUseSDLang(T)(auto T sdl_root_header) {
- // T sdl_root_header;
- // auto headerUseSDLang(Tag sdl_root_header) {
- // private auto headerUseSDLang(Tag sdl_root_header) {
- // private auto headerUseSDLang(in Tag sdl_root_header) {
- // auto sdl_root_header = T;
-
- // Value is a std.variant.Algebraic
- Value test = sdl_root_header.tags["title"][0].values[0];
- // assert(test == typeid(string));
- writeln(test);
-
- return sdl_root_header;
- }
- }
-}
-/+
extract native/orig header return json
+/
-template SiSUheaderExtractNative() {
+template SiSUheaderExtractHub() {
private import
- std.exception,
- std.regex,
- std.utf,
- std.conv : to;
+ std.regex;
private import
ao_rgx;
- struct HeaderDocMetadataAndMakeNativeToJson {
- mixin SiSUrgxInitFlags;
- mixin RgxInit;
+ struct HeaderDocMetadataAndMake {
+ mixin SiSUheaderExtractNative;
+ mixin SiSUheaderExtractSDLang;
auto rgx = Rgx();
- enum State { off, on }
- string hm, hs;
- auto header_metadata_and_make_jsonstr(
- string header,
- JSONValue[string] dochead_meta,
- JSONValue[string] dochead_make
- )
- in { }
- body {
- scope(exit) {
- destroy(header);
- destroy(dochead_meta);
- destroy(dochead_make);
- }
- if (auto t = match(header, rgx.native_header_main)) {
- char[][] header_obj_spl = split(
- cast(char[]) header,
- rgx.line_delimiter_ws_strip
- );
- auto hm = to!string(t.captures[1]);
- if (match(hm, rgx.main_headers)) {
- foreach (line; header_obj_spl) {
- if (auto m = match(line, rgx.native_header_main)) {
- if (!empty(m.captures[2])) {
- if (hm == "creator") {
- dochead_meta[hm]["author"].str =
- to!string(m.captures[2]);
- } else if (hm == "title") {
- dochead_meta[hm]["main"].str =
- to!string(m.captures[2]);
- } else if (hm == "publisher") {
- dochead_meta[hm]["name"].str =
- 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].type() == JSON_TYPE.OBJECT)) {
- 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]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- default:
- break;
- }
- } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) {
- 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 =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- 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 =
- to!string(s.captures[2]);
- } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "rights":
- if (match(hs, rgx.native_subhead_rights)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "date":
- if (match(hs, rgx.native_subhead_date)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "original":
- if (match(hs, rgx.native_subhead_original)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "classify":
- if (match(hs, rgx.native_subhead_classify)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "identifier":
- if (match(hs, rgx.native_subhead_identifier)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "notes":
- if (match(hs, rgx.native_subhead_notes)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "publisher":
- if (match(hs, rgx.native_subhead_publisher)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- 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);
- // 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]);
- // }
- // } else {
- // writeln("not a valid header type:", hm, ":", hs);
- // destroy(hm);
- // destroy(hs);
- // }
- break;
- default:
- break;
- }
- }
- }
- }
- }
- } else {
- writeln("not a valid header type:", hm);
- }
- }
- auto t = tuple(dochead_meta, dochead_make);
- static assert(!isTypeTuple!(t));
- return t;
- }
- private auto native_header_extract(
- char[] line,
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
- ) {
- if (matchFirst(line, 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["obj"] ~= line ~= "\n";
- } else if (matchFirst(line, 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["obj"] ~= line ~= "\n";
- } else if (type["header_make"] == State.on
- && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/
- if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
- debug(header1) { /+ writeln(line); +/ }
- ++line_occur["header_make"];
- an_object["obj"] ~= line ~= "\n";
- }
- } else if (type["header_meta"] == State.on
- && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/
- if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
- debug(header1) { /+ writeln(line); +/ }
- ++line_occur["header_meta"];
- an_object["obj"] ~= line ~= "\n";
- }
- }
- return an_object;
- }
- auto header_reset_states_common(
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
- ) {
- // line_occur["header"] = State.off;
- line_occur["header_make"] = State.off;
- line_occur["header_meta"] = State.off;
- type["header"] = State.off;
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- an_object.remove("obj");
- an_object.remove("is");
- an_object.remove("attrib");
- }
- private auto headerContentJSON(in char[] src_header) {
- 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 = parseJSON(header_make_jsonstr).object;
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
- auto set_header = HeaderDocMetadataAndMakeNativeToJson();
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- foreach(header_line; source_header_arr) {
- if (auto m = matchFirst(header_line, rgx.comment)) {
- /+ matched comment +/
- debug(comment) {
- // tell_l("blue", header_line);
- }
- header_reset_states_common(line_occur, an_object, type);
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- } else if ((matchFirst(header_line, 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_jsonstr(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];
- header_reset_states_common(line_occur, an_object, type);
- type["header_make"] = State.off;
- type["header_meta"] = State.off;
- writeln(dochead_metadata_and_make);
- } else {
- an_object = native_header_extract(header_line, line_occur, an_object, type);
- }
- } else {
- // writeln(__LINE__);
- }
- }
- auto t = tuple(
- dochead_make,
- dochead_meta,
- );
- return t;
+ private auto headerContentJSON(char[] header_src) {
+ auto head_native = HeaderDocMetadataAndMakeNativeToJson();
+ 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));
+ writeln(__LINE__);
+ static assert(!isTypeTuple!(header_make_and_meta_tuple));
+ return header_make_and_meta_tuple;
}
}
}
diff --git a/src/sdp/ao_header_extract_native.d b/src/sdp/ao_header_extract_native.d
new file mode 100644
index 0000000..49555ef
--- /dev/null
+++ b/src/sdp/ao_header_extract_native.d
@@ -0,0 +1,320 @@
+/+
+ extract native/orig header return json
++/
+template SiSUheaderExtractNative() {
+ private import
+ std.exception,
+ std.regex,
+ std.utf,
+ std.conv : to;
+ private import
+ ao_rgx;
+ struct HeaderDocMetadataAndMakeNativeToJson {
+ mixin SiSUheaderRegister;
+ mixin SiSUrgxInitFlags;
+ mixin RgxInit;
+ auto rgx = Rgx();
+ enum State { off, on }
+ string hm, hs;
+ auto header_metadata_and_make_jsonstr(
+ string header,
+ JSONValue[string] dochead_meta,
+ JSONValue[string] dochead_make
+ )
+ in { }
+ body {
+ scope(exit) {
+ destroy(header);
+ destroy(dochead_meta);
+ destroy(dochead_make);
+ }
+ if (auto t = match(header, rgx.native_header_main)) {
+ char[][] header_obj_spl = split(
+ cast(char[]) header,
+ rgx.line_delimiter_ws_strip
+ );
+ auto hm = to!string(t.captures[1]);
+ if (match(hm, rgx.main_headers)) {
+ foreach (line; header_obj_spl) {
+ if (auto m = match(line, rgx.native_header_main)) {
+ if (!empty(m.captures[2])) {
+ if (hm == "creator") {
+ dochead_meta[hm]["author"].str =
+ to!string(m.captures[2]);
+ } else if (hm == "title") {
+ dochead_meta[hm]["main"].str =
+ to!string(m.captures[2]);
+ } else if (hm == "publisher") {
+ dochead_meta[hm]["name"].str =
+ 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].type() == JSON_TYPE.OBJECT)) {
+ 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]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ default:
+ break;
+ }
+ } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) {
+ 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 =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ 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 =
+ to!string(s.captures[2]);
+ } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "rights":
+ if (match(hs, rgx.native_subhead_rights)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "date":
+ if (match(hs, rgx.native_subhead_date)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "original":
+ if (match(hs, rgx.native_subhead_original)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "classify":
+ if (match(hs, rgx.native_subhead_classify)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "identifier":
+ if (match(hs, rgx.native_subhead_identifier)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "notes":
+ if (match(hs, rgx.native_subhead_notes)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ to!string(s.captures[2]);
+ }
+ } else {
+ writeln("not a valid header type:", hm, ":", hs);
+ destroy(hm);
+ destroy(hs);
+ }
+ break;
+ case "publisher":
+ if (match(hs, rgx.native_subhead_publisher)) {
+ if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
+ dochead_meta[hm][hs].str =
+ 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);
+ // 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]);
+ // }
+ // } else {
+ // writeln("not a valid header type:", hm, ":", hs);
+ // destroy(hm);
+ // destroy(hs);
+ // }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ writeln("not a valid header type:", hm);
+ }
+ }
+ auto t = tuple(dochead_meta, dochead_make);
+ static assert(!isTypeTuple!(t));
+ return t;
+ }
+ private auto native_header_extract(
+ char[] line,
+ ref int[string] line_occur,
+ ref string[string] an_object,
+ ref int[string] type
+ ) {
+ if (matchFirst(line, 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["obj"] ~= line ~= "\n";
+ } else if (matchFirst(line, 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["obj"] ~= line ~= "\n";
+ } else if (type["header_make"] == State.on
+ && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/
+ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
+ debug(header1) { /+ writeln(line); +/ }
+ ++line_occur["header_make"];
+ an_object["obj"] ~= line ~= "\n";
+ }
+ } else if (type["header_meta"] == State.on
+ && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/
+ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/
+ debug(header1) { /+ writeln(line); +/ }
+ ++line_occur["header_meta"];
+ an_object["obj"] ~= line ~= "\n";
+ }
+ }
+ return an_object;
+ }
+ auto header_reset_states_common(
+ ref int[string] line_occur,
+ ref string[string] an_object,
+ ref int[string] type
+ ) {
+ // line_occur["header"] = State.off;
+ line_occur["header_make"] = State.off;
+ line_occur["header_meta"] = State.off;
+ type["header"] = State.off;
+ // type["header_make"] = State.off;
+ // type["header_meta"] = State.off;
+ an_object.remove("obj");
+ an_object.remove("is");
+ an_object.remove("attrib");
+ }
+ private auto headerNativeToJSON(in char[] src_header) {
+ 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 = parseJSON(header_make_jsonstr).object;
+ auto dochead_meta = parseJSON(header_meta_jsonstr).object;
+ auto set_header = HeaderDocMetadataAndMakeNativeToJson();
+ char[][] source_header_arr =
+ split(cast(char[]) src_header, rgx.line_delimiter);
+ foreach(header_line; source_header_arr) {
+ if (auto m = matchFirst(header_line, rgx.comment)) {
+ /+ matched comment +/
+ debug(comment) {
+ // tell_l("blue", header_line);
+ }
+ header_reset_states_common(line_occur, an_object, type);
+ // type["header_make"] = State.off;
+ // type["header_meta"] = State.off;
+ } else if ((matchFirst(header_line, 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_jsonstr(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];
+ header_reset_states_common(line_occur, an_object, type);
+ type["header_make"] = State.off;
+ type["header_meta"] = State.off;
+ writeln(dochead_metadata_and_make);
+ } else {
+ an_object = native_header_extract(header_line, line_occur, an_object, type);
+ }
+ } else {
+ // writeln(__LINE__);
+ }
+ }
+ auto t = tuple(
+ dochead_make,
+ dochead_meta,
+ );
+ return t;
+ }
+ }
+}
diff --git a/src/sdp/ao_header_extract_sdlang.d b/src/sdp/ao_header_extract_sdlang.d
new file mode 100644
index 0000000..a175b4f
--- /dev/null
+++ b/src/sdp/ao_header_extract_sdlang.d
@@ -0,0 +1,516 @@
+/+
+ extract sdl header return sdl
++/
+template SiSUheaderExtractSDLang() {
+ private import
+ std.regex;
+ private import
+ ao_rgx;
+ struct HeaderExtractSDL {
+ mixin SiSUheaderRegister;
+ mixin RgxInit;
+ auto rgx = Rgx();
+ final private auto headerMakeSDLang(in string src_header) {
+ scope(failure) {
+ stderr.writefln(
+ "%s\n%s\n%s:%s failed here:\n src_header: %s",
+ __MODULE__, __FUNCTION__,
+ __FILE__, __LINE__,
+ src_header,
+ );
+ }
+ Tag sdl_root_header;
+ try {
+ sdl_root_header = parseSource(src_header);
+ }
+ catch(SDLangParseException e) {
+ stderr.writeln("SDLang problem with this document header:");
+ stderr.writeln(src_header);
+ // Error messages of the form:
+ // myFile.sdl(5:28): Error: Invalid integer suffix.
+ stderr.writeln(e.msg);
+ }
+ debug(sdlang) {
+ writeln("header SDL:");
+ writeln(sdl_root_header.toSDLDocument());
+ }
+ return sdl_root_header;
+ }
+ private auto headerSDLangGet(in char[] src_header) {
+ char[][] source_header_arr =
+ split(cast(char[]) src_header, rgx.line_delimiter);
+ char[] header_clean;
+ // TODO
+ foreach(header_line; source_header_arr) {
+ if (!match(header_line, rgx.comments)) {
+ header_clean ~= header_line ~ "\n";
+ // writeln(header_line);
+ }
+ }
+ /+ get sdlang tags +/
+ auto header_sdlang=headerMakeSDLang(to!string(header_clean));
+ debug(sdlang) {
+ writeln("--------------");
+ stdout.rawWrite( header_sdlang.toSDLDocument() );
+ writeln("--------------");
+ Value test = header_sdlang.tags["title"][0].values[0];
+ assert(test == typeid(string));
+ writeln(header_sdlang.maybe.tags["title"]);
+ writeln(header_sdlang.maybe.tags["title"][0].maybe.attributes["subtitle"]);
+ }
+ return header_sdlang; // sdlang.ast.Tag
+ }
+ private auto headerSDLangToJSONmake(Tag header_sdlang) {
+ /+ TODO json next +/
+ /+ TODO
+ auto dochead_make = parseJSON(header_make_jsonstr).object;
+ auto dochead_meta = parseJSON(header_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]);
+ }
+ +/
+ /+ dochead +/
+ string hm;
+ string hs;
+ /+ make +/
+ auto dochead_make = parseJSON(header_make_jsonstr).object;
+ if (!(header_sdlang.maybe.tags["make"].empty)) {
+ hm = "make";
+ hs = "bold";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ /+ meta +/
+ auto dochead_meta = parseJSON(header_meta_jsonstr).object;
+ hm = "title";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ /+ TODO Title REQUIRED +/
+ hs = "main";
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ } else {
+ writeln("Required header metadata Title, missing");
+ }
+ hs = "sub";
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes["subtitle"][0].value);
+ }
+ // full title composite (main + sub)
+ // hs = "full";
+ // dochead_meta[hm][hs] = dochead_meta[hm]["main"] ~ dochead_meta[hm]["sub"];
+ hs = "language";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "creator";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ /+ Creator / Author REQUIRED +/
+ /+ TODO
+ - decide on representation for & deal with multiple authors;
+ - author(s) full name;
+ - author(s) surname & other parts
+ +/
+ hs = "author";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "classify";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "dewey";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "date";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "added_to_site";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "identifier";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "isbn";
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "links";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ /+ TODO
+ stuff to fix
+ +/
+ // hs = "link";
+ // 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 =
+ // to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ // }
+ }
+ hm = "notes";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "abstract";
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "original";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "language";
+ 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 =
+ 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 =
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "publisher";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "name";
+ 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 =
+ to!string(header_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ hm = "rights";
+ if (!(header_sdlang.maybe.tags[hm].empty)) {
+ hs = "copyright";
+ 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 =
+ 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 =
+ 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 =
+ 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 =
+ 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;
+ }
+ private auto headerSDLangToJSON(char[] header_sdlang_src) {
+ auto header_sdlang_tag = headerSDLangGet(header_sdlang_src); // sdlang.ast.Tag
+ auto header_json_tuple = headerSDLangToJSONmake(header_sdlang_tag);
+ return header_json_tuple;
+ }
+
+ }
+ struct HeaderUseSDL {
+ mixin RgxInit;
+ auto rgx = Rgx();
+ // Tag = sdl_header;
+ auto headerUseSDLang(T)(auto T sdl_root_header) {
+ // T sdl_root_header;
+ // auto headerUseSDLang(Tag sdl_root_header) {
+ // private auto headerUseSDLang(Tag sdl_root_header) {
+ // private auto headerUseSDLang(in Tag sdl_root_header) {
+ // auto sdl_root_header = T;
+
+ // Value is a std.variant.Algebraic
+ Value test = sdl_root_header.tags["title"][0].values[0];
+ // assert(test == typeid(string));
+ writeln(test);
+
+ return sdl_root_header;
+ }
+ }
+}
diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d
index 525ebcc..68a2d40 100644
--- a/src/sdp/ao_output_debugs.d
+++ b/src/sdp/ao_output_debugs.d
@@ -8,8 +8,8 @@ template SiSUoutputDebugs() {
auto ref const S contents,
string[][string][string] bookindex_unordered_hashes,
JSONValue[] biblio,
- // JSONValue[string] dochead_make,
- // JSONValue[string] dochead_meta,
+ JSONValue[string] dochead_make,
+ JSONValue[string] dochead_meta,
string fn_src,
bool[string] opt_action_bool
) {
@@ -76,6 +76,154 @@ template SiSUoutputDebugs() {
}
}
}
+ debug(headermakejson) {
+ writefln(
+ "%s\n%s\n%s",
+ "document header, metadata & make instructions:",
+ dochead_meta,
+ pointer_head_main,
+ );
+ foreach (main_header; pointer_head_main) {
+ switch (main_header) {
+ case "make":
+ foreach (sub_header; pointer_head_sub_make) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ debug(headermetadatajson) {
+ writefln(
+ "%s\n%s\n%s",
+ "document header, metadata & make instructions:",
+ dochead_meta,
+ pointer_head_main,
+ );
+ foreach (main_header; pointer_head_main) {
+ switch (main_header) {
+ case "creator":
+ foreach (sub_header; pointer_head_sub_creator) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "title":
+ foreach (sub_header; pointer_head_sub_title) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "rights":
+ foreach (sub_header; pointer_head_sub_rights) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "date":
+ foreach (sub_header; pointer_head_sub_date) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "original":
+ foreach (sub_header; pointer_head_sub_original) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "classify":
+ foreach (sub_header; pointer_head_sub_classify) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "identifier":
+ foreach (sub_header; pointer_head_sub_identifier) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "notes":
+ foreach (sub_header; pointer_head_sub_notes) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ case "publisher":
+ foreach (sub_header; pointer_head_sub_publisher) {
+ if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
+ writefln(
+ "%s:%s: %s",
+ main_header,
+ sub_header,
+ dochead_meta[main_header][sub_header]
+ );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
debug(bookindex) {
writefln(
"%s\n%s:%s",
@@ -138,10 +286,12 @@ template SiSUoutputDebugs() {
if (auto mfn=match(fn_src, rgx.src_fn)) {
if (opt_action_bool["assertions"]) {
switch (mfn.captures[2]) {
+ // live manual:
case "live-manual.ssm":
assert(check["last_obj_cite_number"] ==
"1019","last obj_cite_number should be: 1019 (check test, document is frequently updated)"); // ok
break;
+ // sisu_markup:
case "sisu_markup.sst":
assert(check["last_obj_cite_number"] ==
"297","last obj_cite_number expected to be: 297 rather than " ~ check["last_obj_cite_number"]); // ok
diff --git a/src/sdp/ao_read_config_files.d b/src/sdp/ao_read_config_files.d
index 47980da..e53c656 100644
--- a/src/sdp/ao_read_config_files.d
+++ b/src/sdp/ao_read_config_files.d
@@ -2,7 +2,7 @@
ao_config_files.d
- read config files
+/
-template SiSUconfiguration() {
+template SiSUconfigIn() {
private import
std.exception,
// std.regex,
@@ -14,9 +14,9 @@ template SiSUconfiguration() {
// mixin RgxInit;
// auto rgx = Rgx();
private
- struct Config {
+ struct ConfigIn {
private import std.file;
- final private string readInConfigFile() {
+ final private string readInConfigFile(string conf_sdl) {
// enforce(
// exists(fn_src)!=0,
// "file not found"
@@ -27,7 +27,6 @@ template SiSUconfiguration() {
environment["HOME"] ~ "/.sisu",
"/etc/sisu"
];
- string conf_sdl = "conf.sdl";
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = format(
@@ -69,3 +68,52 @@ template SiSUconfiguration() {
}
}
}
+/+
+
++/
+template SiSUconfigSDLang() {
+ struct ConfigSDLangRootTag {
+ private auto configSDLangRootTag(string configuration, string conf_sdl_filename) {
+ Tag sdl_root_conf;
+ try {
+ sdl_root_conf = parseSource(configuration);
+ }
+ catch(SDLangParseException e) {
+ stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
+ // Error messages of the form:
+ // myFile.sdl(5:28): Error: Invalid integer suffix.
+ stderr.writeln(e.msg);
+ }
+ debug(sdlang) {
+ // Value is a std.variant.Algebraic
+ Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
+ assert(output_dir_structure_by.type == typeid(string));
+ writeln(output_dir_structure_by);
+ // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0];
+ // writeln("Name: ", person.attributes["name"][0].value);
+ //
+ // int age = person.tags["age"][0].values[0].get!int();
+ // writeln("Age: ", age);
+ writeln("conf SDL:");
+ writeln(sdl_root_conf.toSDLDocument());
+ }
+ return sdl_root_conf;
+ }
+ }
+}
+/+
+
++/
+template SiSUconfigSDLangHub() {
+ mixin SiSUconfigIn;
+ mixin SiSUconfigSDLang;
+ struct ConfigHub {
+ final private auto configSDLang(string conf_sdl) {
+ auto conf_get = ConfigIn();
+ auto configuration = conf_get.readInConfigFile(conf_sdl);
+ auto conf = ConfigSDLangRootTag();
+ auto sdl_root = conf.configSDLangRootTag(configuration, conf_sdl);
+ return sdl_root;
+ }
+ }
+}
diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d
index 4d766b2..06c5f41 100644
--- a/src/sdp/ao_read_source_files.d
+++ b/src/sdp/ao_read_source_files.d
@@ -233,6 +233,13 @@ template SiSUmarkupRaw() {
auto fn_src_insert =
to!string(markup_src_file_path ~ insert_sub_pth ~ insert_fn);
auto raw = MarkupRawUnit();
+ /+ TODO +/
+ if (auto ma = match(line, rgx.src_fn_text)) {
+ /+ .sst when inserted, not used: headers and heading level ^:?A~ so remove +/
+ writeln(__LINE__); writeln(ma);
+ // auto t =
+ // raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth);
+ }
auto markup_sourcefile_insert_content =
raw.markupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts);
debug(insert) { // insert file
diff --git a/views/version.txt b/views/version.txt
index b050377..9f95c23 100644
--- a/views/version.txt
+++ b/views/version.txt
@@ -4,4 +4,4 @@ struct Version {
int minor;
int patch;
}
-enum ver = Version(0, 5, 1);
+enum ver = Version(0, 6, 0);