aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/ao_abstract_doc_source.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-11-25 18:19:24 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:13 -0400
commit19d648a891b3cb9c7d573911f83d3a9fafe2b434 (patch)
treeabd0ee081fe2058f04bf58b7b14ac0fb3295c571 /org/ao_abstract_doc_source.org
parentmunge links & urls for sections: toc, endnotes, book index (diff)
housekeeping
Diffstat (limited to 'org/ao_abstract_doc_source.org')
-rw-r--r--org/ao_abstract_doc_source.org105
1 files changed, 66 insertions, 39 deletions
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org
index 4934a5a..b3c4cd6 100644
--- a/org/ao_abstract_doc_source.org
+++ b/org/ao_abstract_doc_source.org
@@ -75,7 +75,7 @@ string biblio_entry_str_json;
JSONValue[] bib_arr_json;
int bib_entry;
/+ counters +/
-long counter, previous_count;
+long counter, previous_count, previous_length;
int[string] line_occur;
int verse_line, heading_pointer;
/+ paragraph attributes +/
@@ -639,7 +639,7 @@ if ((matchFirst(line, rgx.book_index))
debug(para) {
writeln(line);
}
- an_object[an_object_key] ~= line;
+ an_object[an_object_key] ~= " " ~ line;
++line_occur["para"];
}
}
@@ -810,16 +810,21 @@ if ((type["heading"] == State.on)
/+ unless (the_document_body_section.length == 0) ? +/
if (the_document_body_section.length > 0) {
if (((the_document_body_section[$-1].is_a == "para")
- || (the_document_body_section[$-1].is_a == "heading"))
- && (counter-1 > previous_count)) {
+ || (the_document_body_section[$-1].is_a == "heading")
+ || (the_document_body_section[$-1].is_a == "group"))
+ && (the_document_body_section.length > previous_length)
+) {
if ((the_document_body_section[$-1].is_a == "heading")
&& (the_document_body_section[$-1].heading_attrib.lev_markup_number < 5)) {
type["biblio_section"] = State.off;
type["glossary_section"] = State.off;
type["blurb_section"] = State.off;
}
- if (match(the_document_body_section[$-1].object,
- rgx.inline_notes_delimiter_al_regular_number_note)) {
+ previous_length = the_document_body_section.length;
+ if (
+ match(the_document_body_section[$-1].object,
+ rgx.inline_notes_delimiter_al_regular_number_note)
+ ) {
previous_count=the_document_body_section.length -1;
note_section.gather_notes_for_endnote_section(
the_document_body_section,
@@ -1246,7 +1251,7 @@ debug(toc) {
the_table_of_contents_section["seg"].length
);
foreach (toc_linked_heading; the_table_of_contents_section["seg"]) {
- writeln(toc_linked_heading.object);
+ writeln(mkup.indent_by_spaces_provided(toc_linked_heading.para_attrib.indent_start), toc_linked_heading.object);
}
}
#+END_SRC
@@ -2832,6 +2837,7 @@ struct OCNemitter {
struct ObjInlineMarkupMunge {
string[string] obj_txt;
int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus;
+ string asterisks_;
string obj_txt_out, tail, note;
auto rgx = Rgx();
auto mkup = InlineMarkup();
@@ -2886,7 +2892,7 @@ struct ObjInlineMarkupMunge {
}
return obj_txt_in;
}
- string footnotes_endnotes(string obj_txt_in) {
+ string footnotes_endnotes_markup_and_number_or_stars(string obj_txt_in) {
/+ endnotes (regular) +/
obj_txt_in =
replaceAll(
@@ -2895,28 +2901,36 @@ struct ObjInlineMarkupMunge {
(mkup.en_a_o ~ " $1" ~ mkup.en_a_c)
);
if (match(obj_txt_in, rgx.inline_notes_al_gen)) {
- foreach(m; matchAll(obj_txt_in, rgx.inline_text_and_note_al)) {
- if (match(obj_txt_in, rgx.inline_al_delimiter_open_asterisk)) {
- ++n_foot_sp_asterisk;
- n_foot=n_foot_sp_asterisk;
- } else if (match(obj_txt_in, rgx.inline_al_delimiter_open_plus)) {
- ++n_foot_sp_plus;
- n_foot=n_foot_sp_plus;
- } else {
- ++n_foot_reg;
- n_foot=n_foot_reg;
+ if (auto m = matchAll(obj_txt_in, rgx.inline_text_and_note_al_)) {
+ foreach(n; m) {
+ if (match(to!string(n.hit), rgx.inline_al_delimiter_open_symbol_star)) {
+ ++n_foot_sp_asterisk;
+ asterisks_ = "*";
+ n_foot=n_foot_sp_asterisk;
+ obj_txt_out ~=
+ (replaceFirst(
+ to!string(n.hit),
+ rgx.inline_al_delimiter_open_symbol_star,
+ (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ")
+ ) ~ "\n");
+ } else if (match(to!string(n.hit), rgx.inline_al_delimiter_open_regular)) {
+ ++n_foot_reg;
+ n_foot=n_foot_reg;
+ obj_txt_out ~=
+ (replaceFirst(
+ to!string(n.hit),
+ rgx.inline_al_delimiter_open_regular,
+ (mkup.en_a_o ~ to!string(n_foot) ~ " ")
+ ) ~ "\n");
+ } else {
+ obj_txt_out ~= to!string(n.hit) ~ "\n";
+ }
}
- obj_txt_out ~= replaceFirst(
- m.hit,
- rgx.inline_al_delimiter_open_regular,
- (mkup.en_a_o ~ to!string(n_foot))
- );
- tail = m.post;
}
} else {
obj_txt_out = obj_txt_in;
}
- return obj_txt_in;
+ return obj_txt_out;
}
private auto object_notes_(string obj_txt_in)
in { }
@@ -2939,7 +2953,7 @@ struct ObjInlineMarkupMunge {
if (auto m = matchAll(obj_txt_in, rgx.inline_url)) {
obj_txt_in = url_links(obj_txt_in);
}
- obj_txt_in = footnotes_endnotes(obj_txt_in);
+ obj_txt_out = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in);
debug(footnotes) {
writeln(obj_txt_out, tail);
}
@@ -4144,8 +4158,9 @@ struct NotesSection {
// doc objects other than paragraphs & headings
// various forms of grouped text
assert((contents_am[counter].is_a == "para")
- || (contents_am[counter].is_a == "heading"));
- assert(counter > previous_count);
+ || (contents_am[counter].is_a == "heading")
+ || (contents_am[counter].is_a == "group"));
+ assert(counter >= previous_count);
previous_count=counter;
assert(
match(contents_am[counter].object,
@@ -4154,9 +4169,13 @@ struct NotesSection {
}
body {
auto munge = ObjInlineMarkupMunge();
- foreach(m;
- matchAll(contents_am[counter].object,
- rgx.inline_notes_delimiter_al_regular_number_note)) {
+ foreach(
+ m;
+ matchAll(
+ contents_am[counter].object,
+ rgx.inline_notes_delimiter_al_regular_number_note
+ )
+ ) {
debug(endnotes_build) {
writeln(
"{^{", m.captures[1], ".}^}../", segment_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ",
@@ -4164,16 +4183,24 @@ struct NotesSection {
}
// TODO NEXT you need anchor for segments at this point ->
object_notes["seg"] ~=
- munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
- m.captures[1]) ~ " " ~ m.captures[2] ~ "』";
+ munge.url_links(
+ "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
+ m.captures[1]
+ ) ~ " " ~ m.captures[2] ~ "』";
object_notes["seg"] ~= (segment_object_belongs_to.empty)
- ? (munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
- m.captures[1]) ~ " " ~ m.captures[2] ~ "』")
- : (munge.url_links("{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~
- m.captures[1]) ~ " " ~ m.captures[2] ~ "』");
+ ? (munge.url_links(
+ "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
+ m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
+ )
+ : (munge.url_links(
+ "{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~
+ m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
+ );
object_notes["scroll"] ~=
- munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
- m.captures[1]) ~ " " ~ m.captures[2] ~ "』";
+ munge.url_links(
+ "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
+ m.captures[1]
+ ) ~ " " ~ m.captures[2] ~ "』";
}
return object_notes;
}