diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-11-25 22:06:40 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-12-23 18:17:41 -0500 |
commit | f6d28b62f0e02b8a88a1832589e203c7a613f45b (patch) | |
tree | b5d6462e45bae998190194784e02b143a83f79a3 /org/default_paths.org | |
parent | gitignore & things nix (diff) |
regex review, match speed & compile time, ctregex
- improve match time
- add interim fontface identifier marker
- improve compile time
- remove unused regexs
- separate out some specialized output matches
Diffstat (limited to 'org/default_paths.org')
-rw-r--r-- | org/default_paths.org | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index 7f27191..a60d006 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -39,7 +39,7 @@ import std.conv : to; import doc_reform.meta.defaults, - doc_reform.meta.rgx; + doc_reform.meta.rgx_files; <<template_paths_src_0>> <<template_paths_src_1>> <<template_paths_src_2>> @@ -54,8 +54,8 @@ import #+NAME: template_paths_src_0 #+BEGIN_SRC d template PodManifest() { - mixin spineRgxIn; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); @safe auto PodManifest(O)( O _opt_action, string _pth="" @@ -70,12 +70,12 @@ template PodManifest() { && (exists(_pth.chainPath(pod_manifest_filename).array) != 0 && (_pth.chainPath(pod_manifest_filename).array).isFile)) { _manifest_path = _pth; - } else if (_pth.match(rgx.src_pth_contents) + } else if (_pth.match(rgx_files.src_pth_contents) && exists(_pth) != 0 && _pth.isFile) { _manifest_path = _pth.dirName; - } else if (_pth.match(rgx.src_pth_pod_sst_or_ssm) + } else if (_pth.match(rgx_files.src_pth_pod_sst_or_ssm) && exists(_pth) != 0 && (_pth.isFile)) { - if (auto m = _pth.match(rgx.src_pth_pod_sst_or_ssm)) { + if (auto m = _pth.match(rgx_files.src_pth_pod_sst_or_ssm)) { _manifest_path = m.captures["podpath"]; } } else { @@ -129,9 +129,9 @@ pod #+NAME: template_paths_src_1 #+BEGIN_SRC d template PathMatters() { - mixin spineRgxIn; mixin InternalMarkup; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); static auto mkup = InlineMarkup(); @safe auto PathMatters(O,E)( O _opt_action, @@ -204,7 +204,7 @@ template PathMatters() { string[] _lngs; foreach (filename_; manifest_list_of_filenames) { string _k = "en"; - if (auto m = (filename_).match(rgx.language_code_and_filename)) { + if (auto m = (filename_).match(rgx_files.language_code_and_filename)) { _k = m.captures[1].to!string; } _lngs ~= _k; // all the languages from the manifest list of filenames with paths @@ -241,11 +241,11 @@ template PathMatters() { return filename.stripExtension; } @safe string filename_extension() { - return filename.match(rgx.src_pth_sst_or_ssm).captures["extension"]; + return filename.match(rgx_files.src_pth_sst_or_ssm).captures["extension"]; } @safe string lng() { string _k; - if (auto m = path_and_fn.match(rgx.language_code_and_filename)) { + if (auto m = path_and_fn.match(rgx_files.language_code_and_filename)) { _k = m.captures[1]; } else {_k = "en"; } return _k; @@ -329,7 +329,7 @@ template PathMatters() { } else { _dir = ((path_and_fn.chainPath("../../../")).asNormalizedPath).array; assert(_dir == absolute_path_to_src - .match(rgx.src_base_parent_dir_name).captures["dir"]); + .match(rgx_files.src_base_parent_dir_name).captures["dir"]); } if (_opt_action.debug_do) { writeln("--> (base_dir) ", _dir); @@ -352,7 +352,7 @@ template PathMatters() { string _dir; if ( auto m = (absolute_path_to_src) - .match(rgx.src_formalised_file_path_parts) + .match(rgx_files.src_formalised_file_path_parts) ) { _dir = ((m.captures["pth"]).asNormalizedPath).array; } else if ( @@ -407,7 +407,7 @@ template PathMatters() { ) { _dir = m.captures["dir"]; } else { - _dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"]; + _dir = (absolute_path_to_src).match(rgx_files.src_base_parent_dir_name).captures["dir"]; } if (_opt_action.debug_do) { writeln("--> (base_parent_dir) ", _dir); @@ -477,8 +477,6 @@ template PathMatters() { #+NAME: template_paths_src_2 #+BEGIN_SRC d template configFilePaths() { - mixin spineRgxIn; - static auto rgx = RgxI(); @safe auto configFilePaths(M,E)( M _manifested, E _env, @@ -650,8 +648,8 @@ filelist for processing [things to ponder] #+NAME: template_paths_src_3 #+BEGIN_SRC d template spinePathsSRC() { - mixin spineRgxIn; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); @safe auto spinePathsSRC(D,Fn)( D _pwd, Fn _fn_src_and_path, @@ -663,7 +661,7 @@ template spinePathsSRC() { @safe string language() { // use command line info as well? string _k; - if (auto m = _fn_src_and_path.match(rgx.language_code_and_filename)) { + if (auto m = _fn_src_and_path.match(rgx_files.language_code_and_filename)) { _k = m.captures[1]; } else { /+ unknown until doc_meta read, (could provide & use command line info?) +/ _k = "xx"; // original default was "en" but is not known @@ -705,8 +703,6 @@ template spinePathsSRC() { #+NAME: template_paths_pods #+BEGIN_SRC d template spinePathsPods() { - mixin spineRgxIn; - static auto rgx = RgxI(); string _suffix = ".zip"; auto spinePathsPods(M)(M doc_matters) { string _base_dir_pod = (doc_matters.output_path.length > 0) @@ -981,7 +977,8 @@ import std.path, std.regex, std.stdio; -import doc_reform.meta.rgx; +import + doc_reform.meta.rgx_files; <<template_paths_out_0>> <<template_paths_out_1>> <<template_paths_url>> @@ -1113,8 +1110,6 @@ template spineOutPathsFnPd() { #+NAME: template_paths_html_0 #+BEGIN_SRC d template spineDocRootTreeHTML() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spineDocRootTreeHTML()(string lng) { auto lng_pth = spineOutPaths!()("", lng); string base_dir = "html"; @@ -1179,8 +1174,6 @@ template spineDocRootTreeHTML() { #+NAME: template_paths_html_1 #+BEGIN_SRC d template spinePathsHTML() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsHTML()( string output_path_root, string lng, @@ -1246,8 +1239,6 @@ template spinePathsHTML() { #+BEGIN_SRC d template spineUrlsHTML() { import std.format; - mixin spineRgxIn; - static auto rgx = RgxI(); auto spineUrlsHTML()( string url_doc_root, string lng, @@ -1353,8 +1344,6 @@ template spineUrlsHTML() { #+NAME: template_paths_epub #+BEGIN_SRC d template spinePathsEPUB() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsEPUB()( string output_pth_root, string lng, @@ -1465,8 +1454,6 @@ template spinePathsEPUB() { #+BEGIN_SRC d template spinePathsODT() { import std.conv; - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsODT(M)( M doc_matters, ) { @@ -1535,8 +1522,6 @@ template spinePathsODT() { #+NAME: template_paths_latex #+BEGIN_SRC d template spinePathsLaTeX() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsLaTeX(M)( M doc_matters, ) { @@ -1616,8 +1601,6 @@ template spinePathsLaTeXsty() { #+NAME: template_paths_pdf #+BEGIN_SRC d template spinePathsPDF() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsPDF(M)( M doc_matters, ) { @@ -1647,8 +1630,6 @@ template spinePathsPDF() { #+NAME: template_paths_sqlite_0 #+BEGIN_SRC d template spinePathsSQLiteDiscrete() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsSQLiteDiscrete()( string output_pth_root, string lng, @@ -1679,8 +1660,6 @@ template spinePathsSQLiteDiscrete() { #+NAME: template_paths_sqlite_1 #+BEGIN_SRC d template spinePathsSQLite() { - mixin spineRgxIn; - static auto rgx = RgxI(); auto spinePathsSQLite()( string db_name, string output_pth_root, |