diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2020-01-05 20:17:17 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2020-02-11 13:08:49 -0500 |
commit | de02319cfa7b4bbff8c111bda02be1a7c6591555 (patch) | |
tree | 732c11d10bc2699cd1b72d00b3be943284eea130 /src/doc_reform/io_out/xmls.d | |
parent | reduce use of auto, much with tuples (diff) |
dlang safe default imminent, look ahead
- @safe @trusted & @system, reconsider @trusted
Diffstat (limited to 'src/doc_reform/io_out/xmls.d')
-rw-r--r-- | src/doc_reform/io_out/xmls.d | 150 |
1 files changed, 75 insertions, 75 deletions
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, ("<em>$1</em>")) .replaceAll(rgx.inline_bold, ("<b>$1</b>")) @@ -78,7 +78,7 @@ template outputXHTMLs() { .replaceAll(rgx.inline_cite, ("<cite>$1</cite>")); 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"┃<!-- spine DocReform header metadata --> @@ -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"┃<!DOCTYPE html> <html>┃", ); @@ -300,7 +300,7 @@ template outputXHTMLs() { ); return o; } - string tail() @safe { + @safe string tail() { string o; o = format(q"┃ <a name="bottom" id="bottom"></a> @@ -309,13 +309,13 @@ template outputXHTMLs() { </html>┃"); 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 ~= " <div class=\"nav\">\n"; foreach (subtoc; obj.tags.lev4_subtoc) { @@ -584,10 +584,10 @@ template outputXHTMLs() { lev4_subtoc ~= " </div>\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"); |