|
|
|
@ -61,6 +61,7 @@ struct runtime_config {
@@ -61,6 +61,7 @@ struct runtime_config {
|
|
|
|
|
bool no_interactive = false; |
|
|
|
|
bool save_config = false; |
|
|
|
|
bool test = false; |
|
|
|
|
bool comp_katex = true; |
|
|
|
|
std::set<std::string> readonly_properties {"source_root"}; |
|
|
|
|
std::string port = TEST_PORT; |
|
|
|
|
}; |
|
|
|
@ -76,16 +77,15 @@ extern "C" {
@@ -76,16 +77,15 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class duktape { |
|
|
|
|
duk_context *ctx; |
|
|
|
|
duk_context *ctx = nullptr; |
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
duktape() { |
|
|
|
|
ctx = duk_create_heap_default(); |
|
|
|
|
} |
|
|
|
|
duktape() {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~duktape() { |
|
|
|
|
duk_destroy_heap(ctx); |
|
|
|
|
if (ctx) |
|
|
|
|
duk_destroy_heap(ctx); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void compile_file(std::string fname)
|
|
|
|
@ -135,6 +135,8 @@ class duktape {
@@ -135,6 +135,8 @@ class duktape {
|
|
|
|
|
|
|
|
|
|
void prepare_katex() { |
|
|
|
|
|
|
|
|
|
ctx = duk_create_heap_default(); |
|
|
|
|
|
|
|
|
|
if (duk_pcompile_lstring(ctx, 0, (const char *)default_templates_katex_min_js,
|
|
|
|
|
default_templates_katex_min_js_len) != 0) { |
|
|
|
|
std::cout << "Error :" << duk_safe_to_string(ctx, -1); |
|
|
|
@ -785,7 +787,8 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
@@ -785,7 +787,8 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
|
|
|
|
|
|
|
|
|
|
if (ext == "md" || ext == "markdown") { |
|
|
|
|
text = parser.parse_to_html(text);
|
|
|
|
|
//text = postprocess_math(text);
|
|
|
|
|
if (settings.comp_katex) |
|
|
|
|
text = postprocess_math(text); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -916,7 +919,8 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
@@ -916,7 +919,8 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
|
|
|
|
|
|
|
|
|
|
add_default_templates(); |
|
|
|
|
|
|
|
|
|
dukengine.prepare_katex(); |
|
|
|
|
if (settings.comp_katex) |
|
|
|
|
dukengine.prepare_katex(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
~builder() {delete templr; delete textsub_templr; delete s2_templr;} |
|
|
|
@ -1175,6 +1179,7 @@ std::unordered_map<std::string, std::string> parse_options (int argc, char **arg
@@ -1175,6 +1179,7 @@ std::unordered_map<std::string, std::string> parse_options (int argc, char **arg
|
|
|
|
|
("s,save-config", "Save the configuration used to build the site to src/stgen.json") |
|
|
|
|
("y,noninteractive", "Non-interactive mode (confirm everything)") |
|
|
|
|
("t,test", "Start internal server and build in test mode") |
|
|
|
|
("k,nokatex", "Do not compile KaTeX math at run time") |
|
|
|
|
("p,port", "Port to use for the internal server", cxxopts::value<std::string>()) |
|
|
|
|
("n,name", "Site name, defaults to $source", cxxopts::value<std::string>())
|
|
|
|
|
("u,url", "Site url, defaults to file://$destination", cxxopts::value<std::string>()) |
|
|
|
@ -1205,9 +1210,11 @@ std::unordered_map<std::string, std::string> parse_options (int argc, char **arg
@@ -1205,9 +1210,11 @@ std::unordered_map<std::string, std::string> parse_options (int argc, char **arg
|
|
|
|
|
settings.readonly_properties.insert("url"); |
|
|
|
|
settings.readonly_properties.insert("publish_root"); |
|
|
|
|
settings.test = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.count("nokatex")) |
|
|
|
|
settings.comp_katex = false; |
|
|
|
|
|
|
|
|
|
if (result.count("port")) { |
|
|
|
|
settings.port = result["port"].as<std::string>(); |
|
|
|
|
} |
|
|
|
|