aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/in_source_files.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2024-06-29 13:54:28 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2024-06-29 15:39:08 -0400
commit860b894a10f3526e6bd73d53850764c0ad95ab99 (patch)
treee4a997fcacd3b2dcbff876479ebd1ee718230f1e /org/in_source_files.org
parentnix minor (diff)
document digests and reduction in use of tuples
Diffstat (limited to 'org/in_source_files.org')
-rw-r--r--org/in_source_files.org56
1 files changed, 39 insertions, 17 deletions
diff --git a/org/in_source_files.org b/org/in_source_files.org
index 90143f4..6275ed4 100644
--- a/org/in_source_files.org
+++ b/org/in_source_files.org
@@ -298,6 +298,7 @@ module sisudoc.io_in.read_source_files;
@safe:
template spineRawMarkupContent() {
import
+ std.digest.sha,
std.file,
std.path;
import
@@ -309,6 +310,14 @@ template spineRawMarkupContent() {
static auto rgx = RgxI();
mixin spineRgxFiles;
static auto rgx_files = RgxFiles();
+ struct ST_doc_parts {
+ char[] header_raw;
+ char[][] sourcefile_body_content;
+ string[] insert_file_list;
+ string[] images_list;
+ ubyte[32] header_raw_digest;
+ ubyte[32] src_txt_digest;
+ }
string[] _images=[];
string[] _extract_images(S)(S content_block) {
string[] images_;
@@ -328,7 +337,9 @@ template spineRawMarkupContent() {
char[], "header",
char[][], "src_txt",
string[], "insert_files",
- string[], "images"
+ string[], "images",
+ ubyte[32], "header_digest",
+ ubyte[32], "src_txt_digest"
);
auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
auto _0_header_1_body_content_2_insert_filelist_tuple
@@ -342,43 +353,50 @@ template spineRawMarkupContent() {
= raw.markupSourceReadIn(fn_src);
return source_txt_str;
}
- final auto sourceContentSplitIntoHeaderAndBody(O)(
+ final ST_doc_parts sourceContentSplitIntoHeaderAndBody(O)(
O _opt_action,
in string source_txt_str,
in string fn_src=""
) {
auto raw = MarkupRawUnit();
- string[] insert_file_list;
- string[] images_list;
+ string[] insert_file_list_get;
+ string[] images_list_get;
HeaderContentInsertsImages t
= raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str);
char[] header_raw = t.header;
+ ubyte[32] header_raw_digest = t.header.sha256Of;
char[][] sourcefile_body_content = t.src_txt;
if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
auto ins = Inserts();
ContentsInsertsImages tu
= ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
sourcefile_body_content = tu.contents;
- insert_file_list = tu.insert_files.dup;
- images_list = tu.images.dup;
+ insert_file_list_get = tu.insert_files.dup;
+ images_list_get = tu.images.dup;
} else if (_opt_action.source || _opt_action.pod) {
auto ins = Inserts();
ContentsInsertsImages tu
= ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- images_list = tu.images.dup;
- }
+ images_list_get = tu.images.dup;
+ } // image_list, if path could take sha256 digests already here?
+ ubyte[32] src_txt_digest = sourcefile_body_content.sha256Of;
string header_type = "";
- t = tuple(
- header_raw,
- sourcefile_body_content,
- insert_file_list,
- images_list
- );
- return t;
+ ST_doc_parts ret;
+ {
+ ret.header_raw = t.header;
+ ret.sourcefile_body_content = sourcefile_body_content;
+ ret.insert_file_list = insert_file_list_get;
+ ret.images_list = images_list_get;
+ ret.header_raw_digest = t.header.sha256Of;
+ ret.src_txt_digest = sourcefile_body_content.sha256Of;
+ }
+ return ret;
}
}
struct MarkupRawUnit {
- import std.file;
+ import
+ std.digest.sha,
+ std.file;
<<meta_markup_source_raw_read_file_source_string>>
<<meta_markup_source_raw_doc_header_and_content_split>>
<<meta_markup_source_raw_source_line_array>>
@@ -517,11 +535,15 @@ HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string
char[] header = hc[0];
char[] source_txt = hc[1];
char[][] source_line_arr = markupSourceLineArray(source_txt);
+ ubyte[32] header_digest;
+ ubyte[32] src_txt_digest;
HeaderContentInsertsImages t = tuple(
header,
source_line_arr,
file_insert_list,
- images_list
+ images_list,
+ header_digest,
+ src_txt_digest
);
return t;
}