aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@niklashalle.net>2020-12-04 15:39:23 +0100
committerniklas <niklas@niklashalle.net>2020-12-04 15:39:23 +0100
commitbc2d533069df40bb2932ef2f8ab18e6d9de41b73 (patch)
treea41aa2f24102caa07eda460edf598f747e852a65
parent9a87a3500b835d1bbe29132fee3eef7ada973a5e (diff)
downloadn_core-emergency.tar.gz
n_core-emergency.zip
switch latex engineemergency
-rw-r--r--src/SimpleHandlers.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/SimpleHandlers.cpp b/src/SimpleHandlers.cpp
index eba9331..c3c0627 100644
--- a/src/SimpleHandlers.cpp
+++ b/src/SimpleHandlers.cpp
@@ -221,11 +221,16 @@ json Handler::latexRenderHandler(std::string const &arguments, std::string const
//std::cout << ("png_file " + png_file) << exec(("png_file " + png_file).c_str()) << std::endl;
- std::string result = exec(("curl -s 'https://latex.codecogs.com/png.latex?" + url_encode(arguments) + "' "
- "-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0' "
- "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' "
- "-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Connection: keep-alive' "
- "-H 'Upgrade-Insecure-Requests: 1' --output " + png_file).c_str());
+// std::string result = exec(("curl -s 'https://latex.codecogs.com/png.latex?" + url_encode(arguments) + "' "
+// "-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0' "
+// "-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' "
+// "-H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Connection: keep-alive' "
+// "-H 'Upgrade-Insecure-Requests: 1' --output " + png_file).c_str());
+
+ std::string result = exec(("curl -s 'https://latex2image.joeraut.com/convert' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://latex2image.joeraut.com/convert' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://latex2image.joeraut.com' -H 'DNT: 1' -H 'Connection: keep-alive' --data-raw 'latexInput=" + url_encode(arguments) + "&outputFormat=JPG&outputScale=1000%25' | grep -oP 'output[^\"]+'").c_str());
+ result = result.substr(0, result.size() - 1); // cut \n
+ //std::cout << "result1: " << ("curl -s 'https://latex2image.joeraut.com/" + result + "' --output " + png_file) << std::endl;
+ result = exec(("curl 'https://latex2image.joeraut.com/" + result + "' --output " + png_file).c_str());
//std::cout << ("png_file " + png_file) << exec(("png_file " + png_file).c_str()) << std::endl;