aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_abstract_doc_source.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/ao_abstract_doc_source.d')
-rw-r--r--src/sdp/ao_abstract_doc_source.d105
1 files changed, 66 insertions, 39 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index fd4afa7..9bfa6cb 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -48,7 +48,7 @@ template SiSUdocAbstraction() {
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 +/
@@ -479,7 +479,7 @@ template SiSUdocAbstraction() {
debug(para) {
writeln(line);
}
- an_object[an_object_key] ~= line;
+ an_object[an_object_key] ~= " " ~ line;
++line_occur["para"];
}
}
@@ -624,16 +624,21 @@ template SiSUdocAbstraction() {
/+ 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,
@@ -972,7 +977,7 @@ template SiSUdocAbstraction() {
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);
}
}
the_document_head_section ~= the_document_body_section[0];
@@ -2333,6 +2338,7 @@ template SiSUdocAbstraction() {
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();
@@ -2387,7 +2393,7 @@ template SiSUdocAbstraction() {
}
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(
@@ -2396,28 +2402,36 @@ template SiSUdocAbstraction() {
(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 { }
@@ -2440,7 +2454,7 @@ template SiSUdocAbstraction() {
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);
}
@@ -3449,8 +3463,9 @@ template SiSUdocAbstraction() {
// 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,
@@ -3459,9 +3474,13 @@ template SiSUdocAbstraction() {
}
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], " ",
@@ -3469,16 +3488,24 @@ template SiSUdocAbstraction() {
}
// 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;
}