From 19d648a891b3cb9c7d573911f83d3a9fafe2b434 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Nov 2016 18:19:24 -0500 Subject: housekeeping --- src/sdp/ao_abstract_doc_source.d | 105 ++++++++++++++++++++++++--------------- src/sdp/ao_defaults.d | 45 ++++------------- src/sdp/ao_rgx.d | 9 ++-- src/sdp/output_html.d | 16 +++--- 4 files changed, 90 insertions(+), 85 deletions(-) (limited to 'src/sdp') 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; } diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d index f1c05ac..9a84e80 100644 --- a/src/sdp/ao_defaults.d +++ b/src/sdp/ao_defaults.d @@ -388,42 +388,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; } } diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 73cdb40..3d531dc 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -134,14 +134,17 @@ template RgxInit() { /+ 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"); static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d index ce5684f..5552fe2 100644 --- a/src/sdp/output_html.d +++ b/src/sdp/output_html.d @@ -4,14 +4,14 @@ template SiSUoutputHTML() { 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, @@ -26,13 +26,13 @@ template SiSUoutputHTML() { 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, @@ -44,7 +44,7 @@ template SiSUoutputHTML() { } auto scroll_head_html() { string o; - o = format(q"◎ + o = format(q"¶ @@ -72,18 +72,18 @@ template SiSUoutputHTML() { - ◎"); + ¶"); return o; } auto scroll_tail_html() { string o; - o = format(q"◎ + o = format(q"¶
- ◎"); + ¶"); return o; } void scroll(C)( -- cgit v1.2.3