1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-30 19:50:01 +02:00

curve fitting and assorted fixes

This commit is contained in:
Pomax
2018-06-19 21:03:58 -07:00
parent 0fec6be56f
commit a16142ab4a
41 changed files with 9989 additions and 299 deletions

View File

@@ -12,6 +12,18 @@ var path = require("path");
var cleanUp = require("./cleanup");
var execSync = require("child_process").execSync;
// This function really needs better stdio capture,
// so it can report _what went wrong_ when xelatex fails.
function runCmd(cmd) {
try {
execSync(cmd); //, { stdio: 'inherit' });
} catch (e) {
console.error("could not run cmd: ", cmd);
console.log("latex:\n", latex);
process.exit(1);
}
}
// Get the LaTeX we need, either straight up or base64 encoded:
var latex = process.argv.indexOf("--latex");
@@ -47,6 +59,7 @@ var TeXfilename = path.join(dir, hash + ".tex");
// form the LaTeX block that will be injected into the .tex file
var latexSourceCode = cleanUp(latex);
latexSourceCode = ['\\[', latexSourceCode, '\\]'].join('\n');
// Convert the passed LaTeX to SVG form and write the .tex source
@@ -102,22 +115,14 @@ var SVGfilename = TeXfilename.replace(".tex",".svg");
SVGfilename = path.resolve(path.join(path.dirname(TeXfilename), '..', hash + ".svg"));
// Finally: run the conversion
try {
var cmd = `npm run xelatex -- -output-directory "${path.dirname(TeXfilename)}" "${TeXfilename}"`;
console.log("- running xelatex on " + hash + ".tex");
execSync(cmd); //, { stdio: 'inherit' });
console.log("- running xelatex on " + hash + ".tex");
runCmd(`npm run xelatex -- -output-directory "${path.dirname(TeXfilename)}" "${TeXfilename}"`);
var cmd = `npm run pdfcrop -- "${ PDFfilename }"`;
console.log("- cropping PDF to document content");
execSync(cmd); //, { stdio: 'inherit' });
console.log("- cropping PDF to document content");
runCmd(`npm run pdfcrop -- "${ PDFfilename }"`);
var cmd = `pdf2svg "${ PDFfilenameCropped }" "${ SVGfilename }"`;
console.log("- converting cropped PDF to SVG");
execSync(cmd); //, { stdio: 'inherit' });
console.log("- converting cropped PDF to SVG");
runCmd(`pdf2svg "${ PDFfilenameCropped }" "${ SVGfilename }"`);
var cmd = `npm run svgo -- "${ SVGfilename }"`;
console.log("- cleaning up SVG");
execSync(cmd); //, { stdio: 'inherit' });
}
catch (e) { console.error(e); process.exit(1); }
console.log("- cleaning up SVG");
runCmd(`npm run svgo -- "${ SVGfilename }"`);