diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-06-27 01:30:24 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-04 14:48:18 -0400 |
commit | d7ed4f0aa862615fbba630ac278ae21b1b96e812 (patch) | |
tree | e6cf893339601cc253afd98a1cd2e664b0e2c38f /src | |
parent | step6 headers (&config), native & sdlang to json internally (diff) |
registers, minor cleaning
Diffstat (limited to 'src')
-rwxr-xr-x | src/sdp.d | 7 | ||||
-rw-r--r-- | src/sdp/ao_defaults.d | 6 | ||||
-rw-r--r-- | src/sdp/ao_header_extract.d | 4 | ||||
-rw-r--r-- | src/sdp/ao_header_extract_native.d | 6 | ||||
-rw-r--r-- | src/sdp/ao_header_extract_sdlang.d | 152 |
5 files changed, 138 insertions, 37 deletions
@@ -97,8 +97,9 @@ mixin CompileTimeInfo; mixin RgxInit; void main(string[] args) { - mixin SiSUheaderRegister; + mixin SiSUregisters; mixin SiSUheaderExtractHub; + mixin SiSUheaderExtractSDLang; mixin SiSUbiblio; mixin SiSUrgxInitFlags; mixin SiSUconfigSDLangHub; @@ -208,6 +209,8 @@ void main(string[] 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); foreach(fn_src; fns_src) { // foreach(fn_src; fns_src) { if (!empty(fn_src)) { @@ -242,7 +245,7 @@ void main(string[] args) { writeln(header_and_content_tuple.length); writeln(sourcefile_content[0]); } - 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]; diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d index 48f61c9..dda08f7 100644 --- a/src/sdp/ao_defaults.d +++ b/src/sdp/ao_defaults.d @@ -2,8 +2,8 @@ defaults ao_defaults.d +/ -template SiSUheaderRegister() { - auto header_make_jsonstr = `{ +template SiSUregisters() { + string make_jsonstr = `{ "make": { "bold" : "", "breaks" : "", @@ -20,7 +20,7 @@ template SiSUheaderRegister() { "texpdf_font" : "" } }`; - auto header_meta_jsonstr = `{ + auto meta_jsonstr = `{ "classify": { "dewey" : "", "keywords" : "", diff --git a/src/sdp/ao_header_extract.d b/src/sdp/ao_header_extract.d index 76c5a7d..cf6dca1 100644 --- a/src/sdp/ao_header_extract.d +++ b/src/sdp/ao_header_extract.d @@ -10,13 +10,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; diff --git a/src/sdp/ao_header_extract_native.d b/src/sdp/ao_header_extract_native.d index 49555ef..2f86d89 100644 --- a/src/sdp/ao_header_extract_native.d +++ b/src/sdp/ao_header_extract_native.d @@ -10,7 +10,7 @@ template SiSUheaderExtractNative() { private import ao_rgx; struct HeaderDocMetadataAndMakeNativeToJson { - mixin SiSUheaderRegister; + mixin SiSUregisters; mixin SiSUrgxInitFlags; mixin RgxInit; auto rgx = Rgx(); @@ -273,8 +273,8 @@ template SiSUheaderExtractNative() { ]; 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); diff --git a/src/sdp/ao_header_extract_sdlang.d b/src/sdp/ao_header_extract_sdlang.d index a175b4f..886a2c8 100644 --- a/src/sdp/ao_header_extract_sdlang.d +++ b/src/sdp/ao_header_extract_sdlang.d @@ -7,9 +7,127 @@ template SiSUheaderExtractSDLang() { private import ao_rgx; struct HeaderExtractSDL { - mixin SiSUheaderRegister; + mixin SiSUregisters; mixin RgxInit; auto rgx = Rgx(); + 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; + } final private auto headerMakeSDLang(in string src_header) { scope(failure) { stderr.writefln( @@ -60,11 +178,11 @@ template SiSUheaderExtractSDLang() { } return header_sdlang; // sdlang.ast.Tag } - 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) { @@ -78,7 +196,6 @@ template SiSUheaderExtractSDLang() { string hm; string hs; /+ make +/ - auto dochead_make = parseJSON(header_make_jsonstr).object; if (!(header_sdlang.maybe.tags["make"].empty)) { hm = "make"; hs = "bold"; @@ -174,7 +291,7 @@ template SiSUheaderExtractSDLang() { } } /+ 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 +/ @@ -487,30 +604,11 @@ template SiSUheaderExtractSDLang() { static assert(!isTypeTuple!(t)); return t; } - 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; } } - 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; - } - } } |