aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2020-05-05 21:25:38 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2020-05-20 11:27:26 -0400
commit953d3afd39f6e559efd46b7e7592a1bec26b3215 (patch)
treede63cdd5ca04899327d34791afd2cccff82d7a81 /org
parentdoc abstraction, state (diff)
doc abstraction, track paragraphs & headings
Diffstat (limited to 'org')
-rw-r--r--org/metaverse.org78
1 files changed, 40 insertions, 38 deletions
diff --git a/org/metaverse.org b/org/metaverse.org
index d368103..f5bfd41 100644
--- a/org/metaverse.org
+++ b/org/metaverse.org
@@ -193,10 +193,13 @@ mixin spineRgxIn;
book_index,
blurb,
}
- enum blk_is {
+ enum txt_is {
off,
para,
heading,
+ }
+ enum blk_is {
+ off,
code,
poem,
block,
@@ -614,6 +617,7 @@ auto obj_type_status = flags_type_init;
int[string] pith = [
"ocn" : 1,
"section" : 0,
+ "txt_is" : 0,
"block_is" : 0,
"block_state" : 0,
"block_delim" : 0,
@@ -849,9 +853,9 @@ if there is a glossary section you need to:
"base_position" : 0,
];
bullet = false;
- obj_type_status["para"] = eN.bi.on;
- line_occur["para"] = eN.bi.off;
- an_object_key="glossary_nugget"; //
+ pith["txt_is"] = eN.txt_is.para;
+ line_occur["para"] = eN.bi.off;
+ an_object_key="glossary_nugget";
if (line.matchFirst(rgx.heading_glossary)) {
{
comp_obj_heading_ = comp_obj_heading_.init;
@@ -906,7 +910,7 @@ if there is a glossary section you need to:
tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
}
} else {
- an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, pith, line_occur);
+ an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
comp_obj_para = comp_obj_para.init;
comp_obj_para.metainfo.is_of_part = "backmatter";
comp_obj_para.metainfo.is_of_section = "glossary";
@@ -985,8 +989,8 @@ if there is a blurb section you need to:
];
bullet = true;
}
- obj_type_status["para"] = eN.bi.on;
- line_occur["para"] = eN.bi.off;
+ pith["txt_is"] = eN.txt_is.para;
+ line_occur["para"] = eN.bi.off;
an_object_key="blurb_nugget";
if (line.matchFirst(rgx.heading_blurb)) {
{
@@ -1065,7 +1069,7 @@ if there is a blurb section you need to:
tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html;
tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
} else {
- an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, pith, line_occur);
+ an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
comp_obj_para = comp_obj_para.init;
comp_obj_para.metainfo.is_of_part = "backmatter";
comp_obj_para.metainfo.is_of_section = "blurb";
@@ -1242,7 +1246,7 @@ if (line.matchFirst(rgx.book_index_item)
comp_obj_comment.metainfo.is_a = "comment";
comp_obj_comment.text = an_object[an_object_key].strip;
the_document_body_section ~= comp_obj_comment;
- flow_common_reset_(line_occur, an_object, obj_type_status, pith);
+ flow_common_reset_(line_occur, an_object, pith);
processing.remove("verse");
++cntr;
#+END_SRC
@@ -1251,19 +1255,19 @@ if (line.matchFirst(rgx.book_index_item)
#+NAME: abs_in_loop_body_not_block_obj
#+BEGIN_SRC d
- } else if (((line_occur["para"] == eN.bi.off)
- && (line_occur["heading"] == eN.bi.off))
- && ((obj_type_status["para"] == eN.bi.off)
- && (obj_type_status["heading"] == eN.bi.off))) { /+ heading or para but neither flag nor line exists +/
+ } else if ((line_occur["para"] == eN.bi.off
+ && line_occur["heading"] == eN.bi.off)
+ && pith["txt_is"] == eN.txt_is.off
+ ) { /+ heading or para but neither flag nor line exists +/
if ((conf_make_meta.make.headings.length > 2)
&& (obj_type_status["make_headings"] == eN.bi.off)) { /+ heading found +/
heading_match_str = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, obj_type_status, pith);
}
- if ((obj_type_status["make_headings"] == eN.bi.on)
- && ((line_occur["para"] == eN.bi.off)
- && (line_occur["heading"] == eN.bi.off))
- && ((obj_type_status["para"] == eN.bi.off)
- && (obj_type_status["heading"] == eN.bi.off))) { /+ heading make set +/
+ if (obj_type_status["make_headings"] == eN.bi.on
+ && (line_occur["para"] == eN.bi.off
+ && line_occur["heading"] == eN.bi.off)
+ && pith["txt_is"] == eN.txt_is.off
+ ) { /+ heading make set +/
line = line.flow_heading_make_set_(line_occur, heading_match_rgx, obj_type_status, pith);
}
/+ TODO node info: all headings identified at this point,
@@ -1289,7 +1293,7 @@ if (line.matchFirst(rgx.book_index_item)
line = line
._doc_header_and_make_substitutions_(conf_make_meta)
._doc_header_and_make_substitutions_fontface_(conf_make_meta);
- an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, pith, line_occur);
+ an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
}
#+END_SRC
@@ -1366,8 +1370,9 @@ if (_new_doc) {
lv0_to_3_tags = lv0_to_3_tags.init;
tag_in_seg = tag_in_seg.init;
}
-if ((obj_type_status["heading"] == eN.bi.on)
-&& (line_occur["heading"] > eN.bi.off)) { /+ heading object (current line empty) +/
+if (pith["txt_is"] == eN.txt_is.heading
+ && line_occur["heading"] > eN.bi.off
+) { /+ heading object (current line empty) +/
obj_cite_digits = (an_object["lev_markup_number"].to!int == 0)
? ocn_emit(eN.ocn.reset)
: ocn_emit(pith["ocn"]);
@@ -1483,7 +1488,7 @@ if ((obj_type_status["heading"] == eN.bi.on)
debug(objectrelated1) { // check
writeln(line);
}
- flow_common_reset_(line_occur, an_object, obj_type_status, pith);
+ flow_common_reset_(line_occur, an_object, pith);
an_object.remove("lev");
an_object.remove("lev_markup_number");
processing.remove("verse");
@@ -1494,8 +1499,9 @@ if ((obj_type_status["heading"] == eN.bi.on)
#+NAME: abs_in_loop_body_not_block_obj_line_empty
#+BEGIN_SRC d
-} else if ((obj_type_status["para"] == eN.bi.on)
-&& (line_occur["para"] > eN.bi.off)) {
+} else if (pith["txt_is"] == eN.txt_is.para
+ && line_occur["para"] > eN.bi.off
+) {
/+ paragraph object (current line empty) +/
/+ repeated character paragraph separator +/
if ((an_object[an_object_key].to!string).matchFirst(rgx.repeated_character_line_separator)) {
@@ -1545,7 +1551,7 @@ if ((obj_type_status["heading"] == eN.bi.on)
comp_obj_para.has.image_without_dimensions = substantive_obj_misc_tuple[sObj.image_no_dimensions];
the_document_body_section ~= comp_obj_para;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
- flow_common_reset_(line_occur, an_object, obj_type_status, pith);
+ flow_common_reset_(line_occur, an_object, pith);
indent=[
"hang_position" : 0,
"base_position" : 0,
@@ -3193,13 +3199,11 @@ functions used in document abstraction
@system void flow_common_reset_()(
return ref int[string] line_occur,
return ref string[string] an_object,
- return ref int[string] obj_type_status,
return ref int[string] pith,
) {
line_occur["heading"] = eN.bi.off;
line_occur["para"] = eN.bi.off;
- obj_type_status["heading"] = eN.bi.off;
- obj_type_status["para"] = eN.bi.off;
+ pith["txt_is"] = eN.txt_is.off;
an_object = an_object.object_reset;
}
#+END_SRC
@@ -4893,11 +4897,11 @@ process and use an_object["table_head"] (then empty it)
return ref int[string] obj_type_status,
return ref int[string] pith,
) {
- if ((obj_type_status["make_headings"] == eN.bi.on)
- && ((line_occur["para"] == eN.bi.off)
- && (line_occur["heading"] == eN.bi.off))
- && ((obj_type_status["para"] == eN.bi.off)
- && (obj_type_status["heading"] == eN.bi.off))) { /+ heading make set +/
+ if (obj_type_status["make_headings"] == eN.bi.on
+ && (line_occur["para"] == eN.bi.off
+ && line_occur["heading"] == eN.bi.off)
+ && pith["txt_is"] == eN.txt_is.off
+ ) { /+ heading make set +/
if (line.matchFirst(heading_match_rgx["h_B"])) {
line = "B~ " ~ line;
debug(headingsfound) {
@@ -4963,10 +4967,9 @@ process and use an_object["table_head"] (then empty it)
static auto rgx = RgxI();
if (auto m = line.match(rgx.headings)) { /+ heading match +/
++line_occur["heading"];
- obj_type_status["heading"] = eN.bi.on;
- obj_type_status["para"] = eN.bi.off;
+ pith["txt_is"] = eN.txt_is.heading;
if (line.match(rgx.heading_seg_and_above)) {
- pith["section"] = eN.sect.unset;
+ pith["section"] = eN.sect.unset;
}
an_object[an_object_key] ~= line ~= "\n";
an_object["lev"] ~= m.captures[1];
@@ -5113,7 +5116,6 @@ process and use an_object["table_head"] (then empty it)
return ref string an_object_key,
return ref int[string] indent,
return ref bool bullet,
- return ref int[string] obj_type_status,
return ref int[string] pith,
return ref int[string] line_occur,
) {
@@ -5121,7 +5123,7 @@ process and use an_object["table_head"] (then empty it)
if (line_occur["para"] == eN.bi.off) {
line = font_faces_line(line);
/+ para matches +/
- obj_type_status["para"] = eN.bi.on;
+ pith["txt_is"] = eN.txt_is.para;
an_object[an_object_key] ~= line;
indent=[
"hang_position" : 0,