aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_read_source_files.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/ao_read_source_files.d')
-rw-r--r--src/sdp/ao_read_source_files.d103
1 files changed, 47 insertions, 56 deletions
diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d
index 9bfaa05..e450bc8 100644
--- a/src/sdp/ao_read_source_files.d
+++ b/src/sdp/ao_read_source_files.d
@@ -16,22 +16,29 @@ template SiSUmarkupRaw() {
mixin RgxInit;
auto rgx = Rgx();
struct MarkupRaw {
- final char[][] sourceContent(in string fn_src) {
+ auto sourceContent(in string fn_src) {
auto raw = MarkupRawUnit();
- auto sourcefile_content =
- raw.markupSourceContentRawLineArray(fn_src, rgx.src_pth);
+ auto t =
+ raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth);
+ auto header_content_raw = t[0];
+ auto sourcefile_content = t[1];
if (match(fn_src, rgx.src_fn_master)) {
auto ins = Inserts();
sourcefile_content =
- ins.scan_master_doc_source_for_insert_filenames(sourcefile_content, fn_src);
+ ins.scan_master_src_for_insert_files_and_import_content(sourcefile_content, fn_src);
// auto ins = SiSUdocInserts.Inserts();
}
- return sourcefile_content;
+ t = tuple(
+ header_content_raw,
+ sourcefile_content
+ );
+ return t;
}
}
private
struct MarkupRawUnit {
private import std.file;
+ enum State { off, on }
final private string readInMarkupSource(in string fn_src) {
enforce(
exists(fn_src)!=0,
@@ -67,11 +74,35 @@ template SiSUmarkupRaw() {
std.utf.validate(source_txt_str);
return source_txt_str;
}
- final private char[][] markupSourceLineArray(in string src_text) {
+ final private char[][] header0Content1(in string src_text) {
+ /+ split string on first match of "^:?A~\s" into [header, content] tuple +/
+ char[][] header_and_content =
+ split(cast(char[]) src_text, rgx.heading_a);
+ return header_and_content;
+ }
+ final private char[][] markupSourceLineArray(in char[] src_text) {
char[][] source_line_arr =
split(cast(char[]) src_text, rgx.line_delimiter);
return source_line_arr;
}
+ auto markupSourceHeaderContentRawLineTupleArray(in string fn_src, Regex!(char) rgx_file ) {
+ enforce(
+ match(fn_src, rgx_file),
+ "not a sisu markup filename"
+ );
+ auto source_txt_str = readInMarkupSource(fn_src);
+ auto hc = header0Content1(source_txt_str);
+ auto header = hc[0];
+ char[] la;
+ la ~= "A~ ";
+ char[] source_txt = la ~ hc[1];
+ auto source_line_arr = markupSourceLineArray(source_txt);
+ auto t = tuple(
+ header,
+ source_line_arr
+ );
+ return t;
+ }
final char[][] markupSourceContentRawLineArray(in string fn_src, Regex!(char) rgx_file ) {
enforce(
match(fn_src, rgx_file),
@@ -92,17 +123,12 @@ template SiSUmarkupRaw() {
mixin SiSUrgxInitFlags;
char[][] contents_insert;
auto type1 = flags_type_init;
- mixin ScreenTxtColors;
- int tell_l(string color, in char[] line) {
- writeln(scr_txt_marker[color], line);
- return 0;
- }
auto fn_pth_full = match(fn_src, rgx.src_pth);
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_metadata"] = 0;
+ type1["header_meta"] = 0;
if (matchFirst(line, rgx.block_curly_code_close)) {
type1["curly_code"] = 0;
}
@@ -110,11 +136,11 @@ template SiSUmarkupRaw() {
} else if (matchFirst(line, rgx.block_curly_code_open)) {
type1["curly_code"] = 1;
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
contents_insert ~= line;
} else if (type1["tic_code"] == 1) {
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
if (matchFirst(line, rgx.block_tic_close)) {
type1["tic_code"] = 0;
}
@@ -122,25 +148,25 @@ template SiSUmarkupRaw() {
} else if (matchFirst(line, rgx.block_tic_code_open)) {
type1["tic_code"] = 1;
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
contents_insert ~= line;
} else if (
(type1["header_make"] == 1)
&& matchFirst(line, rgx.header_sub)
) {
type1["header_make"] = 1;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
// cont_dynamic_array ~= "% " ~ line;
} else if (
- (type1["header_metadata"] == 1)
+ (type1["header_meta"] == 1)
&& matchFirst(line, rgx.header_sub)
) {
- type1["header_metadata"] = 1;
+ type1["header_meta"] = 1;
type1["header_make"] = 0;
// cont_dynamic_array ~= "% " ~ line;
} else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) {
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
auto insert_fn = m.captures[2];
auto insert_sub_pth = m.captures[1];
auto fn_src_insert =
@@ -169,72 +195,39 @@ template SiSUmarkupRaw() {
+/
} else {
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
contents_insert ~= line;
}
} // end src subdoc (inserts) loop
return contents_insert;
}
- auto scan_master_doc_source_for_insert_filenames(
+ auto scan_master_src_for_insert_files_and_import_content(
char[][] sourcefile_content,
string fn_src
) {
mixin SiSUrgxInitFlags;
char[][] contents;
auto type = flags_type_init;
- mixin ScreenTxtColors;
- int tell_l(string color, in char[] line) {
- writeln(scr_txt_marker[color], line);
- return 0;
- }
auto fn_pth_full = match(fn_src, rgx.src_pth);
auto markup_src_file_path = fn_pth_full.captures[1];
foreach (line; sourcefile_content) {
if (type["curly_code"] == 1) {
- type["header_make"] = 0;
- type["header_metadata"] = 0;
if (matchFirst(line, rgx.block_curly_code_close)) {
type["curly_code"] = 0;
}
contents ~= line;
} else if (matchFirst(line, rgx.block_curly_code_open)) {
type["curly_code"] = 1;
- type["header_make"] = 0;
- type["header_metadata"] = 0;
contents ~= line;
} else if (type["tic_code"] == 1) {
- type["header_make"] = 0;
- type["header_metadata"] = 0;
if (matchFirst(line, rgx.block_tic_close)) {
type["tic_code"] = 0;
}
contents ~= line;
} else if (matchFirst(line, rgx.block_tic_code_open)) {
type["tic_code"] = 1;
- type["header_make"] = 0;
- type["header_metadata"] = 0;
- contents ~= line;
- } else if (
- (type["header_make"] == 1)
- && matchFirst(line, rgx.header_sub)
- ) {
- contents ~= line;
- } else if (
- (type["header_metadata"] == 1)
- && matchFirst(line, rgx.header_sub)
- ) {
- contents ~= line;
- } else if (matchFirst(line, rgx.header_make)) {
- type["header_make"] = 1;
- type["header_metadata"] = 0;
- contents ~= line;
- } else if (matchFirst(line, rgx.header_metadata)) {
- type["header_make"] = 0;
- type["header_metadata"] = 1;
contents ~= line;
} else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) {
- type["header_make"] = 0;
- type["header_metadata"] = 0;
auto insert_fn = m.captures[2];
auto insert_sub_pth = m.captures[1];
auto fn_src_insert =
@@ -266,8 +259,6 @@ template SiSUmarkupRaw() {
7. add line to new array;
+/
} else {
- type["header_make"] = 0;
- type["header_metadata"] = 0;
contents ~= line;
}
} // end src doc loop