From 19d648a891b3cb9c7d573911f83d3a9fafe2b434 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Nov 2016 18:19:24 -0500 Subject: housekeeping --- org/ao_abstract_doc_source.org | 105 ++++++++++++++++++++++++++--------------- org/ao_defaults.org | 54 +++++++-------------- org/output.org | 16 +++---- 3 files changed, 90 insertions(+), 85 deletions(-) (limited to 'org') 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; } diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 20952fb..8dde679 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -437,42 +437,17 @@ template InternalMarkup() { auto en_b_o = "〖"; auto en_b_c = "〗"; // endnote en_b_o: '~['; en_b_c: ']~'; auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; - string _indent_spaces =""; + auto nbsp = "░"; + auto br_line = "┘"; + auto br_nl = "┙"; + auto br_paragraph = "┚"; + auto br_obj = "break_obj"; + auto br_page_line = "┼"; + auto br_page = "┿"; + auto br_page_new = "╂"; string indent_by_spaces_provided(int indent) { - switch (indent) { - case 0: - _indent_spaces = ""; - break; - case 1: - _indent_spaces = " "; - break; - case 2: - _indent_spaces = " "; - break; - case 3: - _indent_spaces = " "; - break; - case 4: - _indent_spaces = " "; - break; - case 5: - _indent_spaces = " "; - break; - case 6: - _indent_spaces = " "; - break; - case 7: - _indent_spaces = " "; - break; - case 8: - _indent_spaces = " "; - break; - case 9: - _indent_spaces = " "; - break; - default: - break; - } + auto _indent_spaces ="░░"; // auto nbsp = "░"; + _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; } } @@ -687,14 +662,17 @@ static note_ref = ctRegex!(`^\S+?noteref_( /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); -static inline_al_delimiter_open_regular = ctRegex!(`【`, "m"); +static inline_al_delimiter_open_regular = ctRegex!(`【\s`, "m"); +static inline_al_delimiter_open_symbol_star = ctRegex!(`【[*]\s`, "m"); +static inline_al_delimiter_open_symbol_plus = ctRegex!(`【[+]\s`, "m"); static inline_al_delimiter_close_regular = ctRegex!(`】`, "m"); static inline_al_delimiter_open_and_close_regular = ctRegex!(`【|】`, "m"); -static inline_notes_delimiter_al_regular = ctRegex!(`【(.+?)】`, "m"); -static inline_notes_delimiter_al_regular_number_note = ctRegex!(`【(\d+)\s+(.+?)】`, "m"); +static inline_notes_delimiter_al_regular = ctRegex!(`【(.+?)】`, "mg"); +static inline_notes_delimiter_al_regular_number_note = ctRegex!(`【(\d+)\s+(.+?)】`, "mg"); static inline_al_delimiter_open_asterisk = ctRegex!(`【\*`, "m"); static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); static inline_text_and_note_al = ctRegex!(`(?P.+?)【(?:[*+ ]*)(?P.+?)】`, "mg"); +static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+ ]*.+?】|$))`, "mg"); #+END_SRC ** links/ urls :inline:footnote: diff --git a/org/output.org b/org/output.org index 073e56f..d17020f 100644 --- a/org/output.org +++ b/org/output.org @@ -28,14 +28,14 @@ auto html_heading(O)( auto ref const O obj, ) { string o; - o = format(q"◎


+ o = format(q"¶


%s
- ◎", + ¶", obj.obj_cite_number, obj.obj_cite_number, obj.heading_attrib.lev_markup_number, @@ -56,13 +56,13 @@ auto html_para(O)( auto ref const O obj, ) { string o; - o = format(q"◎
+ o = format(q"¶

%s

- ◎", + ¶", obj.obj_cite_number, obj.obj_cite_number, obj.para_attrib.indent_start, @@ -80,7 +80,7 @@ auto html_para(O)( #+BEGIN_SRC d auto scroll_head_html() { string o; - o = format(q"◎ + o = format(q"¶ @@ -108,18 +108,18 @@ auto scroll_head_html() { -◎"); +¶"); return o; } auto scroll_tail_html() { string o; - o = format(q"◎ + o = format(q"¶
-◎"); +¶"); return o; } #+END_SRC -- cgit v1.2.3