From e9e17be24eba558c30fcdc41ea5bb9a1da7fd4e7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 12 Mar 2024 22:39:09 -0400 Subject: mark modules as @safe: (& identify what is not) --- src/doc_reform/io_out/odt.d | 79 +++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 39 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 15e7e8e..c17158a 100644 --- a/src/doc_reform/io_out/odt.d +++ b/src/doc_reform/io_out/odt.d @@ -48,6 +48,7 @@ +/ module doc_reform.io_out.odt; +@safe: template formatODT() { import doc_reform.io_out, @@ -69,7 +70,7 @@ template formatODT() { struct formatODT { static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); - @safe string _tags(O)(const O obj) { + string _tags(O)(const O obj) { string _tags = ""; if (obj.tags.anchor_tags.length > 0) { foreach (tag_; obj.tags.anchor_tags) { @@ -87,7 +88,7 @@ template formatODT() { } return _tags; } - @safe string _xhtml_anchor_tags(O)(O obj) { + string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -99,7 +100,7 @@ template formatODT() { } return tags; } - @safe string obj_num(O)(const O obj) { // TODO + string obj_num(O)(const O obj) { // TODO string _on; _on = (obj.metainfo.object_number.empty) ? "" @@ -109,7 +110,7 @@ template formatODT() { )); return _on; } - @safe string _footnotes()(string _txt) { + string _footnotes()(string _txt) { static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); _txt = _txt.replaceAll( @@ -129,14 +130,14 @@ template formatODT() { ); return _txt; } - @safe string _bullet(O)(const O obj) { + string _bullet(O)(const O obj) { string _b = ""; if (obj.attrib.bullet) { _b = format(q"┃● ┃",); } return _b; } - @safe string _indent(O)(string _txt, const O obj) { // TODO + string _indent(O)(string _txt, const O obj) { // TODO // if (obj.attrib.indent_base > 0 || // obj.attrib.indent_hang > 0 // ) { @@ -244,7 +245,7 @@ template formatODT() { } return _txt; } - @safe string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO + string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO string _block = ""; foreach (i, _line; _block_lines) { _line = _footnotes(_line); @@ -277,7 +278,7 @@ template formatODT() { obj_num(obj)); return _block; } - @safe string _special_characters(O)(string _txt, const O obj) { + string _special_characters(O)(string _txt, const O obj) { _txt = _txt .replaceAll(rgx_xhtml.ampersand, "&") .replaceAll(rgx_xhtml.quotation, """) @@ -286,7 +287,7 @@ template formatODT() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - @safe string _preserve_white_spaces(O)(string _txt, const O obj) { + 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, " "); @@ -307,9 +308,9 @@ template formatODT() { .replaceAll(rgx.inline_mono, format(q"┃%s┃", "$1")); return _txt; } - @safe auto _obj_num(O)(O obj) { // NOT USED YET + auto _obj_num(O)(O obj) { // NOT USED YET struct objNum { - @safe string reference() { + string reference() { return format(q"┃ @@ -318,7 +319,7 @@ template formatODT() { obj.object_number, ); } - @safe string display() { + string display() { return format(q"┃ %s%s%s ┃", @@ -330,20 +331,20 @@ template formatODT() { } return objNum(); } - @safe string _break_page()() { + string _break_page()() { return format(q"┃ ┃", ); } - @safe string _empty_line_break(O)(string _txt, const O obj) { + 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; } - @safe string _links(O)(string _txt, const O obj) { + string _links(O)(string _txt, const O obj) { if (obj.metainfo.is_a != "code") { if (obj.metainfo.is_a == "toc") { _txt = replaceAll!(m => @@ -383,7 +384,7 @@ template formatODT() { } return _txt; } - @safe string _images(O)(string _txt, const O obj) { + string _images(O)(string _txt, const O obj) { if (_txt.match(rgx.inline_image)) { _txt = _txt .replaceAll(rgx.inline_image, @@ -394,7 +395,7 @@ template formatODT() { } return _txt; } - @safe string markup(O)(const O obj) { + 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 @@ -408,7 +409,7 @@ 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; } - @safe string heading(O,M)( + string heading(O,M)( const O obj, const M doc_matters, ) { @@ -452,7 +453,7 @@ template formatODT() { } return _o_txt_odt; } - @safe string para(O,M)( + string para(O,M)( const O obj, const M doc_matters, ) { @@ -471,7 +472,7 @@ template formatODT() { } return _o_txt_odt; } - @safe string quote(O,M)( + string quote(O,M)( const O obj, const M doc_matters, ) { @@ -483,7 +484,7 @@ template formatODT() { _o_txt_odt = _footnotes(_o_txt_odt); // decide return _o_txt_odt; } - @safe string group(O,M)( + string group(O,M)( const O obj, const M doc_matters, ) { @@ -501,7 +502,7 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - @safe string block(O,M)( + string block(O,M)( const O obj, const M doc_matters, ) { @@ -514,7 +515,7 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - @safe string verse(O,M)( + string verse(O,M)( const O obj, const M doc_matters, ) { @@ -527,7 +528,7 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - @safe string code(O,M)( + string code(O,M)( const O obj, const M doc_matters, ) { @@ -574,7 +575,7 @@ template formatODT() { _o_txt_odt = _block; return _o_txt_odt; } - @safe Tuple!(string, string) tablarize(O)( + Tuple!(string, string) tablarize(O)( const O obj, string _txt, ) { @@ -609,7 +610,7 @@ template formatODT() { return t; } int _table_number = 0; - @safe string table(O,M)( + string table(O,M)( const O obj, const M doc_matters, ) { @@ -666,7 +667,7 @@ template outputODT() { static auto rgx = RgxO(); static auto rgx_xhtml = RgxXHTML(); // mixin outputXmlODT; - @safe string odt_head(I)(I doc_matters) { + string odt_head(I)(I doc_matters) { string _has_tables = format(q"┃ @@ -774,7 +775,7 @@ template outputODT() { ); return _odt_head; } - @safe string odt_body(D,I)( + string odt_body(D,I)( const D doc_abstraction, I doc_matters, ) { @@ -900,12 +901,12 @@ template outputODT() { return doc_odt; } - @safe string odt_tail() { + string odt_tail() { string _odt_tail = format(q"┃spine: <www.doc_reform.org> and <www.sisudoc.org> ┃",); return _odt_tail; } - @safe string content_xml(D,I)( + string content_xml(D,I)( const D doc_abstraction, I doc_matters, ) { @@ -918,7 +919,7 @@ template outputODT() { _content_xml ~= odt_tail; return _content_xml; } - @safe string manifest_xml(M)( + string manifest_xml(M)( auto ref M doc_matters, ) { string _bullet = format(q"┃┃"); @@ -942,7 +943,7 @@ template outputODT() { ); return _manifest_xml; } - @safe void images_cp(M)( + void images_cp(M)( auto ref M doc_matters, ) { { /+ (copy odt images) +/ @@ -963,7 +964,7 @@ template outputODT() { } // return 0; } - @safe string meta_xml(M)( + string meta_xml(M)( auto ref M doc_matters, ) { /+ (meta_xml includes output time-stamp) +/ @@ -1011,11 +1012,11 @@ template outputODT() { } // return 0; } - @safe string mimetype() { + string mimetype() { string mimetype_ = format(q"┃application/vnd.oasis.opendocument.text┃"); return mimetype_; } - @safe string manifest_rdf() { + string manifest_rdf() { string _manifest_rdf = format(q"┃ @@ -1037,7 +1038,7 @@ template outputODT() { ┃"); return _manifest_rdf; } - @safe string settings_xml() { + string settings_xml() { string _settings_xml = format(q"┃ @@ -1137,7 +1138,7 @@ template outputODT() { ┃"); return _settings_xml; } - @safe string styles_xml() { + string styles_xml() { string _styles_xml = format(q"┃ @@ -2033,7 +2034,7 @@ template outputODT() { ┃"); return _styles_xml; } - void writeOutputODT(W,I)( + @trusted void writeOutputODT(W,I)( const W odt_content, I doc_matters, ) { @@ -2092,7 +2093,7 @@ template outputODT() { auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn_out; auto zip_data = new OutBuffer(); - zip_data.write(cast(char[]) ((fn_src).read)); + zip_data.write(cast(char[]) ((fn_src).read)); // trusted? zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); createZipFile!()(fn_odt, zip.build()); -- cgit v1.2.3