From bc2d533069df40bb2932ef2f8ab18e6d9de41b73 Mon Sep 17 00:00:00 2001 From: niklas Date: Fri, 4 Dec 2020 15:39:23 +0100 Subject: switch latex engine --- src/SimpleHandlers.cpp | 15 ++++++++++----- 1 file 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; -- cgit v1.2.3-54-g00ecf