/+ extract sdl header return sdl +/ template SiSUheaderExtractSDLang() { private import std.regex; private import ao_rgx; struct HeaderExtractSDL { mixin SiSUregisters; mixin RgxInit; auto rgx = Rgx(); private auto configSettingsSDLangToAAmake(Tag conf_sdlang) { /+ config settings +/ string hm; string hs; auto conf = conf_aa; hm = "webserv"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "url_root"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "path"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "images"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "cgi"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "webserv_cgi"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "host"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "base_path"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "port"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "user"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "file_links"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "processing"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "path"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "dir"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "concord_max"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "flag"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "act0"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act0"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act1"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act2"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act3"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act4"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act5"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act6"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act7"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act8"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "act9"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "default"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "papersize"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "text_wrap"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "emphasis"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "language"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "digest"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "permission"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "share_source"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "program_select"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "editor"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "epub_viewer"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "html_viewer"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "odf_viewer"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "pdf_viewer"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "xml_viewer"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } hm = "search"; if (!(conf_sdlang.maybe.tags[hm].empty)) { hs = "flag"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "action"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "db"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } hs = "title"; if (!(conf_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (conf_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(conf_sdlang.tags[hm][0].attributes[hs][0].value); conf[hm][hs] = to!string(conf_sdlang.tags[hm][0].attributes[hs][0].value); } } return conf; } private auto documentMakeSDLangToAAmake(Tag document_make_sdlang) { /+ dochead +/ string hm; string hs; /+ make +/ auto dochead_make = make_aa; if (!(document_make_sdlang.maybe.tags["make"].empty)) { hm = "make"; hs = "bold"; if (!(document_make_sdlang.tags[hm][0].maybe.attributes[hs].empty) && (document_make_sdlang.tags[hm][0].attributes[hs][0].value.length > 1)) { writeln(document_make_sdlang.tags[hm][0].attributes[hs][0].value); dochead_make[hm][hs] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = // 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( "%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 headerSDLangToAAmake(Tag header_sdlang, string[string][string] dochead_make) { /+ dochead +/ string hm; string hs; /+ make +/ 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } /+ meta +/ auto dochead_meta = meta_aa; 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = // 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = 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] = to!string(header_sdlang.tags[hm][0].attributes[hs][0].value); } } auto t = tuple(dochead_make, dochead_meta); static assert(!isTypeTuple!(t)); return t; } private auto headerSDLangToAA(char[] header_sdlang_src, string[string][string] conf_doc_make_aa) { auto header_sdlang_tag = headerSDLangGet(header_sdlang_src); // sdlang.ast.Tag auto header_aa_tuple = headerSDLangToAAmake(header_sdlang_tag, conf_doc_make_aa); return header_aa_tuple; } } }