aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
diff options
context:
space:
mode:
Diffstat (limited to 'misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d')
-rwxr-xr-xmisc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d24
1 files changed, 10 insertions, 14 deletions
diff --git a/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d b/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
index abd4e45..b084052 100755
--- a/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
+++ b/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
@@ -48,31 +48,27 @@ void main(string[] args) {
string text = filename.readText;
string[] paragraphs = text.split("\n\n");
int endnote_ref_count = 0;
- int[string] type = [
- "curly_code" : 0,
- "tic_code" : 0,
- ];
+ int code_block_status = 0;
+ enum codeBlock { off, curly, tic, }
foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/
- if ( !( type["curly_code"] == 1 || type["tic_code"] == 1)
+ if (code_block_status == codeBlock.off
&& paragraph.match(rgx_endnote)
) {
endnotes ~= replaceAll!(m => m[1])
(paragraph, rgx_endnote);
} else {
- if ( type["curly_code"] == 1
- && paragraph.matchFirst(block_curly_code_close)
+ if ((code_block_status == codeBlock.curly
+ && paragraph.matchFirst(block_curly_code_close))
+ || ((code_block_status == codeBlock.tic
+ && paragraph.matchFirst(block_tic_close))
) {
- type["curly_code"] = 0;
- } else if (type["tic_code"] == 1
- && paragraph.matchFirst(block_tic_close)
- ) {
- type["tic_code"] = 0;
+ code_block_status = codeBlock.off;
} else if ( type["curly_code"] == 1 || type["tic_code"] == 1) {
// skip, prevent search for endnotes
} else if (paragraph.matchFirst(block_curly_code_open)) {
- type["curly_code"] = 1;
+ code_block_status = codeBlock.curly;
} else if (paragraph.matchFirst(block_tic_code_open)) {
- type["tic_code"] = 1;
+ code_block_status = codeBlock.tic;
} else if (auto m = paragraph.matchAll(rgx_endnote_ref)) {
foreach (n; m) {
endnote_ref_count++; // endnote_refs ~= (n.captures[1]);