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/odt.d | 102 ++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/doc_reform/io_out/odt.d') 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"┃ -- cgit v1.2.3