aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/ao_read_source_files.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-06-14 23:25:36 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-04 14:48:18 -0400
commit9bec897cdada305cae8ce78809dc3f9fe9cf8776 (patch)
treed05d0e4f2d9a9b2c5273e0a33bbbdf84580543b2 /org/ao_read_source_files.org
parentstep4 some additional work (diff)
step4.1 as step4 but extract header meta & make on first reading in documentdoc-reform_v0.0.4
Diffstat (limited to 'org/ao_read_source_files.org')
-rw-r--r--org/ao_read_source_files.org115
1 files changed, 56 insertions, 59 deletions
diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org
index 26f25fb..2d41105 100644
--- a/org/ao_read_source_files.org
+++ b/org/ao_read_source_files.org
@@ -12,9 +12,10 @@
#+FILETAGS: :sdp:niu:ao:
#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n)
-* read file, get raw markup source :markup:
[[./sdp.org][sdp]] [[./][org/]]
+* get markup source, read file :source:markup:
+
** [#A] read file, source string :string:
#+name: ao_markup_source_raw
#+BEGIN_SRC d
@@ -79,10 +80,21 @@ catch (ErrnoException ex) {
// }
}
+** array[0..1]: split header content :array:
+#+name: ao_markup_source_raw
+#+BEGIN_SRC d
+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;
+}
+#+END_SRC
+
** source line array :array:
#+name: ao_markup_source_raw
#+BEGIN_SRC d
-final private char[][] markupSourceLineArray(in string src_text) {
+final private char[][] markupSourceLineArray(in char[] src_text) {
char[][] source_line_arr =
split(cast(char[]) src_text, rgx.line_delimiter);
return source_line_arr;
@@ -95,6 +107,24 @@ final private char[][] markupSourceLineArray(in string src_text) {
#+name: ao_markup_source_raw
#+BEGIN_SRC d
+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),
@@ -106,7 +136,7 @@ final char[][] markupSourceContentRawLineArray(in string fn_src, Regex!(char) rg
}
#+END_SRC
-* get markup source, master file & inserts :inserts:
+* get markup source, master file & inserts :masterfile:inserts:
[[./sdp.org][sdp]] [[./][org/]]
** scan inserts (sub-document) source :scan_insert_src:
@@ -115,11 +145,6 @@ final char[][] markupSourceContentRawLineArray(in string fn_src, Regex!(char) rg
#+BEGIN_SRC d
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];
#+END_SRC
@@ -129,7 +154,7 @@ auto markup_src_file_path = fn_pth_full.captures[1];
#+BEGIN_SRC d
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;
}
@@ -137,11 +162,11 @@ if (type1["curly_code"] == 1) {
} 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;
}
@@ -149,25 +174,25 @@ if (type1["curly_code"] == 1) {
} 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 =
@@ -196,7 +221,7 @@ if (type1["curly_code"] == 1) {
+/
} else {
type1["header_make"] = 0;
- type1["header_metadata"] = 0;
+ type1["header_meta"] = 0;
contents_insert ~= line;
}
#+END_SRC
@@ -213,62 +238,29 @@ return contents_insert;
#+BEGIN_SRC d
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];
#+END_SRC
-*** loop insert (document)
+*** loop master scan for inserts (insert documents)
#+name: ao_master_doc_scan_for_insert_filenames_loop
#+BEGIN_SRC d
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 =
@@ -300,8 +292,6 @@ if (type["curly_code"] == 1) {
7. add line to new array;
+/
} else {
- type["header_make"] = 0;
- type["header_metadata"] = 0;
contents ~= line;
}
#+END_SRC
@@ -338,22 +328,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 }
<<ao_markup_source_raw>>
}
struct Inserts {
@@ -370,7 +367,7 @@ template SiSUmarkupRaw() {
} // end src subdoc (inserts) loop
<<ao_inserts_scan_post>>
}
- auto scan_master_doc_source_for_insert_filenames(
+ auto scan_master_src_for_insert_files_and_import_content(
char[][] sourcefile_content,
string fn_src
) {