From 0c693b23c4ff8f98a151884a24f150a5ff746dd4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 16 Oct 2020 19:16:18 -0400 Subject: org mode, unique code-block names & adjust headers - avoid org-mode undefined behavior, provide unique code-block names --- org/out_odt.org | 177 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 64 deletions(-) (limited to 'org/out_odt.org') diff --git a/org/out_odt.org b/org/out_odt.org index 027816d..fe83c68 100644 --- a/org/out_odt.org +++ b/org/out_odt.org @@ -7,6 +7,7 @@ #+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah #+LANGUAGE: en #+STARTUP: content hideblocks hidestars noindent entitiespretty +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t #+PROPERTY: header-args :exports code #+PROPERTY: header-args+ :noweb yes #+PROPERTY: header-args+ :eval no @@ -52,7 +53,31 @@ template formatODT() { mixin spineRgxOut; struct formatODT { static auto rgx = RgxO(); - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> } } template outputODT() { @@ -61,16 +86,40 @@ template outputODT() { mixin spineRgxOut; static auto rgx = RgxO(); // mixin outputXmlODT; - <> - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> <> - <> + <> + <> + <> <> <> - <> - <> - <> - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> } #+END_SRC @@ -87,7 +136,7 @@ template outputODT() { **** object attrib ***** tags -#+NAME: odt_format_objects +#+NAME: odt_format_objects_0 #+BEGIN_SRC d @safe string _tags(O)(const O obj) { string _tags = ""; @@ -111,7 +160,7 @@ template outputODT() { ****** anchor tags -#+NAME: odt_format_objects +#+NAME: odt_format_objects_1 #+BEGIN_SRC d @safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; @@ -129,7 +178,7 @@ template outputODT() { ***** ocn object number display -#+NAME: odt_format_objects +#+NAME: odt_format_objects_2 #+BEGIN_SRC d @safe string obj_num(O)(const O obj) { // TODO string _on; @@ -145,7 +194,7 @@ template outputODT() { ***** footnotes -#+NAME: odt_format_objects +#+NAME: odt_format_objects_3 #+BEGIN_SRC d @safe string _footnotes()(string _txt) { static auto rgx = RgxO(); @@ -170,7 +219,7 @@ template outputODT() { ***** bullet -#+NAME: odt_format_objects +#+NAME: odt_format_objects_4 #+BEGIN_SRC d @safe string _bullet(O)(const O obj) { string _b = ""; @@ -183,7 +232,7 @@ template outputODT() { ***** para (with bullet, indent levels, footnotes extracted) -#+NAME: odt_format_objects +#+NAME: odt_format_objects_5 #+BEGIN_SRC d @safe string _indent(O)(string _txt, const O obj) { // TODO // if (obj.attrib.indent_base > 0 || @@ -297,7 +346,7 @@ template outputODT() { ***** block type -#+NAME: odt_format_objects +#+NAME: odt_format_objects_6 #+BEGIN_SRC d @safe string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO string _block = ""; @@ -338,7 +387,7 @@ template outputODT() { ***** special characters -#+NAME: odt_format_objects +#+NAME: odt_format_objects_7 #+BEGIN_SRC d @safe string _special_characters(O)(string _txt, const O obj) { _txt = _txt @@ -353,7 +402,7 @@ template outputODT() { ***** preserve white space -#+NAME: odt_format_objects +#+NAME: odt_format_objects_8 #+BEGIN_SRC d @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") { @@ -366,7 +415,7 @@ template outputODT() { ***** font_face -#+NAME: odt_format_objects +#+NAME: odt_format_objects_9 #+BEGIN_SRC d string _font_face(string _txt){ _txt = _txt @@ -386,7 +435,7 @@ string _font_face(string _txt){ ***** object number -#+NAME: odt_format_objects +#+NAME: odt_format_objects_10 #+BEGIN_SRC d @safe auto _obj_num(O)(O obj) { // NOT USED YET struct objNum { @@ -415,7 +464,7 @@ string _font_face(string _txt){ ***** break page -#+NAME: odt_format_objects +#+NAME: odt_format_objects_11 #+BEGIN_SRC d @safe string _break_page()() { return format(q"┃ @@ -436,7 +485,7 @@ string _font_face(string _txt){ ***** empty lines break -#+NAME: odt_format_objects +#+NAME: odt_format_objects_12 #+BEGIN_SRC d @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") { @@ -449,7 +498,7 @@ string _font_face(string _txt){ ***** links: url, mail -#+NAME: odt_format_objects +#+NAME: odt_format_objects_13 #+BEGIN_SRC d @safe string _links(O)(string _txt, const O obj) { if (obj.metainfo.is_a != "code") { @@ -495,7 +544,7 @@ string _font_face(string _txt){ ***** image -#+NAME: odt_format_objects +#+NAME: odt_format_objects_14 #+BEGIN_SRC d @safe string _images(O)(string _txt, const O obj) { if (_txt.match(rgx.inline_image)) { @@ -512,7 +561,7 @@ string _font_face(string _txt){ **** markup hub (including font face) -#+NAME: odt_format_objects +#+NAME: odt_format_objects_15 #+BEGIN_SRC d @safe string markup(O)(const O obj) { /+ markup TODO +/ @@ -534,7 +583,7 @@ string _font_face(string _txt){ **** para type ***** heading -#+NAME: odt_format_objects +#+NAME: odt_format_objects_16 #+BEGIN_SRC d @safe string heading(O,M)( const O obj, @@ -584,7 +633,7 @@ string _font_face(string _txt){ ***** para -#+NAME: odt_format_objects +#+NAME: odt_format_objects_17 #+BEGIN_SRC d @safe string para(O,M)( const O obj, @@ -610,7 +659,7 @@ string _font_face(string _txt){ **** block type ***** quote -#+NAME: odt_format_objects +#+NAME: odt_format_objects_18 #+BEGIN_SRC d @safe string quote(O,M)( const O obj, @@ -631,7 +680,7 @@ string _font_face(string _txt){ - preserves double newlines (paragraph delimiter) - the "group" delimiter is different from the "block" delimiter in that groups do not preserve whitespace, the "block" mark does -#+NAME: odt_format_objects +#+NAME: odt_format_objects_19 #+BEGIN_SRC d @safe string group(O,M)( const O obj, @@ -666,7 +715,7 @@ string _font_face(string _txt){ - "^[ ]"   - count number only at beginning of line and replace each -#+NAME: odt_format_objects +#+NAME: odt_format_objects_20 #+BEGIN_SRC d @safe string block(O,M)( const O obj, @@ -689,7 +738,7 @@ string _font_face(string _txt){ - preserves spaces - preserves newlines -#+NAME: odt_format_objects +#+NAME: odt_format_objects_21 #+BEGIN_SRC d @safe string verse(O,M)( const O obj, @@ -708,7 +757,7 @@ string _font_face(string _txt){ ***** code -#+NAME: odt_format_objects +#+NAME: odt_format_objects_22 #+BEGIN_SRC d @safe string code(O,M)( const O obj, @@ -762,7 +811,7 @@ string _font_face(string _txt){ ***** table ****** tablarize -#+NAME: odt_format_objects +#+NAME: odt_format_objects_23 #+BEGIN_SRC d @safe Tuple!(string, string) tablarize(O)( const O obj, @@ -802,7 +851,7 @@ string _font_face(string _txt){ ****** table -#+NAME: odt_format_objects +#+NAME: odt_format_objects_24 #+BEGIN_SRC d int _table_number = 0; @safe string table(O,M)( @@ -842,7 +891,7 @@ int _table_number = 0; ** write odt output :odf:odt:out: -#+NAME: output_odt +#+NAME: output_odt_0 #+BEGIN_SRC d void writeOutputODT(W,I)( const W odt_content, @@ -931,7 +980,7 @@ void writeOutputODT(W,I)( ** odt output hub [#A] :odf:odt:out: -#+NAME: output_odt +#+NAME: output_odt_1 #+BEGIN_SRC d void outputODT(D,I)( const D doc_abstraction, @@ -1019,13 +1068,13 @@ void dirtree(I)( *** manifest.rdf :manifest_rdf: -#+NAME: output_odt_fixed_manifest_rdf +#+NAME: output_odt_fixed_manifest_rdf_0 #+BEGIN_SRC d @safe string manifest_rdf() { string _manifest_rdf = format(q"┃ #+END_SRC -#+NAME: output_odt_fixed_manifest_rdf +#+NAME: output_odt_fixed_manifest_rdf_1 #+BEGIN_SRC xml @@ -1046,7 +1095,7 @@ void dirtree(I)( #+END_SRC -#+NAME: output_odt_fixed_manifest_rdf +#+NAME: output_odt_fixed_manifest_rdf_2 #+BEGIN_SRC d ┃"); return _manifest_rdf; @@ -1055,13 +1104,13 @@ void dirtree(I)( *** settings.xml :settings: -#+NAME: output_odt_fixed_settings_xml +#+NAME: output_odt_fixed_settings_xml_0 #+BEGIN_SRC d @safe string settings_xml() { string _settings_xml = format(q"┃ #+END_SRC -#+NAME: output_odt_fixed_settings_xml +#+NAME: output_odt_fixed_settings_xml_1 #+BEGIN_SRC xml @@ -1160,7 +1209,7 @@ void dirtree(I)( #+END_SRC -#+NAME: output_odt_fixed_settings_xml +#+NAME: output_odt_fixed_settings_xml_2 #+BEGIN_SRC d ┃"); return _settings_xml; @@ -1169,13 +1218,13 @@ void dirtree(I)( *** styles.xml :styles_xml: -#+NAME: output_odt_fixed_styles_xml +#+NAME: output_odt_fixed_styles_xml_0 #+BEGIN_SRC d @safe string styles_xml() { string _styles_xml = format(q"┃ #+END_SRC -#+NAME: output_odt_fixed_styles_xml +#+NAME: output_odt_fixed_styles_xml_1 #+BEGIN_SRC xml @@ -2070,7 +2119,7 @@ void dirtree(I)( #+END_SRC -#+NAME: output_odt_fixed_styles_xml +#+NAME: output_odt_fixed_styles_xml_2 #+BEGIN_SRC d ┃"); return _styles_xml; @@ -2082,7 +2131,7 @@ void dirtree(I)( **** content head ***** head open -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_0 #+BEGIN_SRC d @safe string odt_head(I)(I doc_matters) { string _has_tables = format(q"┃ @@ -2090,7 +2139,7 @@ void dirtree(I)( ***** if table include within head -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_1 #+BEGIN_SRC xml @@ -2168,7 +2217,7 @@ void dirtree(I)( ***** head -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_2 #+BEGIN_SRC d ┃",); string _odt_head = format(q"┃ @@ -2176,7 +2225,7 @@ void dirtree(I)( ***** head xml -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_3 #+BEGIN_SRC xml @@ -2209,7 +2258,7 @@ void dirtree(I)( ***** head close -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_4 #+BEGIN_SRC d ┃", (doc_matters.has.tables > 0) ? _has_tables : "", @@ -2221,7 +2270,7 @@ void dirtree(I)( **** ↻ content body ***** body open -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_5 #+BEGIN_SRC d @safe string odt_body(D,I)( const D doc_abstraction, @@ -2236,7 +2285,7 @@ void dirtree(I)( ***** ↻ the loop & outer switch (sections & objects) format output -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_6 #+BEGIN_SRC d foreach (part; doc_matters.has.keys_seq.scroll) { foreach (obj; doc_abstraction[part]) { @@ -2245,7 +2294,7 @@ void dirtree(I)( ****** frontmatter -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_7 #+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { @@ -2270,7 +2319,7 @@ void dirtree(I)( ****** body -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_8 #+BEGIN_SRC d case "body": assert(part == "body" || "head"); // surprise switch (obj.metainfo.is_of_type) { @@ -2321,7 +2370,7 @@ void dirtree(I)( ****** backmatter -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_9 #+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); @@ -2371,7 +2420,7 @@ void dirtree(I)( ***** closings & post loop -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_10 #+BEGIN_SRC d } } @@ -2382,13 +2431,13 @@ void dirtree(I)( **** content book index? -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_11 #+BEGIN_SRC d #+END_SRC **** content tail -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_12 #+BEGIN_SRC d @safe string odt_tail() { string _odt_tail = format(q"┃spine: <www.doc_reform.org> and <www.sisudoc.org> @@ -2399,7 +2448,7 @@ void dirtree(I)( **** hub -#+NAME: output_odt_variable_content_xml +#+NAME: output_odt_variable_content_xml_13 #+BEGIN_SRC d @safe string content_xml(D,I)( const D doc_abstraction, @@ -2420,7 +2469,7 @@ void dirtree(I)( - META-INF/manifest.xml - image list changes -#+NAME: output_odt_variable_manifest_xml +#+NAME: output_odt_variable_manifest_xml_0 #+BEGIN_SRC d @safe string manifest_xml(M)( auto ref M doc_matters, @@ -2433,7 +2482,7 @@ void dirtree(I)( string _manifest_xml = format(q"┃ #+END_SRC -#+NAME: output_odt_variable_manifest_xml +#+NAME: output_odt_variable_manifest_xml_1 #+BEGIN_SRC xml @@ -2447,7 +2496,7 @@ void dirtree(I)( #+END_SRC -#+NAME: output_odt_variable_manifest_xml +#+NAME: output_odt_variable_manifest_xml_2 #+BEGIN_SRC d ┃", _images.join("\n"), @@ -2458,7 +2507,7 @@ _images.join("\n"), *** meta.xml (time stamp) :meta_xml: -#+NAME: output_odt_variable_meta_xml +#+NAME: output_odt_variable_meta_xml_0 #+BEGIN_SRC d @safe string meta_xml(M)( auto ref M doc_matters, @@ -2467,7 +2516,7 @@ _images.join("\n"), string _meta_xml = format(q"┃ #+END_SRC -#+NAME: output_odt_variable_meta_xml +#+NAME: output_odt_variable_meta_xml_1 #+BEGIN_SRC xml @@ -2479,7 +2528,7 @@ _images.join("\n"), #+END_SRC -#+NAME: output_odt_variable_meta_xml +#+NAME: output_odt_variable_meta_xml_2 #+BEGIN_SRC d ┃", doc_matters.generator_program.name_and_version, -- cgit v1.2.3