diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2023-11-15 22:16:26 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2023-11-15 22:26:07 -0500 |
commit | d2a94f93c3fe24d673eb812e1457829701c1ddfe (patch) | |
tree | 2bda2dae74b593c8d24e2d233f16a61186feb305 /org/ocda_obj_setter.org | |
parent | 0.13.0 (diff) |
ocda, single out, use more structs
Diffstat (limited to 'org/ocda_obj_setter.org')
-rw-r--r-- | org/ocda_obj_setter.org | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/org/ocda_obj_setter.org b/org/ocda_obj_setter.org new file mode 100644 index 0000000..f499adf --- /dev/null +++ b/org/ocda_obj_setter.org @@ -0,0 +1,313 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) object-centric document abstraction +#+DESCRIPTION: documents - structuring, publishing in multiple formats & search +#+FILETAGS: :spine:abstraction: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2023 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :noweb yes +#+PROPERTY: header-args+ :exports code +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +- [[./doc-reform.org][doc-reform.org]] [[./][org/]] + +* Object Setter (Set Abstract Object) :module:spine:metadoc_object_setter: + +set abstracted objects for downstream processing + +** _module template_ + +#+HEADER: :tangle "../src/doc_reform/meta/metadoc_object_setter.d" +#+HEADER: :noweb yes +#+BEGIN_SRC d +<<doc_header_including_copyright_and_license>> +/++ + object setter: + setting of sisu objects for downstream processing + metadoc_object_setter.d ++/ +module doc_reform.meta.metadoc_object_setter; +template ObjectSetter() { + /+ structs +/ + <<meta_structs_init_docObj_metainfo>> + <<meta_structs_init_docObj_txtAttrib>> + <<meta_structs_init_docObj_has>> + <<meta_structs_init_docObj_table>> + <<meta_structs_init_docObj_code_block>> + <<meta_structs_init_docObj_stow>> + <<meta_structs_init_docObj_pointer>> + <<meta_structs_init_docObj_tags>> + <<meta_structs_init_docObj_composite>> + <<meta_structs_init_docObj_theObjects>> +} +#+END_SRC + +** initialize structs :struct: +*** heading attribute + +#+BEGIN_SRC d +struct HeadingAttrib { + string lev = "9"; + int heading_lev_markup = 9; + int heading_lev_collapsed = 9; + int[] closes_lev_collapsed = []; + int[] closes_lev_markup = []; + int array_ptr = 0; + int heading_array_ptr_segments = 0; +} +#+END_SRC + +*** _composite object_ [#A] + +#+NAME: meta_structs_init_docObj_metainfo +#+BEGIN_SRC d +struct DocObj_MetaInfo_ { + string is_of_part = ""; // frontmatter, body, backmatter + string is_of_section = ""; // toc, body, glossary, biography, book index, blurb + string is_of_type = ""; // para, block ? + string is_a = ""; // heading, para, table, code block, group, verse/poem ... + alias of_part = is_of_part; + alias of_section = is_of_section; + alias is_of = is_of_type; + string attrib = ""; + string lang = ""; // blocks: group, block, quote; not codeblock; + string syntax = ""; // codeblock only + /+ o_n +/ + int o_n_substantive = 0; + int o_n_non_substantive = 0; + int o_n_glossary = 0; + int o_n_bibliography = 0; + int o_n_book_index = 0; + int o_n_blurb = 0; + @safe string object_number_substantive() const @property { + return (o_n_substantive == 0) ? "" : o_n_substantive.to!string; + } + @safe string object_number_non_substantive() const @property { + return (o_n_non_substantive == 0) ? "" : o_n_non_substantive.to!string; + } + @safe string object_number_glossary() const @property { + return (o_n_glossary == 0) ? "" : o_n_glossary.to!string; + } + @safe string object_number_bibliography() const @property { + return (o_n_bibliography == 0) ? "" : o_n_bibliography.to!string; + } + @safe string object_number_book_index() const @property { + return (o_n_book_index == 0) ? "" : o_n_book_index.to!string; + } + @safe string object_number_blurb() const @property { + return (o_n_blurb == 0) ? "" : o_n_blurb.to!string; + } + bool object_number_off = false; + bool visible_object_number = false; + int object_number_type = 0; // { ocn, non, bkidx } + /+ node +/ + string[string][string] node; + int ocn = 0; + string identifier = ""; + @safe string object_number() const @property { + return (ocn == 0) ? "" : ocn.to!string; + } + int o_n_type = 0; + int heading_lev_markup = 9; + int heading_lev_collapsed = 9; + @safe string marked_up_level() const @property { + string _out; + switch (heading_lev_markup) { + case 0 : _out = "A"; break; + case 1 : _out = "B"; break; + case 2 : _out = "C"; break; + case 3 : _out = "D"; break; + case 4 : _out = "1"; break; + case 5 : _out = "2"; break; + case 6 : _out = "3"; break; + case 7 : _out = "4"; break; + default : _out = ""; break; // "9"; + } + return _out; + } + bool dummy_heading = false; + int[] markedup_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] collapsed_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int parent_lev_markup = 0; + int parent_ocn = 0; + int last_decendant_ocn = 0; +} +#+END_SRC + +**** object text attributes + +#+NAME: meta_structs_init_docObj_txtAttrib +#+BEGIN_SRC d +struct DocObj_TxtAttrib_ { + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; +} +#+END_SRC + +**** object has within it + +#+NAME: meta_structs_init_docObj_has +#+BEGIN_SRC d +struct DocObj_Has_ { + bool inline_links = false; + bool inline_notes_reg = false; + bool inline_notes_star = false; + bool images = false; + bool image_without_dimensions = false; +} +#+END_SRC + +**** table attributes + +#+NAME: meta_structs_init_docObj_table +#+BEGIN_SRC d +struct DocObj_Table_ { + int number_of_columns = 0; + double[] column_widths = []; + string[] column_aligns = []; + bool heading = false; + bool walls = false; +} +#+END_SRC + +**** code attributes + +#+NAME: meta_structs_init_docObj_code_block +#+BEGIN_SRC d +struct DocObj_CodeBlock_ { + string syntax = ""; + bool linenumbers = false; +} +#+END_SRC + +**** stow (things to be protected from regular text transformations, so far links) + +#+NAME: meta_structs_init_docObj_stow +#+BEGIN_SRC d +struct DocObj_Stow_ { + string[] link = []; +} +#+END_SRC + +**** pointers + +#+NAME: meta_structs_init_docObj_pointer +#+BEGIN_SRC d +struct DocObj_Pointer_ { + int doc_object = 0; + int html_segnames = 0; + int heading = 0; +} +#+END_SRC + +**** tags + +#+NAME: meta_structs_init_docObj_tags +#+BEGIN_SRC d +struct DocObj_Tags_ { + string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; + string anchor_tag_html = ""; + string in_segment_html = ""; + string segment_anchor_tag_epub = ""; + string html_segment_anchor_tag_is = ""; + string epub_segment_anchor_tag_is = ""; + string heading_lev_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; + string[] lev4_subtoc = []; + string[] anchor_tags = []; +} +#+END_SRC + +**** composite object the parts + +#+NAME: meta_structs_init_docObj_composite +#+BEGIN_SRC d +struct ObjGenericComposite { + string text = ""; + DocObj_MetaInfo_ metainfo; + DocObj_TxtAttrib_ attrib; + DocObj_Tags_ tags; + DocObj_Has_ has; + DocObj_Table_ table; + DocObj_CodeBlock_ code_block; + DocObj_Stow_ stow; + DocObj_Pointer_ ptr; +} +#+END_SRC + +*** The Objects: generic composite object array + +#+NAME: meta_structs_init_docObj_theObjects +#+BEGIN_SRC d +struct TheObjects { + ObjGenericComposite[] oca; +} +#+END_SRC + +* document header including copyright & license + +#+NAME: doc_header_including_copyright_and_license +#+BEGIN_SRC text +/+ +- Name: Spine, Doc Reform [a part of] + - Description: documents, structuring, processing, publishing, search + - static content generator + + - Author: Ralph Amissah + [ralph.amissah@gmail.com] + + - Copyright: (C) 2015 - 2023 Ralph Amissah, All Rights Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see [https://www.gnu.org/licenses/]. + + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.doc_reform.org] + [https://www.sisudoc.org] + + - Git + [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] + ++/ +#+END_SRC + +* __END__ |