aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-06-27 01:30:24 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-04 14:48:18 -0400
commitd7ed4f0aa862615fbba630ac278ae21b1b96e812 (patch)
treee6cf893339601cc253afd98a1cd2e664b0e2c38f /org
parentstep6 headers (&config), native & sdlang to json internally (diff)
registers, minor cleaning
Diffstat (limited to 'org')
-rw-r--r--org/ao_defaults.org6
-rw-r--r--org/ao_header_extract.org170
-rw-r--r--org/sdp.org7
3 files changed, 145 insertions, 38 deletions
diff --git a/org/ao_defaults.org b/org/ao_defaults.org
index 00fe102..ec007b0 100644
--- a/org/ao_defaults.org
+++ b/org/ao_defaults.org
@@ -19,8 +19,8 @@
** template: header :header:
#+name: ao_defaults_templates
#+BEGIN_SRC d
-template SiSUheaderRegister() {
- auto header_make_jsonstr = `{
+template SiSUregisters() {
+ string make_jsonstr = `{
"make": {
"bold" : "",
"breaks" : "",
@@ -37,7 +37,7 @@ template SiSUheaderRegister() {
"texpdf_font" : ""
}
}`;
- auto header_meta_jsonstr = `{
+ auto meta_jsonstr = `{
"classify": {
"dewey" : "",
"keywords" : "",
diff --git a/org/ao_header_extract.org b/org/ao_header_extract.org
index 586a0ff..a0b87d4 100644
--- a/org/ao_header_extract.org
+++ b/org/ao_header_extract.org
@@ -13,6 +13,130 @@
#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n)
[[./sdp.org][sdp]] [[./][org/]]
+* conf make sdlang
+
+#+name: ao_header_extract_sdl
+#+BEGIN_SRC d
+private auto documentMakeSDLangToJSONmake(Tag document_make_sdlang) {
+ /+ dochead +/
+ string hm;
+ string hs;
+ /+ make +/
+ auto dochead_make = parseJSON(make_jsonstr).object;
+ if (!(document_make_sdlang.maybe.tags["make"].empty)) {
+ hm = "make";
+ hs = "bold";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "breaks";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "cover_image";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "css";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "emphasis";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "footer";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "headings";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "home_button_image";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "home_button_text";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "italics";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "num_top";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "substitute";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ hs = "texpdf_font";
+ if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ dochead_make[hm][hs].str =
+ to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ }
+ }
+ /+
+ hm = "links";
+ if (!(document_make_sdlang.maybe.tags[hm].empty)) {
+ /+ TODO
+ stuff to fix
+ +/
+ // hs = "link";
+ // if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty)
+ // && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) {
+ // writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ // dochead_meta[hm][hs].str =
+ // to!string(document_make_sdlang.tags[hm][0].attributes[hs][0].value);
+ // }
+ }
+ +/
+ // writeln(dochead_make);
+ return dochead_make;
+}
+#+END_SRC
+
* header native :header:native:
// mixin SiSUheader;
@@ -297,8 +421,8 @@ private auto headerNativeToJSON(in char[] src_header) {
];
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 dochead_make = parseJSON(make_jsonstr).object;
+ auto dochead_meta = parseJSON(meta_jsonstr).object;
auto set_header = HeaderDocMetadataAndMakeNativeToJson();
char[][] source_header_arr =
split(cast(char[]) src_header, rgx.line_delimiter);
@@ -405,15 +529,15 @@ private auto headerSDLangGet(in char[] src_header) {
}
#+END_SRC
-** sdlang header to json make :sdlang:json:
+** sdlang header to json make sdlTag in :sdlang:json:
#+name: ao_header_extract_sdl
#+BEGIN_SRC d
-private auto headerSDLangToJSONmake(Tag header_sdlang) {
+private auto headerSDLangToJSONmake(Tag header_sdlang, JSONValue[string] dochead_make) {
/+ TODO json next +/
/+ TODO
- auto dochead_make = parseJSON(header_make_jsonstr).object;
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
+ auto dochead_make = parseJSON(make_jsonstr).object;
+ auto dochead_meta = parseJSON(meta_jsonstr).object;
auto hm = to!string(t.captures[1]);
auto hs = to!string(s.captures[1]);
if (dochead_make[hm][hs].type() == JSON_TYPE.STRING) {
@@ -427,7 +551,6 @@ private auto headerSDLangToJSONmake(Tag header_sdlang) {
string hm;
string hs;
/+ make +/
- auto dochead_make = parseJSON(header_make_jsonstr).object;
if (!(header_sdlang.maybe.tags["make"].empty)) {
hm = "make";
hs = "bold";
@@ -523,7 +646,7 @@ private auto headerSDLangToJSONmake(Tag header_sdlang) {
}
}
/+ meta +/
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
+ auto dochead_meta = parseJSON(meta_jsonstr).object;
hm = "title";
if (!(header_sdlang.maybe.tags[hm].empty)) {
/+ TODO Title REQUIRED +/
@@ -842,9 +965,9 @@ private auto headerSDLangToJSONmake(Tag header_sdlang) {
#+name: ao_header_extract_sdl
#+BEGIN_SRC d
-private auto headerSDLangToJSON(char[] header_sdlang_src) {
+private auto headerSDLangToJSON(char[] header_sdlang_src, JSONValue[string] conf_doc_make_json) {
auto header_sdlang_tag = headerSDLangGet(header_sdlang_src); // sdlang.ast.Tag
- auto header_json_tuple = headerSDLangToJSONmake(header_sdlang_tag);
+ auto header_json_tuple = headerSDLangToJSONmake(header_sdlang_tag, conf_doc_make_json);
return header_json_tuple;
}
#+END_SRC
@@ -872,13 +995,13 @@ template SiSUheaderExtractHub() {
mixin SiSUheaderExtractNative;
mixin SiSUheaderExtractSDLang;
auto rgx = Rgx();
- private auto headerContentJSON(char[] header_src) {
+ private auto headerContentJSON(char[] header_src, JSONValue[string] conf_doc_make_json) {
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));
+ : (head_sdlang.headerSDLangToJSON(header_src, conf_doc_make_json));
writeln(__LINE__);
static assert(!isTypeTuple!(header_make_and_meta_tuple));
return header_make_and_meta_tuple;
@@ -903,7 +1026,7 @@ template SiSUheaderExtractNative() {
private import
ao_rgx;
struct HeaderDocMetadataAndMakeNativeToJson {
- mixin SiSUheaderRegister;
+ mixin SiSUregisters;
mixin SiSUrgxInitFlags;
mixin RgxInit;
auto rgx = Rgx();
@@ -926,30 +1049,11 @@ template SiSUheaderExtractSDLang() {
private import
ao_rgx;
struct HeaderExtractSDL {
- mixin SiSUheaderRegister;
+ mixin SiSUregisters;
mixin RgxInit;
auto rgx = Rgx();
<<ao_header_extract_sdl>>
<<ao_header_extract_sdl_to_json>>
}
- 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;
- }
- }
}
#+END_SRC
diff --git a/org/sdp.org b/org/sdp.org
index 89cd588..014cb0c 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -173,8 +173,9 @@ mixin(import("version.txt"));
#+NAME: sdp_args
#+BEGIN_SRC d
-mixin SiSUheaderRegister;
+mixin SiSUregisters;
mixin SiSUheaderExtractHub;
+mixin SiSUheaderExtractSDLang;
mixin SiSUbiblio;
mixin SiSUrgxInitFlags;
mixin SiSUconfigSDLangHub;
@@ -312,6 +313,8 @@ foreach(arg; args) {
auto conf = ConfigHub();
auto sdl_root_configuration = conf.configSDLang("conf.sdl");
auto sdl_root_document_make = conf.configSDLang("sisu_document_make");
+auto confsdl = HeaderExtractSDL();
+auto conf_doc_make_json = confsdl.documentMakeSDLangToJSONmake(sdl_root_document_make);
#+END_SRC
** each file (loop) [+2] :loop:files:
@@ -362,7 +365,7 @@ debug(header_and_content) {
**** [#A] read doc header: metadata & make :doc:header:metadata:make:
#+NAME: sdp_each_file_do
#+BEGIN_SRC d
-auto header_make_and_meta_tuple = head.headerContentJSON(header);
+auto header_make_and_meta_tuple = head.headerContentJSON(header, conf_doc_make_json);
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];