aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/meta_read_source_files.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-12-02 12:53:52 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit5f238cfa5122fefbee7769e36fd07df060a85b4c (patch)
treec18731cfebd484ce92af84917ec3aad2c3a18c97 /org/meta_read_source_files.org
parent0.22.0 document matters & pod matters structs (diff)
0.23.0 make image list available early for sisupod
- have information needed for building source pods available early - don't do extra scan (for images) unless building of source pod requested
Diffstat (limited to 'org/meta_read_source_files.org')
-rw-r--r--org/meta_read_source_files.org131
1 files changed, 97 insertions, 34 deletions
diff --git a/org/meta_read_source_files.org b/org/meta_read_source_files.org
index 6b44dfb..8062f46 100644
--- a/org/meta_read_source_files.org
+++ b/org/meta_read_source_files.org
@@ -26,7 +26,7 @@ import
std.path;
#+END_SRC
-* 1. get _config file_ (read in) :module:sdp:meta_read_config_files:
+* A. get _config file_ (read in) :module:sdp:meta_read_config_files:
** 0. module template
#+BEGIN_SRC d :tangle ../src/sdp/meta/read_config_files.d
@@ -142,8 +142,8 @@ final auto configRead(C,E)(C conf_sdl, E env) {
}
#+END_SRC
-* 2. get _markup source_, read file :module:sdp:meta_read_source_files:
-** 0. module template
+* B. get _markup source_, read file :module:sdp:meta_read_source_files:
+** 0. module template (includes tuple)
#+BEGIN_SRC d :tangle ../src/sdp/meta/read_source_files.d
/++
@@ -158,10 +158,19 @@ static template SiSUrawMarkupContent() {
<<imports_std>>
mixin SiSUrgxInit;
static auto rgx = Rgx();
+ string[] _images=[];
+ auto _extract_images(S)(S content_block) {
+ string[] images_;
+ auto _content_block = content_block.to!string;
+ if (auto m = _content_block.matchAll(rgx.image)) {
+ images_ ~= m.captures[1].to!string;
+ }
+ return images_;
+ }
auto rawsrc = RawMarkupContent();
- auto SiSUrawMarkupContent(Fn)(Fn fn_src) {
+ auto SiSUrawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
auto _0_header_1_body_content_2_insert_filelist_tuple =
- rawsrc.sourceContentSplitIntoHeaderAndBody(rawsrc.sourceContent(fn_src), fn_src);
+ rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
return _0_header_1_body_content_2_insert_filelist_tuple;
}
struct RawMarkupContent {
@@ -171,9 +180,10 @@ static template SiSUrawMarkupContent() {
raw.markupSourceReadIn(fn_src);
return source_txt_str;
}
- final auto sourceContentSplitIntoHeaderAndBody(in string source_txt_str, in string fn_src="") {
+ final auto sourceContentSplitIntoHeaderAndBody(O)(O _opt_action, in string source_txt_str, in string fn_src="") {
auto raw = MarkupRawUnit();
string[] insert_file_list;
+ string[] images_list;
auto t =
raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str);
auto header_raw = t[0];
@@ -181,17 +191,25 @@ static template SiSUrawMarkupContent() {
if (fn_src.match(rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
auto ins = Inserts();
auto tu =
- ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src);
+ ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
static assert(!isTypeTuple!(tu));
sourcefile_body_content = tu[0];
insert_file_list = tu[1].dup;
+ images_list = tu[2].dup;
+ } else if (_opt_action.source || _opt_action.sisupod) {
+ auto ins = Inserts();
+ auto tu =
+ ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
+ static assert(!isTypeTuple!(tu));
+ images_list = tu[2].dup;
}
t = tuple(
header_raw,
sourcefile_body_content,
- insert_file_list
+ insert_file_list,
+ images_list
);
- static assert(t.length==3);
+ static assert(t.length==4);
return t;
}
}
@@ -206,9 +224,10 @@ static template SiSUrawMarkupContent() {
}
struct Inserts {
import sdp.meta.defaults;
- auto scan_subdoc_source(
+ auto scan_subdoc_source(O)(
+ O _opt_action,
char[][] markup_sourcefile_insert_content,
- string fn_src
+ string fn_src
) {
mixin SiSUrgxInitFlags;
<<meta_inserts_scan>>
@@ -217,10 +236,12 @@ static template SiSUrawMarkupContent() {
} // end src subdoc (inserts) loop
<<meta_inserts_scan_post>>
}
- auto scan_master_src_for_insert_files_and_import_content(
+ auto scan_master_src_for_insert_files_and_import_content(O)(
+ O _opt_action,
char[][] sourcefile_body_content,
- string fn_src
+ string fn_src
) {
+ import std.algorithm;
mixin SiSUrgxInitFlags;
<<meta_master_doc_scan_for_insert_filenames>>
foreach (line; sourcefile_body_content) {
@@ -321,12 +342,18 @@ auto markupSourceReadIn(in string fn_src) {
}
#+END_SRC
-**** tuple header and body content
+**** tuple (a) header, (b) body content, (c) file insert list & (d) image list?
+
+- header
+- body content
+- file insert list
+- [image list?]
#+name: meta_markup_source_raw_tuple_of_header_and_body
#+BEGIN_SRC d
auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) {
string[] file_insert_list = [];
+ string[] images_list = [];
auto hc = header0Content1(source_txt_str);
auto header = hc[0];
char[] source_txt = hc[1];
@@ -334,7 +361,8 @@ auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) {
auto t = tuple(
header,
source_line_arr,
- file_insert_list
+ file_insert_list,
+ images_list
);
return t;
}
@@ -432,20 +460,30 @@ if (type1["curly_code"] == 1) {
markup_sourcesubfile_insert_content.length
);
}
+ if (_opt_action.source || _opt_action.sisupod) {
+ _images ~= _extract_images(markup_sourcesubfile_insert_content);
+ }
auto ins = Inserts();
/+
- 1. load file,
- 2. read lines;
- 3. scan lines,
- 4. if filename insert, and insert filename
- 5. repeat 1
- 6. else
- 7. add line to new array;
+ - 1. load file
+ - 2. read lines
+ - 3. scan lines
+ - a. if filename insert, and insert filename
+ - repeat 1
+ - b. else
+ - add line to new array;
+ - build image list, search for any image files to add to image list
+/
} else {
type1["header_make"] = 0;
type1["header_meta"] = 0;
- contents_insert ~= line;
+ contents_insert ~= line; // images to extract for image list?
+ if (_opt_action.source || _opt_action.sisupod) {
+ auto _image_linelist = _extract_images(line);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
}
#+END_SRC
@@ -453,7 +491,11 @@ if (type1["curly_code"] == 1) {
#+name: meta_inserts_scan_post
#+BEGIN_SRC d
-return contents_insert;
+auto t = tuple(
+ contents_insert,
+ _images
+);
+return t;
#+END_SRC
*** scan document source :scan_src:
@@ -465,6 +507,8 @@ char[][] contents;
auto type = flags_type_init;
auto fn_pth_full = fn_src.match(rgx.src_pth);
auto markup_src_file_path = fn_pth_full.captures[1];
+char[][] contents_insert;
+string[] _images =[];
string[] insert_file_list =[];
#+END_SRC
@@ -511,22 +555,36 @@ if (type["curly_code"] == 1) {
);
}
auto ins = Inserts();
- auto contents_insert = ins.scan_subdoc_source(
+ auto contents_insert_tu = ins.scan_subdoc_source(
+ _opt_action,
markup_sourcefile_insert_content,
to!string(fn_src_insert)
);
- contents ~= contents_insert;
+ contents ~= contents_insert_tu[0]; // images to extract for image list?
+ if (_opt_action.source || _opt_action.sisupod) {
+ auto _image_linelist = _extract_images(contents_insert_tu[0]);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
/+
- 1. load file,
- 2. read lines;
- 3. scan lines,
- 4. if filename insert, and insert filename
- 5. repeat 1
- 6. else
- 7. add line to new array;
+ - 1. load file
+ - 2. read lines
+ - 3. scan lines
+ - a. if filename insert, and insert filename
+ - repeat 1
+ - b. else
+ - add line to new array;
+ - build image list, search for any image files to add to image list
+/
} else {
contents ~= line;
+ if (_opt_action.source || _opt_action.sisupod) {
+ auto _image_linelist = _extract_images(line);
+ if (_image_linelist.length > 0) {
+ _images ~= _image_linelist;
+ }
+ }
}
#+END_SRC
@@ -534,13 +592,18 @@ if (type["curly_code"] == 1) {
#+name: meta_master_doc_scan_for_insert_filenames_post
#+BEGIN_SRC d
+string[] images = [];
+foreach(i; uniq(_images.sort())) {
+ images ~= i;
+}
debug(insert_file) {
writeln(__LINE__);
writeln(contents.length);
}
auto t = tuple(
contents,
- insert_file_list
+ insert_file_list,
+ images
);
return t;
#+END_SRC