Browse Source

detect displaymode

master
alistair 3 years ago
parent
commit
243250db85
  1. 18
      main.cpp

18
main.cpp

@ -139,8 +139,19 @@ class duktape { @@ -139,8 +139,19 @@ class duktape {
std::string eval_katex(std::string text) {
//math_text = math_text.substr(2, math_text.length() - 4);
//
std::string katexargs = "throwOnError: false";
if (text.length() > 4) {
if (text[1] == '[') {
katexargs += ", displayMode: true";
} else if (text[1] != '(') {
spdlog::debug("mathmode detection broken eval_katex()");
}
text = text.substr(2, text.length() - 4);
} else {
spdlog::error("Generate katex: short \n\t{}", text);
@ -153,6 +164,9 @@ class duktape { @@ -153,6 +164,9 @@ class duktape {
math_text += "\\'";
} else if (i == '\\') {
math_text += "\\\\";
} else if (i == '\n') {
math_text += "\\n";
} else {
math_text += i;
}
@ -163,7 +177,7 @@ class duktape { @@ -163,7 +177,7 @@ class duktape {
std::string line = "katex.renderToString('";
line += matht;
line += "', {throwOnError: false });";
line += "',{" + katexargs + "});";
duk_push_lstring(ctx, line.c_str(), line.length());

Loading…
Cancel
Save