aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta/metadoc_from_src.d
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 /src/doc_reform/meta/metadoc_from_src.d
parentdoc abstraction, state (diff)
doc abstraction, track paragraphs & headings
Diffstat (limited to 'src/doc_reform/meta/metadoc_from_src.d')
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index b354764..d976b60 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -49,10 +49,13 @@ template docAbstraction() {
book_index,
blurb,
}
- enum blk_is {
+ enum txt_is {
off,
para,
heading,
+ }
+ enum blk_is {
+ off,
code,
poem,
block,
@@ -432,6 +435,7 @@ template docAbstraction() {
int[string] pith = [
"ocn" : 1,
"section" : 0,
+ "txt_is" : 0,
"block_is" : 0,
"block_state" : 0,
"block_delim" : 0,
@@ -625,9 +629,9 @@ template docAbstraction() {
"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;
@@ -682,7 +686,7 @@ template docAbstraction() {
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";
@@ -748,8 +752,8 @@ template docAbstraction() {
];
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)) {
{
@@ -828,7 +832,7 @@ template docAbstraction() {
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";
@@ -935,22 +939,22 @@ template docAbstraction() {
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;
- } 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,
@@ -976,7 +980,7 @@ template docAbstraction() {
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);
}
} else if (line_occur["heading"] > eN.bi.off) { /+ heading +/
debug(heading) {
@@ -1024,8 +1028,9 @@ template docAbstraction() {
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"]);
@@ -1141,13 +1146,14 @@ template docAbstraction() {
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");
++cntr;
- } 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)) {
@@ -1197,7 +1203,7 @@ template docAbstraction() {
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,
@@ -2493,13 +2499,11 @@ template docAbstraction() {
@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;
}
@safe static int[string] _check_ocn_status_()(
@@ -3892,11 +3896,11 @@ template docAbstraction() {
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) {
@@ -3956,10 +3960,9 @@ template docAbstraction() {
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];
@@ -4100,7 +4103,6 @@ template docAbstraction() {
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,
) {
@@ -4108,7 +4110,7 @@ template docAbstraction() {
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,