|
|
|
@ -1,4 +1,5 @@
@@ -1,4 +1,5 @@
|
|
|
|
|
|
|
|
|
|
// ./stgen3 src dest 7.98s user 0.32s system 102% cpu 8.123 total
|
|
|
|
|
#include <map> |
|
|
|
|
#include <ranges> |
|
|
|
|
#include <stack> |
|
|
|
@ -834,6 +835,7 @@ class templater {
@@ -834,6 +835,7 @@ class templater {
|
|
|
|
|
|
|
|
|
|
std::unordered_map<std::string, substitution_plugin *> substitution_commands {}; |
|
|
|
|
std::unordered_map<std::string, s2_substitution_plugin *> s2_substitution_commands {}; |
|
|
|
|
const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> NO_PAGES {}; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
@ -872,7 +874,7 @@ class templater {
@@ -872,7 +874,7 @@ class templater {
|
|
|
|
|
do_substitution(int start, int end, const std::string &invocation,
|
|
|
|
|
std::string &file_text,
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties, |
|
|
|
|
std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages)
|
|
|
|
|
const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages)
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
std::string command_name = invocation.substr(0, invocation.find(":")); |
|
|
|
@ -903,19 +905,19 @@ class templater {
@@ -903,19 +905,19 @@ class templater {
|
|
|
|
|
run_substitution_plugins(std::string &text,
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties)
|
|
|
|
|
{ |
|
|
|
|
run_substitution_plugins(text, properties, {}, true); |
|
|
|
|
run_substitution_plugins(text, properties, NO_PAGES, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
run_substitution_plugins_once(std::string &text,
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties)
|
|
|
|
|
{ |
|
|
|
|
run_substitution_plugins(text, properties, {}, false); |
|
|
|
|
run_substitution_plugins(text, properties, NO_PAGES, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
run_substitution_plugins(std::string &text,
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages) { |
|
|
|
|
const std::unordered_map<std::string, std::string> &properties, const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages) { |
|
|
|
|
run_substitution_plugins(text, properties,pages,true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -923,7 +925,7 @@ class templater {
@@ -923,7 +925,7 @@ class templater {
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
run_substitution_plugins(std::string &text,
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages, bool allow_recursion)
|
|
|
|
|
const std::unordered_map<std::string, std::string> &properties, const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages, bool allow_recursion)
|
|
|
|
|
{ |
|
|
|
|
std::string::size_type next = text.find(TEMPLATE_CODE_START, 0); |
|
|
|
|
|
|
|
|
|