From de02319cfa7b4bbff8c111bda02be1a7c6591555 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 5 Jan 2020 20:17:17 -0500 Subject: dlang safe default imminent, look ahead - @safe @trusted & @system, reconsider @trusted --- src/doc_reform/io_out/create_zip_file.d | 2 +- src/doc_reform/io_out/defaults.d | 8 +- src/doc_reform/io_out/epub3.d | 18 ++-- src/doc_reform/io_out/html.d | 22 ++--- src/doc_reform/io_out/hub.d | 7 +- src/doc_reform/io_out/latex.d | 58 ++++++------ src/doc_reform/io_out/metadata.d | 4 +- src/doc_reform/io_out/odt.d | 102 +++++++++++----------- src/doc_reform/io_out/source_pod.d | 2 +- src/doc_reform/io_out/xmls.d | 150 ++++++++++++++++---------------- src/doc_reform/io_out/xmls_css.d | 4 +- 11 files changed, 190 insertions(+), 187 deletions(-) (limited to 'src/doc_reform/io_out') diff --git a/src/doc_reform/io_out/create_zip_file.d b/src/doc_reform/io_out/create_zip_file.d index 09b481a..0ad8ada 100644 --- a/src/doc_reform/io_out/create_zip_file.d +++ b/src/doc_reform/io_out/create_zip_file.d @@ -4,7 +4,7 @@ template createZipFile() { import std.outbuffer; import std.string; import std.zip; - void createZipFile( + @safe void createZipFile( string zip_file_name, void[] compressed_zip_data, ) { diff --git a/src/doc_reform/io_out/defaults.d b/src/doc_reform/io_out/defaults.d index 4dd8021..84bac73 100644 --- a/src/doc_reform/io_out/defaults.d +++ b/src/doc_reform/io_out/defaults.d @@ -50,7 +50,7 @@ template InternalMarkup() { template spineLanguageCodes() { /+ language codes +/ struct Lang { - static string[string][string] codes() { + @safe static string[string][string] codes() { auto _lang_codes = [ "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], @@ -117,15 +117,15 @@ template spineLanguageCodes() { ]; return _lang_codes; } - static string[] code_arr_ptr() { + @safe static string[] code_arr_ptr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; return _lang_codes; } - static string[] code_arr() { + @safe static string[] code_arr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; return _lang_codes; } - static auto codes_() { + @safe static auto codes_() { return "(" ~ join(code_arr,"|") ~ ")"; } static auto codes_regex() { diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 4de98a1..f8f5ba4 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -14,12 +14,12 @@ template outputEPub3() { doc_reform.io_out.xmls_css; mixin InternalMarkup; mixin outputXHTMLs; - string epub3_mimetypes() @safe { + @safe string epub3_mimetypes() { string o; o = format(q"┃application/epub+zip┃") ~ "\n"; return o; } - string epub3_container_xml() @safe { + @safe string epub3_container_xml() { string o; o = format(q"┃┃") ~ "\n"; o ~= format(q"┃┃") ~ "\n\n"; return o; } - string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) @safe { + @safe string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { auto xhtml_format = outputXHTMLs(); auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! @@ -128,7 +128,7 @@ template outputEPub3() { } return content; } - string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) @safe { + @safe string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = Rgx(); @@ -207,7 +207,7 @@ template outputEPub3() { \n"; return toc; } - string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) @safe { + @safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { int counter = 0; string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); @@ -297,10 +297,10 @@ template outputEPub3() { return toc; } - void outputEPub3(D,I)( + @system void outputEPub3(D,I)( const D doc_abstraction, I doc_matters, - ) { // @trusted + ) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -606,10 +606,10 @@ template outputEPub3() { epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts); epubWrite.epub3_write_output_files(doc_matters); } - void epub3_write_output_files(W,M)( + @system void epub3_write_output_files(W,M)( W epub_write, M doc_matters, - ) { // @trusted + ) { debug(asserts) { static assert(is(typeof(epub_write.doc_epub3) == string[][string])); static assert(is(typeof(epub_write.mimetypes) == string)); diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d index 8598ca5..637b007 100644 --- a/src/doc_reform/io_out/html.d +++ b/src/doc_reform/io_out/html.d @@ -13,10 +13,10 @@ template outputHTML() { doc_reform.io_out.xmls, doc_reform.io_out.xmls_css; mixin outputXHTMLs; - void scroll(D,M)( + @safe void scroll(D,M)( const D doc_abstraction, M doc_matters, - ) @safe { + ) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -183,10 +183,10 @@ template outputHTML() { doc = xhtml_format.html_head(doc_matters, "scroll") ~ doc_html ~ xhtml_format.tail; scroll_write_output(doc, doc_matters); } - void scroll_write_output(D,M)( + @trusted void scroll_write_output(D,M)( D doc, M doc_matters, - ) @trusted { + ) { debug(asserts) { static assert(is(typeof(doc) == string[])); } @@ -206,10 +206,10 @@ template outputHTML() { writeln(" ", pth_html.fn_scroll(doc_matters.src.filename)); } } - void seg(D,M)( + @safe void seg(D,M)( const D doc_abstraction, M doc_matters, - ) @safe { + ) { mixin spineOutputRgxInit; static auto rgx = Rgx(); auto xhtml_format = outputXHTMLs(); @@ -459,11 +459,11 @@ template outputHTML() { } seg_write_output(doc_html, doc_html_endnotes, doc_matters); } - void seg_write_output(D,E,M)( + @trusted void seg_write_output(D,E,M)( // @system? D doc_html, E doc_html_endnotes, M doc_matters, - ) @trusted { // @system? + ) { debug(asserts) { static assert(is(typeof(doc_html) == string[][string])); } @@ -493,7 +493,7 @@ template outputHTML() { writeln(" ", pth_html.fn_seg(doc_matters.src.filename, "toc")); } } - void css(M)(M doc_matters) @safe { + @safe void css(M)(M doc_matters) { auto css = spineCss(doc_matters); auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { @@ -508,9 +508,9 @@ template outputHTML() { // Handle error } } - void images_cp(M)( + @trusted void images_cp(M)( // @system M doc_matters, - ) @trusted { // @system + ) { { /+ (copy html images) +/ auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index a43c28a..df3d28c 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -11,7 +11,10 @@ template outputHub() { doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; import std.parallelism; - void outputHub(D,I)(const D doc_abstraction, I doc_matters) { + @system void outputHub(D,I)( + const D doc_abstraction, + I doc_matters + ) { mixin spineOutputRgxInit; mixin Msg; auto msg = Msg!()(doc_matters); @@ -114,7 +117,7 @@ template outputHubOp() { doc_reform.io_out.odt, doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; - void outputHubOp(E,O)(E env, O opt_action) { + @system void outputHubOp(E,O)(E env, O opt_action) { mixin spineOutputRgxInit; static auto rgx = Rgx(); if ((opt_action.sqlite_db_drop)) { diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d index cfa347c..b8e33f4 100644 --- a/src/doc_reform/io_out/latex.d +++ b/src/doc_reform/io_out/latex.d @@ -14,7 +14,7 @@ template outputLaTeX() { auto lang = Lang(); auto paper() { struct PaperType { - auto a4() @safe { + @safe auto a4() { struct A4 { auto portrait() { struct V { @@ -35,7 +35,7 @@ template outputLaTeX() { } return A4(); } - auto a5() @safe { + @safe auto a5() { struct A5 { auto portrait() { struct V { @@ -56,7 +56,7 @@ template outputLaTeX() { } return A5(); } - auto b4() @safe { + @safe auto b4() { struct B4 { auto portrait() { struct V { @@ -77,7 +77,7 @@ template outputLaTeX() { } return B4(); } - auto letter() @safe { + @safe auto letter() { struct Letter { auto portrait() { struct V { @@ -98,7 +98,7 @@ template outputLaTeX() { } return Letter(); } - auto legal() @safe { + @safe auto legal() { struct Legal { auto portrait() { struct V { @@ -122,10 +122,10 @@ template outputLaTeX() { } return PaperType(); } - string sp_char_esc(O)( + @safe string sp_char_esc(O)( string _txt, const O obj, - ) @safe { + ) { string _unescape_sp_char_esc()(string _txt) { _txt = _txt .replaceAll(rgx.latex_special_char_escaped, @@ -147,9 +147,9 @@ template outputLaTeX() { } return _txt; } - string sp_char_esc_txt()( + @safe string sp_char_esc_txt()( string _txt, - ) @safe { + ) { string _unescape_sp_char_esc()(string _txt) { _txt = _txt .replaceAll(rgx.latex_special_char_escaped, @@ -169,9 +169,9 @@ template outputLaTeX() { _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface); return _txt; } - string fontface()( + @safe string fontface()( string _txt, - ) @safe { + ) { _txt = _txt .replaceAll(rgx.inline_emphasis, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) .replaceAll(rgx.inline_bold, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) @@ -185,9 +185,9 @@ template outputLaTeX() { .replaceAll(rgx.inline_italics, format(q"┃``%s''┃", "$1")); return _txt; } - string leading_hardspaces()( + @safe string leading_hardspaces()( string _txt, - ) @safe { + ) { string hardspaces(string _spaces) { _spaces = _spaces .replaceAll(rgx.space, "\\hardspace "); @@ -196,23 +196,23 @@ template outputLaTeX() { _txt = replaceAll!(m => hardspaces(m[0]))(_txt, rgx.spaces_line_start); return _txt; } - string nbsp_char()(string _txt) @safe { + @safe string nbsp_char()(string _txt) { if (_txt.match(rgx.nbsp_char)) { _txt = _txt.replaceAll(rgx.nbsp_char, "\\hardspace "); } return _txt; } - string nbsp_char_to_space()(string _txt) @safe { + @safe string nbsp_char_to_space()(string _txt) { if (_txt.match(rgx.nbsp_char)) { _txt = _txt.replaceAll(rgx.nbsp_char, " "); } return _txt; } - string links_and_images(O,M)( + @safe string links_and_images(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { if (obj.has.inline_links) { // TODO some images do not have inline links ... image without link string _width_adjust(string _width) { if (_width.to!int > 300) { _width = "300"; } // will need to vary max with papersize & orientation @@ -253,9 +253,9 @@ template outputLaTeX() { } return _txt; } - string footnotes()( + @safe string footnotes()( string _txt, - ) @safe { + ) { if (_txt.match(rgx.inline_notes_al_gen)) { string _tex_note = q"┃\hypertarget{noteref_%s}{}\footnote[%s]{%% \label{note_%s}%s}┃"; @@ -268,18 +268,18 @@ template outputLaTeX() { } return _txt; } - string remove_footnotes()( + @safe string remove_footnotes()( string _txt, - ) @safe { + ) { if (_txt.match(rgx.inline_notes_al_gen)) { _txt = replaceAll!(m => "")(_txt, rgx.inline_notes_al_gen); } return _txt; } - string para(O)( + @safe string para(O)( string _txt, O obj, - ) @safe { + ) { if (obj.metainfo.is_of_type == "para") { string _tex_para; _tex_para = q"┃\begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{%s}{%s}\end{tiny}}}%s┃"; @@ -291,10 +291,10 @@ template outputLaTeX() { } return _txt; } - string bookindex(O)( + @safe string bookindex(O)( string _txt, O obj, - ) @safe { + ) { if (obj.metainfo.is_of_type == "para" && obj.metainfo.is_a == "bookindex" ) { @@ -306,12 +306,12 @@ template outputLaTeX() { } return _txt; } - string heading(O,M)( + @safe string heading(O,M)( string _txt, O obj, M doc_matters, string _part = "" - ) @safe { + ) { if (obj.metainfo.is_a == "heading") { string _tex_para; string _pg_break; @@ -641,10 +641,10 @@ string table(O,M)( } return _txt; } - string bullets_and_indentation(O)( + @safe string bullets_and_indentation(O)( string _txt, O obj, - ) @safe { + ) { string _tex_para; string _hang; string _indent; int _paper_margin = -10; diff --git a/src/doc_reform/io_out/metadata.d b/src/doc_reform/io_out/metadata.d index 8201926..5dfdfe2 100644 --- a/src/doc_reform/io_out/metadata.d +++ b/src/doc_reform/io_out/metadata.d @@ -1,6 +1,6 @@ module doc_reform.io_out.metadata; template outputMetadata() { - void outputMetadata(T)( T doc_matters) @safe { + @safe void outputMetadata(T)( T doc_matters) { import std.file; import std.format; import doc_reform.io_out; @@ -185,7 +185,7 @@ string theme_light_1 = format(q"┃ doc_matters.opt.action.css_theme_default ? theme_light_0 : theme_dark_0, doc_matters.opt.action.css_theme_default ? theme_light_1 : theme_dark_1, ) ~ "\n"; - void metadata_write_output(M)(M doc_matters, string[] metadata_) @trusted { + @safe void metadata_write_output(M)(M doc_matters, string[] metadata_) { auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { if (!exists(pth_html.base)) { diff --git a/src/doc_reform/io_out/odt.d b/src/doc_reform/io_out/odt.d index 23eb947..67b34ba 100644 --- a/src/doc_reform/io_out/odt.d +++ b/src/doc_reform/io_out/odt.d @@ -15,7 +15,7 @@ template formatODT() { mixin spineOutputRgxInit; struct formatODT { static auto rgx = Rgx(); - string _tags(O)(const O obj) @safe { + @safe string _tags(O)(const O obj) { string _tags = ""; if (obj.tags.anchor_tags.length > 0) { foreach (tag_; obj.tags.anchor_tags) { @@ -33,7 +33,7 @@ template formatODT() { } return _tags; } - string _xhtml_anchor_tags(O)(O obj) @safe { + @safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -45,7 +45,7 @@ template formatODT() { } return tags; } - string obj_num(O)(const O obj) @safe { // TODO + @safe string obj_num(O)(const O obj) { // TODO string _on; _on = (obj.metainfo.object_number.empty) ? "" @@ -55,7 +55,7 @@ template formatODT() { )); return _on; } - string _footnotes()(string _txt) @safe { + @safe string _footnotes()(string _txt) { static auto rgx = Rgx(); _txt = _txt.replaceAll( rgx.inline_notes_al_regular_number_note, @@ -74,14 +74,14 @@ template formatODT() { ); return _txt; } - string _bullet(O)(const O obj) @safe { + @safe string _bullet(O)(const O obj) { string _b = ""; if (obj.attrib.bullet) { _b = format(q"┃● ┃",); } return _b; } - string _indent(O)(string _txt, const O obj) @safe { // TODO + @safe string _indent(O)(string _txt, const O obj) { // TODO // if (obj.attrib.indent_base > 0 || // obj.attrib.indent_hang > 0 // ) { @@ -189,7 +189,7 @@ template formatODT() { } return _txt; } - string _block_type_delimiters(O)(string[] _block_lines, const O obj) @safe { // TODO + @safe string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO string _block = ""; foreach (i, _line; _block_lines) { _line = _footnotes(_line); @@ -222,7 +222,7 @@ template formatODT() { obj_num(obj)); return _block; } - string _special_characters(O)(string _txt, const O obj) @safe { + @safe string _special_characters(O)(string _txt, const O obj) { _txt = _txt .replaceAll(rgx.xhtml_ampersand, "&") .replaceAll(rgx.xhtml_quotation, """) @@ -231,7 +231,7 @@ template formatODT() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - string _preserve_white_spaces(O)(string _txt, const O obj) @safe { + @safe string _preserve_white_spaces(O)(string _txt, const O obj) { if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { _txt = _txt .replaceAll(rgx.space, " "); @@ -252,9 +252,9 @@ template formatODT() { .replaceAll(rgx.inline_mono, format(q"┃%s┃", "$1")); return _txt; } - auto _obj_num(O)(O obj) @safe { // NOT USED YET + @safe auto _obj_num(O)(O obj) { // NOT USED YET struct objNum { - string reference() @safe { + @safe string reference() { return format(q"┃ @@ -263,7 +263,7 @@ template formatODT() { obj.object_number, ); } - string display() @safe { + @safe string display() { return format(q"┃ %s%s%s ┃", @@ -275,20 +275,20 @@ template formatODT() { } return objNum(); } - string _break_page()() @safe { + @safe string _break_page()() { return format(q"┃ ┃", ); } - string _empty_line_break(O)(string _txt, const O obj) @safe { + @safe string _empty_line_break(O)(string _txt, const O obj) { if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { _txt = _txt .replaceAll(rgx.br_empty_line, "
"); } return _txt; } - string _links(O)(string _txt, const O obj) @safe { + @safe string _links(O)(string _txt, const O obj) { if (obj.metainfo.is_a != "code") { if (obj.metainfo.is_a == "toc") { _txt = replaceAll!(m => @@ -328,7 +328,7 @@ template formatODT() { } return _txt; } - string _images(O)(string _txt, const O obj) @safe { + @safe string _images(O)(string _txt, const O obj) { if (_txt.match(rgx.inline_image)) { _txt = _txt .replaceAll(rgx.inline_image, @@ -339,7 +339,7 @@ template formatODT() { } return _txt; } - string markup(O)(const O obj) @safe { + @safe string markup(O)(const O obj) { /+ markup TODO +/ string _txt = obj.text; _txt = _special_characters(_txt, obj); // TODO & why both obj & obj.text, consider also in output_xmls.org @@ -353,10 +353,10 @@ template formatODT() { _txt = _empty_line_break(_txt, obj); // (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") return _txt; } - string heading(O,M)( + @safe string heading(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -397,10 +397,10 @@ template formatODT() { } return _o_txt_odt; } - string para(O,M)( + @safe string para(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -416,10 +416,10 @@ template formatODT() { } return _o_txt_odt; } - string quote(O,M)( + @safe string quote(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -428,10 +428,10 @@ template formatODT() { _o_txt_odt = _footnotes(_o_txt_odt); // decide return _o_txt_odt; } - string group(O,M)( + @safe string group(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -446,10 +446,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string block(O,M)( + @safe string block(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -459,10 +459,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string verse(O,M)( + @safe string verse(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -472,10 +472,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string code(O,M)( + @safe string code(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -519,10 +519,10 @@ template formatODT() { _o_txt_odt = _block; return _o_txt_odt; } - Tuple!(string, string) tablarize(O)( + @safe Tuple!(string, string) tablarize(O)( const O obj, string _txt, - ) @safe { + ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; @@ -554,10 +554,10 @@ template formatODT() { return t; } int _table_number = 0; - string table(O,M)( + @safe string table(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -606,7 +606,7 @@ template outputODT() { mixin spineOutputRgxInit; static auto rgx = Rgx(); // mixin outputXmlODT; - string odt_head(I)(I doc_matters) @safe { + @safe string odt_head(I)(I doc_matters) { string _has_tables = format(q"┃ @@ -714,10 +714,10 @@ template outputODT() { ); return _odt_head; } - string odt_body(D,I)( + @safe string odt_body(D,I)( const D doc_abstraction, I doc_matters, - ) @safe { + ) { mixin formatODT; auto odt_format = formatODT(); string delimit = ""; @@ -840,15 +840,15 @@ template outputODT() { return doc_odt; } - string odt_tail() @safe { + @safe string odt_tail() { string _odt_tail = format(q"┃spine: <www.doc_reform.org> and <www.sisudoc.org> ┃",); return _odt_tail; } - string content_xml(D,I)( + @safe string content_xml(D,I)( const D doc_abstraction, I doc_matters, - ) @safe { + ) { string _content_xml; string break_line = (doc_matters.opt.action.debug_do) ? "\n" : ""; string odt_break_page = format(q"┃┃",); @@ -858,9 +858,9 @@ template outputODT() { _content_xml ~= odt_tail; return _content_xml; } - string manifest_xml(M)( + @safe string manifest_xml(M)( auto ref M doc_matters, - ) @safe { + ) { string _bullet = format(q"┃┃"); string[] _images = [ _bullet ]; foreach (image; doc_matters.srcs.image_list) { @@ -882,9 +882,9 @@ template outputODT() { ); return _manifest_xml; } - void images_cp(M)( + @safe void images_cp(M)( auto ref M doc_matters, - ) @safe { + ) { { /+ (copy odt images) +/ auto pth_odt = spinePathsODT!()(doc_matters); foreach (image; doc_matters.srcs.image_list) { @@ -902,9 +902,9 @@ template outputODT() { } // return 0; } - string meta_xml(M)( + @safe string meta_xml(M)( auto ref M doc_matters, - ) @safe { + ) { /+ (meta_xml includes output time-stamp) +/ string _meta_xml = format(q"┃ @@ -939,11 +939,11 @@ template outputODT() { } // return 0; } - string mimetype() @safe { + @safe string mimetype() { string mimetype_ = format(q"┃application/vnd.oasis.opendocument.text┃"); return mimetype_; } - string manifest_rdf() @safe { + @safe string manifest_rdf() { string _manifest_rdf = format(q"┃ @@ -965,7 +965,7 @@ template outputODT() { ┃"); return _manifest_rdf; } - string settings_xml() @safe { + @safe string settings_xml() { string _settings_xml = format(q"┃ @@ -1065,7 +1065,7 @@ template outputODT() { ┃"); return _settings_xml; } - string styles_xml() @safe { + @safe string styles_xml() { string _styles_xml = format(q"┃ diff --git a/src/doc_reform/io_out/source_pod.d b/src/doc_reform/io_out/source_pod.d index 31c0b45..59746de 100644 --- a/src/doc_reform/io_out/source_pod.d +++ b/src/doc_reform/io_out/source_pod.d @@ -23,7 +23,7 @@ template spinePod() { auto lang = Lang(); static auto rgx = Rgx(); assert (doc_matters.src.filename.match(rgx.src_fn)); - auto pod_archive(Z)( + @system auto pod_archive(Z)( string _source_type, string _data_in, string _pth_out, diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 1d58e27..1b038a9 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -15,10 +15,10 @@ template outputXHTMLs() { mixin spineOutputRgxInit; struct outputXHTMLs { static auto rgx = Rgx(); - string div_delimit( + @safe string div_delimit( string part, return ref string previous_part - ) @safe { + ) { string delimit = ""; string delimit_ = ""; if (part != previous_part) { @@ -45,7 +45,7 @@ template outputXHTMLs() { // you also need to close the last div, introduce a footer? return delimit; } - string special_characters_text(string _txt) @safe { + @safe string special_characters_text(string _txt) { _txt = _txt .replaceAll(rgx.xhtml_ampersand, "&") .replaceAll(rgx.xhtml_quotation, """) @@ -54,9 +54,9 @@ template outputXHTMLs() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - string special_characters(O)( + @safe string special_characters(O)( const O obj, - ) @safe { + ) { string _txt = special_characters_text(obj.text); if (!(obj.metainfo.is_a == "code")) { _txt = (_txt) @@ -64,7 +64,7 @@ template outputXHTMLs() { } return _txt; } - string font_face(string _txt) @safe { + @safe string font_face(string _txt) { _txt = _txt .replaceAll(rgx.inline_emphasis, ("$1")) .replaceAll(rgx.inline_bold, ("$1")) @@ -78,7 +78,7 @@ template outputXHTMLs() { .replaceAll(rgx.inline_cite, ("$1")); return _txt; } - string _xhtml_anchor_tags(O)(O obj) @safe { + @safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -90,9 +90,9 @@ template outputXHTMLs() { } return tags; } - string header_metadata(M)( + @safe string header_metadata(M)( M doc_matters, - ) @safe { + ) { string _publisher="Publisher"; // TODO string o; o = format(q"┃ @@ -127,9 +127,9 @@ template outputXHTMLs() { ); return o; } - string site_info_button(M)( + @safe string site_info_button(M)( M doc_matters, - ) @safe { + ) { string _locations; if (doc_matters.conf_make_meta.make.home_button_text.length > 0) { _locations = (doc_matters.conf_make_meta.make.home_button_text) @@ -151,9 +151,9 @@ template outputXHTMLs() { ); return o; } - string inline_search_form(M)( + @safe string inline_search_form(M)( M doc_matters, - ) @safe { + ) { string _action="http://www.sisudoc.org/cgi-bin/search.cgi"; string _db="spine.7a.manual"; string o; @@ -182,7 +182,7 @@ template outputXHTMLs() { } return o; } - string html_head(M)( + @safe string html_head(M)( M doc_matters, string type, ) { @@ -232,9 +232,9 @@ template outputXHTMLs() { ); return o; } - string epub3_seg_head(M)( + @safe string epub3_seg_head(M)( M doc_matters, - ) @safe { + ) { string html_base = format(q"┃ ┃", ); @@ -300,7 +300,7 @@ template outputXHTMLs() { ); return o; } - string tail() @safe { + @safe string tail() { string o; o = format(q"┃ @@ -309,13 +309,13 @@ template outputXHTMLs() { ┃"); return o; } - string inline_images(O,M)( + @safe string inline_images(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { string _img_pth; switch (_xml_type) { case "epub": _img_pth = "image/"; break; @@ -335,13 +335,13 @@ template outputXHTMLs() { } return _txt; } - string inline_links(O,M)( + @safe string inline_links(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { string seg_lvs; if (obj.has.inline_links) { if (obj.metainfo.is_a != "code") { @@ -426,11 +426,11 @@ template outputXHTMLs() { } return _txt; } - string inline_notes_scroll(O,M)( + @safe string inline_notes_scroll(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); _txt = _txt.replaceAll( @@ -457,11 +457,11 @@ template outputXHTMLs() { } return _txt; } - Tuple!(string, string[]) inline_notes_seg(O,M)( + @safe Tuple!(string, string[]) inline_notes_seg(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { string[] _endnotes; if (obj.has.inline_notes_star) { _txt = font_face(_txt); @@ -521,12 +521,12 @@ template outputXHTMLs() { ); return t; } - string inline_markup_scroll(O,M)( + @safe string inline_markup_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { if (obj.metainfo.dummy_heading && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { _txt = ""; @@ -537,13 +537,13 @@ template outputXHTMLs() { } return _txt; } - auto inline_markup_seg(O,M)( + @safe auto inline_markup_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { if (obj.metainfo.dummy_heading && ((_xml_type == "epub" && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) @@ -557,10 +557,10 @@ template outputXHTMLs() { Tuple!(string, string[]) t = inline_notes_seg(_txt, obj, doc_matters); return t; } - string lev4_heading_subtoc(O,M)( + @safe string lev4_heading_subtoc(O,M)( const O obj, M doc_matters, - ) @safe { + ) { char[] lev4_subtoc; lev4_subtoc ~= "
\n"; foreach (subtoc; obj.tags.lev4_subtoc) { @@ -584,10 +584,10 @@ template outputXHTMLs() { lev4_subtoc ~= "
\n"; return lev4_subtoc.to!string; } - auto nav_pre_next_svg(O,M)( + @safe auto nav_pre_next_svg(O,M)( const O obj, M doc_matters, - ) @safe { + ) { string prev, next, toc; if (obj.tags.segment_anchor_tag_epub == "toc") { toc = ""; @@ -660,12 +660,12 @@ template outputXHTMLs() { } return bar(); } - string heading(O,M)( + @safe string heading(O,M)( string _txt, const O obj, M doc_matters, string _xml_type = "html", - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -725,23 +725,23 @@ template outputXHTMLs() { } return o; } - string heading_scroll(O,M)( + @safe string heading_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = heading(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) heading_seg(O,M)( + @safe Tuple!(string, string[]) heading_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; @@ -752,11 +752,11 @@ template outputXHTMLs() { ); return u; } - string para(O,M)( + @safe string para(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -802,12 +802,12 @@ template outputXHTMLs() { } return o; } - string para_scroll(O,M)( + @safe string para_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { if (obj.metainfo.is_a == "toc" && _txt.match(rgx.inline_link_toc_to_backmatter)) { _txt = _txt.replaceAll(rgx.inline_link_toc_to_backmatter, "┤#section_$1├"); } @@ -815,13 +815,13 @@ template outputXHTMLs() { string o = para(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) para_seg(O,M)( + @safe Tuple!(string, string[]) para_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -832,11 +832,11 @@ template outputXHTMLs() { ); return u; } - string quote(O,M)( + @safe string quote(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -868,23 +868,23 @@ template outputXHTMLs() { } return o; } - string quote_scroll(O,M)( + @safe string quote_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = quote(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) quote_seg(O,M)( + @safe Tuple!(string, string[]) quote_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -895,11 +895,11 @@ template outputXHTMLs() { ); return u; } - string group(O,M)( + @safe string group(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -931,24 +931,24 @@ template outputXHTMLs() { } return o; } - string group_scroll(O,M)( + @safe string group_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = group(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) group_seg(O,M)( + @safe Tuple!(string, string[]) group_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -959,11 +959,11 @@ template outputXHTMLs() { ); return u; } - string block(O,M)( + @safe string block(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -991,24 +991,24 @@ template outputXHTMLs() { } return o; } - string block_scroll(O,M)( + @safe string block_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = block(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) block_seg(O,M)( + @safe Tuple!(string, string[]) block_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1019,11 +1019,11 @@ template outputXHTMLs() { ); return u; } - string verse(O,M)( + @safe string verse(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1051,24 +1051,24 @@ template outputXHTMLs() { } return o; } - string verse_scroll(O,M)( + @safe string verse_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = verse(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) verse_seg(O,M)( + @safe Tuple!(string, string[]) verse_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1079,10 +1079,10 @@ template outputXHTMLs() { ); return u; } - Tuple!(string, string) tablarize(O)( + @safe Tuple!(string, string) tablarize(O)( string _txt, const O obj, - ) @safe { + ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; @@ -1112,11 +1112,11 @@ template outputXHTMLs() { ); return t; } - string table(O,M)( + @safe string table(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -1146,11 +1146,11 @@ template outputXHTMLs() { ); return o; } - string code(O,M)( + @safe string code(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); diff --git a/src/doc_reform/io_out/xmls_css.d b/src/doc_reform/io_out/xmls_css.d index 0974637..88af237 100644 --- a/src/doc_reform/io_out/xmls_css.d +++ b/src/doc_reform/io_out/xmls_css.d @@ -4,7 +4,7 @@ module doc_reform.io_out.xmls_css; template spineCss() { import std.format; - auto spineCss(M)(M doc_matters) @safe { + @safe auto spineCss(M)(M doc_matters) { string _css_indent = format(q"┃ /* indent */ p.norm { } @@ -4162,7 +4162,7 @@ template spineCss() { _css_indent, _color_ocn_dark, ); - auto css_() @safe { + @safe auto css_() { struct _CSS { string html_seg = "/* spine css html seg stylesheet */\n"; string html_scroll = "/* spine css html scroll stylesheet */\n"; -- cgit v1.2.3