diff options
Diffstat (limited to 'org/in_source_files.org')
-rw-r--r-- | org/in_source_files.org | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/org/in_source_files.org b/org/in_source_files.org index cb95fda..7ea9bae 100644 --- a/org/in_source_files.org +++ b/org/in_source_files.org @@ -267,7 +267,7 @@ static template spineRawMarkupContent() { mixin spineRgxInit; static auto rgx = Rgx(); string[] _images=[]; - auto _extract_images(S)(S content_block) @safe { + string[] _extract_images(S)(S content_block) @safe { string[] images_; string _content_block = content_block.to!string; if (auto m = _content_block.matchAll(rgx.image)) { @@ -276,6 +276,17 @@ static template spineRawMarkupContent() { return images_; } auto rawsrc = RawMarkupContent(); + alias ContentsInsertsImages = Tuple!( + char[][], "contents", + string[], "insert_files", + string[], "images" + ); + alias HeaderContentInsertsImages = Tuple!( + char[], "header", + char[][], "src_txt", + string[], "insert_files", + string[], "images" + ); auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) @safe { auto _0_header_1_body_content_2_insert_filelist_tuple = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src); @@ -284,7 +295,7 @@ static template spineRawMarkupContent() { struct RawMarkupContent { final sourceContent(in string fn_src) { auto raw = MarkupRawUnit(); - auto source_txt_str + string source_txt_str = raw.markupSourceReadIn(fn_src); return source_txt_str; } @@ -296,22 +307,22 @@ static template spineRawMarkupContent() { auto raw = MarkupRawUnit(); string[] insert_file_list; string[] images_list; - Tuple!(char[], char[][], string[], string[]) t + HeaderContentInsertsImages t = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); - auto header_raw = t[0]; - auto sourcefile_body_content = t[1]; + char[] header_raw = t.header; + char[][] sourcefile_body_content = t.src_txt; if (fn_src.match(rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); - Tuple!(char[][], string[], string[]) tu + ContentsInsertsImages tu = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); - sourcefile_body_content = tu[0]; - insert_file_list = tu[1].dup; - images_list = tu[2].dup; + sourcefile_body_content = tu.contents; + insert_file_list = tu.insert_files.dup; + images_list = tu.images.dup; } else if (_opt_action.source || _opt_action.pod) { auto ins = Inserts(); - Tuple!(char[][], string[], string[]) tu + ContentsInsertsImages tu = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); - images_list = tu[2].dup; + images_list = tu.images.dup; } string header_type = ""; t = tuple( @@ -320,7 +331,6 @@ static template spineRawMarkupContent() { insert_file_list, images_list ); - static assert(t.length==4); return t; } } @@ -334,7 +344,11 @@ static template spineRawMarkupContent() { <<meta_markup_source_raw_get_insert_source_line_array>> } struct Inserts { - auto scan_subdoc_source(O)( + alias ContentsAndImages = Tuple!( + char[][], "insert_contents", + string[], "images" + ); + ContentsAndImages scan_subdoc_source(O)( O _opt_action, char[][] markup_sourcefile_insert_content, string fn_src @@ -346,7 +360,7 @@ static template spineRawMarkupContent() { } // end src subdoc (inserts) loop <<meta_inserts_scan_post>> } - Tuple!(char[][], string[], string[]) scan_master_src_for_insert_files_and_import_content(O)( + ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( O _opt_action, char[][] sourcefile_body_content, string fn_src @@ -434,14 +448,14 @@ final private char[][] markupSourceLineArray(in char[] src_text) @trusted { // c #+name: meta_markup_source_raw_read_in_file #+BEGIN_SRC d -auto markupSourceReadIn(in string fn_src) { +string markupSourceReadIn(in string fn_src) { static auto rgx = Rgx(); enforce( fn_src.match(rgx.src_pth_sst_or_ssm), "not a dr markup filename: «" ~ fn_src ~ "»" ); - auto source_txt_str = readInMarkupSource(fn_src); + string source_txt_str = readInMarkupSource(fn_src); return source_txt_str; } #+END_SRC @@ -455,14 +469,14 @@ auto markupSourceReadIn(in string fn_src) { #+name: meta_markup_source_raw_tuple_of_header_and_body #+BEGIN_SRC d -Tuple!(char[], char[][], string[], string[]) markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) @safe { +HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) @safe { string[] file_insert_list = []; string[] images_list = []; char[][] hc = header0Content1(source_txt_str); char[] header = hc[0]; char[] source_txt = hc[1]; char[][] source_line_arr = markupSourceLineArray(source_txt); - Tuple!(char[], char[][], string[], string[]) t = tuple( + HeaderContentInsertsImages t = tuple( header, source_line_arr, file_insert_list, @@ -570,7 +584,7 @@ if (type1["curly_code"] == 1) { type1["header_meta"] = 0; contents_insert ~= line; // images to extract for image list? if (_opt_action.source || _opt_action.pod) { - auto _image_linelist = _extract_images(line); + string[] _image_linelist = _extract_images(line); if (_image_linelist.length > 0) { _images ~= _image_linelist; } @@ -582,7 +596,7 @@ if (type1["curly_code"] == 1) { #+name: meta_inserts_scan_post #+BEGIN_SRC d -Tuple!(char[][], string[]) t = tuple( +ContentsAndImages t = tuple( contents_insert, _images ); @@ -642,14 +656,14 @@ if (type["curly_code"] == 1) { ); } auto ins = Inserts(); - auto contents_insert_tu = ins.scan_subdoc_source( + ContentsAndImages contents_insert_tu = ins.scan_subdoc_source( _opt_action, markup_sourcefile_insert_content, fn_src_insert.to!string ); - contents ~= contents_insert_tu[0]; // images to extract for image list? + contents ~= contents_insert_tu.insert_contents; if (_opt_action.source || _opt_action.pod) { - auto _image_linelist = _extract_images(contents_insert_tu[0]); + string[] _image_linelist = _extract_images(contents_insert_tu.images); if (_image_linelist.length > 0) { _images ~= _image_linelist; } @@ -667,7 +681,7 @@ if (type["curly_code"] == 1) { } else { contents ~= line; if (_opt_action.source || _opt_action.pod) { - auto _image_linelist = _extract_images(line); + string[] _image_linelist = _extract_images(line); if (_image_linelist.length > 0) { _images ~= _image_linelist; } @@ -687,7 +701,7 @@ debug(insert_file) { writeln(__LINE__); writeln(contents.length); } -Tuple!(char[][], string[], string[]) t = tuple( +ContentsInsertsImages t = tuple( contents, insert_file_list, images |