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/sdp/ao_header_extract_sdlang.d | |
parent | step6 headers (&config), native & sdlang to json internally (diff) |
registers, minor cleaning
Diffstat (limited to 'src/sdp/ao_header_extract_sdlang.d')
-rw-r--r-- | src/sdp/ao_header_extract_sdlang.d | 152 |
1 files changed, 125 insertions, 27 deletions
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; - } - } } |