From 10a66c974537dcb984217a6c581fc20fa7144db4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 21 Jan 2024 01:15:34 -0500 Subject: org, ocda (ongoing) split file, separate functions --- org/ocda_obj_setter.org | 352 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 269 insertions(+), 83 deletions(-) (limited to 'org/ocda_obj_setter.org') diff --git a/org/ocda_obj_setter.org b/org/ocda_obj_setter.org index 5d65ecd..4791dcf 100644 --- a/org/ocda_obj_setter.org +++ b/org/ocda_obj_setter.org @@ -35,37 +35,18 @@ set abstracted objects for downstream processing module doc_reform.meta.metadoc_object_setter; template ObjectSetter() { /+ structs +/ - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> + <> + <> + <> + <> + <> } #+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 +#+NAME: meta_structs_docObjectMeta #+BEGIN_SRC d struct DocObj_MetaInfo_ { string is_of_part = ""; // frontmatter, body, backmatter @@ -103,19 +84,6 @@ struct DocObj_MetaInfo_ { @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) { @@ -131,6 +99,19 @@ struct DocObj_MetaInfo_ { } return _out; } + @safe string object_number() const @property { + return (ocn == 0) ? "" : ocn.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 = ""; + int o_n_type = 0; + int heading_lev_markup = 9; + int heading_lev_collapsed = 9; 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,]; @@ -138,13 +119,13 @@ struct DocObj_MetaInfo_ { 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; + int last_descendant_ocn = 0; } #+END_SRC -**** object text attributes +*** doc objects -#+NAME: meta_structs_init_docObj_txtAttrib +#+NAME: meta_structs_docObjects #+BEGIN_SRC d struct DocObj_TxtAttrib_ { int indent_base = 0; @@ -152,12 +133,6 @@ struct DocObj_TxtAttrib_ { 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; @@ -165,12 +140,6 @@ struct DocObj_Has_ { 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 = []; @@ -178,42 +147,18 @@ struct DocObj_Table_ { 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 = ""; @@ -229,9 +174,9 @@ struct DocObj_Tags_ { } #+END_SRC -**** composite object the parts +*** the doc -#+NAME: meta_structs_init_docObj_composite +#+NAME: meta_structs_doc #+BEGIN_SRC d struct ObjGenericComposite { string text = ""; @@ -244,14 +189,255 @@ struct ObjGenericComposite { DocObj_Stow_ stow; DocObj_Pointer_ ptr; } +struct _theDoc { + ObjGenericComposite[] toc; + ObjGenericComposite[] head; + ObjGenericComposite[] body; + ObjGenericComposite[] bibliography; + ObjGenericComposite[] glossary; + ObjGenericComposite[] bookindex; + ObjGenericComposite[] blurb; + ObjGenericComposite[] endnotes; +} +struct TheObjects { + ObjGenericComposite[] oca; +} +ObjGenericComposite comp_obj_, comp_obj_location, comp_obj_poem_ocn, comp_obj_comment; +ObjGenericComposite[] the_document_toc_section, the_document_head_section, the_document_body_section, the_document_endnotes_section, the_document_bibliography_section, the_document_bookindex_section, the_document_glossary_section, the_document_blurb_section, the_document_xml_dom_tail_section; #+END_SRC -*** The Objects: generic composite object array +*** structs -#+NAME: meta_structs_init_docObj_theObjects +#+NAME: meta_structs #+BEGIN_SRC d -struct TheObjects { - ObjGenericComposite[] oca; +struct OCNset { + int digit; + int object_number; + bool off; + string identifier; + int bkidx; + int type; +} +struct ST_endnotes { + ObjGenericComposite[] endnotes; + OCNset ocn; +} +struct ST_bookindex { + ObjGenericComposite[] bookindex; + OCNset ocn; +} +struct ST_biblio_section { + ObjGenericComposite[] bibliography_section; + string[string][string] tag_assoc; +} +struct ST_ancestors { + ObjGenericComposite[] the_document_body_section; + ObjGenericComposite[] the_document_endnotes_section; + ObjGenericComposite[] the_document_glossary_section; + ObjGenericComposite[] the_document_bibliography_section; + ObjGenericComposite[] the_document_bookindex_section; + ObjGenericComposite[] the_document_blurb_section; +} +struct ST_segnames { + string[][string] segnames; + int html_segnames_ptr_cntr; + int html_segnames_ptr; +} +struct ST_txtPlusHasFootnotes { + string obj_txt; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; +} +struct ST_txtPlusHasFootnotesUrlsImages { + string obj_txt; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; + bool has_urls; + bool has_images_without_dimensions; +} +struct ST_txtAndAnchorTagPlusHasFootnotesUrlsImages { + string obj_txt; + string anchor_tag; + bool has_notes_reg; + bool has_notes_star; + bool has_notes_plus; + bool has_links; // use same name + bool has_images_without_dimensions; +} +struct ST_the_section { + ObjGenericComposite[] comp_section_obj; // array: the heading has 2 members inserted, paras just 1 + uint[string] pith; + string[string][string] tag_assoc; // only for headings: html & epub +} +// book index variables +string book_idx_tmp; +string[][string][string] bookindex_unordered_hashes; +// node +struct ST_txt_by_line_common_reset { + int[string] line_occur; + string[string] this_object; + uint[string] pith; +} +struct ST_txt_by_line_block_start { + uint[string] pith; + uint[string] dochas; + string[string] object_number_poem; +} +struct ST_txt_by_line_block_generic { + uint[string] pith; + string[string] this_object; +} +struct ST_txt_by_line_block_poem { + int cntr; + uint[string] pith; + string[string] this_object; +} +struct ST_txt_by_line_block_biblio { + uint[string] pith; + int bib_entry; + string biblio_entry_str_json; + string[] biblio_arr_json; +} +struct ST_flow_book_index { + string[string] this_object; + uint[string] pith; + string book_idx_tmp; +} +struct ST_flow_heading_found { + string[string] heading_match_str; + Regex!(char)[string] heading_match_rgx; + uint[string] pith; +} +struct ST_flow_heading_make_set { + char[] line; + uint[string] pith; + string[string] this_object; +} +struct ST_flow_para_match { + uint[string] pith; + string[string] this_object; + string this_object_key; + int[string] indent; + bool bullet; + int[string] line_occur; +} +struct ST_flow_table_array_munge { + ObjGenericComposite table_object; + string[][] table_array; +} +struct ST_flow_table_of_contents_gather_headings { + ObjGenericComposite[] the_document_toc_section; + string[][string] lev4_subtoc; +} +struct ST_flow_bibliography { + JSONValue[] biblio_sorted; + JSONValue[] bib_arr_json; + string[] biblio_unsorted_incomplete; +} +struct ST_flow_table_closed_make_special_notation_table { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_; + int cntr; + uint[string] pith; +} +struct ST_flow_block_flag_line_empty { + string[string] this_object; + ObjGenericComposite[] the_document_body_section; + string[][string][string] bookindex_unordered_hashes; + OCNset obj_cite_digits; + ObjGenericComposite comp_obj_; + int cntr; + uint[string] pith; +} +struct ST_flow_table_substantive_munge { + ObjGenericComposite table_object; + string table_substantive; +} +struct _loopMarkupSrcByLineStruct { + ObjGenericComposite[] toc; + ObjGenericComposite[] body; + ObjGenericComposite[] glossary; + ObjGenericComposite[] blurb; + string[string] object_notes; + string[][string] segnames; +} +#+END_SRC + +*** enums + +#+NAME: meta_enum +#+BEGIN_SRC d +enum DocStructMarkupHeading { + h_sect_A, + h_sect_B, + h_sect_C, + h_sect_D, + h_text_1, + h_text_2, + h_text_3, + h_text_4, + h_text_5, // extra level, drop + content_non_header +} // header section A-D; header text 1-4 +enum Status { off, on, } +enum OCNtype { ocn, non, bkidx, } +enum DomTags { none, open, close, close_and_open, open_still, } +enum Substitute { match, markup, } +@safe static auto eN() { + struct _e { + enum bi { + off, + on, + } + enum ocn { + off, + on, + closing, + bkidx, + reset, + } + enum sect { + unset, + head, + toc, + substantive, + bibliography, + glossary, + book_index, + blurb, + } + enum txt_is { + off, + para, + heading, + } + enum blk_is { + off, + code, + poem, + block, + group, + table, + quote, + } + enum blk_state { + off, + on, + closing, + } + enum blk_delim { + off, + curly, + tic, + curly_special, + tic_special, + } + } + return _e(); } #+END_SRC -- cgit v1.2.3