From 69a5eaad6c474bc7d397dbade39c8180e8351a81 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 28 Apr 2020 14:20:01 -0400 Subject: 0.11.0 in_source_files, changed tracking of code blocks --- src/doc_reform/io_in/read_source_files.d | 55 +++++++++++++++++--------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/doc_reform/io_in/read_source_files.d b/src/doc_reform/io_in/read_source_files.d index 2959cc6..349729d 100644 --- a/src/doc_reform/io_in/read_source_files.d +++ b/src/doc_reform/io_in/read_source_files.d @@ -175,37 +175,39 @@ template spineRawMarkupContent() { ) { mixin spineRgxDocStructFlags; char[][] contents_insert; - int[string] type1 = flags_type_init; + int code_block_status = 0; + enum codeBlock { off, curly, tic, } + int[string] type = flags_type_init; auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; foreach (line; markup_sourcefile_insert_content) { - if (type1["curly_code"] == 1) { - type1["header_make"] = 0; - type1["header_meta"] = 0; + if (code_block_status == codeBlock.curly) { + type["header_make"] = 0; + type["header_meta"] = 0; if (line.matchFirst(rgx.block_curly_code_close)) { - type1["curly_code"] = 0; + code_block_status = codeBlock.off; } contents_insert ~= line; } else if (line.matchFirst(rgx.block_curly_code_open)) { - type1["curly_code"] = 1; - type1["header_make"] = 0; - type1["header_meta"] = 0; + code_block_status = codeBlock.curly; + type["header_make"] = 0; + type["header_meta"] = 0; contents_insert ~= line; - } else if (type1["tic_code"] == 1) { - type1["header_make"] = 0; - type1["header_meta"] = 0; + } else if (code_block_status == codeBlock.tic) { + type["header_make"] = 0; + type["header_meta"] = 0; if (line.matchFirst(rgx.block_tic_close)) { - type1["tic_code"] = 0; + code_block_status = codeBlock.off; } contents_insert ~= line; } else if (line.matchFirst(rgx.block_tic_code_open)) { - type1["tic_code"] = 1; - type1["header_make"] = 0; - type1["header_meta"] = 0; + code_block_status = codeBlock.tic; + type["header_make"] = 0; + type["header_meta"] = 0; contents_insert ~= line; } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) { - type1["header_make"] = 0; - type1["header_meta"] = 0; + type["header_make"] = 0; + type["header_meta"] = 0; auto insert_fn = m.captures[2]; auto insert_sub_pth = m.captures[1]; auto fn_src_insert @@ -236,8 +238,8 @@ template spineRawMarkupContent() { - build image list, search for any image files to add to image list +/ } else { - type1["header_make"] = 0; - type1["header_meta"] = 0; + type["header_make"] = 0; + type["header_meta"] = 0; contents_insert ~= line; // images to extract for image list? if (_opt_action.source || _opt_action.pod) { string[] _image_linelist = _extract_images(line); @@ -261,28 +263,29 @@ template spineRawMarkupContent() { import std.algorithm; mixin spineRgxDocStructFlags; char[][] contents; - int[string] type = flags_type_init; + int code_block_status = 0; + enum codeBlock { off, curly, tic, } auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; string[] _images =[]; string[] insert_file_list =[]; foreach (line; sourcefile_body_content) { - if (type["curly_code"] == 1) { + if (code_block_status == codeBlock.curly) { if (line.matchFirst(rgx.block_curly_code_close)) { - type["curly_code"] = 0; + code_block_status = codeBlock.off; } contents ~= line; } else if (line.matchFirst(rgx.block_curly_code_open)) { - type["curly_code"] = 1; + code_block_status = codeBlock.curly; contents ~= line; - } else if (type["tic_code"] == 1) { + } else if (code_block_status == codeBlock.tic) { if (line.matchFirst(rgx.block_tic_close)) { - type["tic_code"] = 0; + code_block_status = codeBlock.off; } contents ~= line; } else if (line.matchFirst(rgx.block_tic_code_open)) { - type["tic_code"] = 1; + code_block_status = codeBlock.tic; contents ~= line; } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) { auto insert_fn = m.captures[2]; -- cgit v1.2.3