diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-10-05 15:23:01 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:13 -0400 |
commit | d8d34b0eaca6f847f6ac7b09d729ad1c38e5484f (patch) | |
tree | 2a99c9798363e1510eaf122184ddc3cbea5a9741 /src/sdp/ao_abstract_doc_source.d | |
parent | 0.7.0 using dub remote dependencies (local src related to sdlang removed) (diff) |
segment auto naming (where no name provided) placed in function
Diffstat (limited to 'src/sdp/ao_abstract_doc_source.d')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index c7e5a13..595241a 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -2221,6 +2221,25 @@ template SiSUdocAbstraction() { // struct ObjInlineMarkup : AssertObjInlineMarkup { auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; + string make_segment_anchor_tags_if_none_provided(string munge_, string lev_) { + if (!(match(munge_, rgx.heading_anchor_tag))) { // if (anchor_tags_.length == 0) { + if (match(munge_, rgx.heading_identify_anchor_tag)) { + if (auto m = match(munge_, rgx.heading_extract_named_anchor_tag)) { + munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + "$1~" ~ toLower(m.captures[1]) ~ "_" ~ m.captures[2] ~ " "); + } else if (auto m = match(munge_, rgx.heading_extract_unnamed_anchor_tag)) { + munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + "$1~" ~ "s" ~ m.captures[1] ~ " "); + } + } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1" + static __gshared uint heading_num_lev1 = 0; + heading_num_lev1 ++; + munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + "$1~" ~ "x" ~ to!string(heading_num_lev1) ~ " "); + } + } + return munge_; + } auto obj_inline_markup_and_anchor_tags(string[string] obj_, string[string][string] dochead_make_aa) in { } body { @@ -2342,22 +2361,7 @@ template SiSUdocAbstraction() { } } // WORK ON, you still need to ensure that level 1 anchor_tags are unique - if (!(match(obj_txt["munge"], rgx.heading_anchor_tag))) { // if (anchor_tags_.length == 0) { - if (match(obj_txt["munge"], rgx.heading_identify_anchor_tag)) { - if (auto m = match(obj_txt["munge"], rgx.heading_extract_named_anchor_tag)) { - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, - "$1~" ~ toLower(m.captures[1]) ~ "_" ~ m.captures[2] ~ " "); - } else if (auto m = match(obj_txt["munge"], rgx.heading_extract_unnamed_anchor_tag)) { - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, - "$1~" ~ "s" ~ m.captures[1] ~ " "); - } - } else if (obj_["lev"] == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1" - static __gshared uint heading_num_lev1 = 0; - heading_num_lev1 ++; - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading_marker_missing_tag, - "$1~" ~ "x" ~ to!string(heading_num_lev1) ~ " "); - } - } + obj_txt["munge"]=make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"]); if (auto m = match(obj_txt["munge"], rgx.heading_anchor_tag)) { anchor_tag = m.captures[1]; anchor_tags_ ~=anchor_tag; |