/++ extract native/orig header return associative array
the header is passed as text (lopped off top of a sisu markup file until the required first heading ^A~), determine whether is a yaml header or toml one with a regex check if whether it contains the "yaml header" required tag/field title: then process accordingly as a "yaml header" or "toml header" converting the metadata and make instructions to a common json format used by program internally. Moved to associative array. +/ module doc_reform.meta.conf_make_meta_toml; static template configParseTOMLreturnJSON() { import toml, toml.json; auto configParseTOMLreturnJSON(T)( T _text ){ TOMLDocument _doc; _doc = parseTOML(cast(string)(_text.content)); auto _doc_json = _doc.toJSON; return _doc_json; } } static template configParseTOMLreturnDocReformStruct() { import toml, toml.json; import doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_json; mixin contentJSONtoDocReformStruct; auto configParseTOMLreturnDocReformStruct(T,CCm,M)( T _document_struct, CCm _make_and_meta_struct, M _manifest ){ TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content)); auto _doc_json = _doc.toJSON; _make_and_meta_struct = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, _document_struct.filename); // struct from json return _make_and_meta_struct; } } static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { import std.exception, std.regex, std.stdio, std.traits, std.typecons, std.utf, std.conv : to; import toml, toml.json; import doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_json, doc_reform.meta.rgx; mixin DocReformRgxInit; mixin contentJSONtoDocReformStruct; static auto rgx = Rgx(); auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm,Src,M)( Src header_src, CCm _make_and_meta_struct, M _manifest, ) { TOMLDocument _doc_toml; if (header_src.match(rgx.toml_header_meta_title)) { debug (json) { writeln(">>> document header is toml, convert to JSON"); } _doc_toml = parseTOML(cast(string)(header_src)); } auto _doc_json = _doc_toml.toJSON; auto _header_and_make_and_meta_struct = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, "header"); return _header_and_make_and_meta_struct; } }