Multiline equation support
This commit is contained in:
parent
8214ce5111
commit
ea73f4d45c
11
app.js
11
app.js
@ -46,9 +46,9 @@ var documentTemplate = `
|
|||||||
${preamble}
|
${preamble}
|
||||||
\\thispagestyle{empty}
|
\\thispagestyle{empty}
|
||||||
\\begin{document}
|
\\begin{document}
|
||||||
\\[
|
\\begin{align*}
|
||||||
EQUATION
|
EQUATION
|
||||||
\\]
|
\\end{align*}
|
||||||
\\end{document}`;
|
\\end{document}`;
|
||||||
|
|
||||||
// Create temp and output directories on first run
|
// Create temp and output directories on first run
|
||||||
@ -77,9 +77,14 @@ app.post('/convert', function (req, res) {
|
|||||||
if (validFormats.includes(req.body.outputFormat)) {
|
if (validFormats.includes(req.body.outputFormat)) {
|
||||||
var id = generateID(); // Generate unique ID for filename
|
var id = generateID(); // Generate unique ID for filename
|
||||||
|
|
||||||
|
var eqnInput = req.body.latexInput.trim();
|
||||||
|
if (/\\\\(?!$)/.test(eqnInput) && !eqnInput.includes("&")) { // if any "\\" not at EOF, unless intentionally aligned with &
|
||||||
|
eqnInput = '&' + eqnInput.replace(/\\\\(?!$)/g, "\\\\&"); // replace any "\\" not at EOF with "\\&", to enforce left alignment
|
||||||
|
}
|
||||||
|
|
||||||
shell.mkdir(`${tempDirRoot}${id}`);
|
shell.mkdir(`${tempDirRoot}${id}`);
|
||||||
|
|
||||||
var document = documentTemplate.replace('EQUATION', req.body.latexInput.trim());
|
var document = documentTemplate.replace('EQUATION', eqnInput);
|
||||||
fs.writeFileSync(`${tempDirRoot}${id}/equation.tex`, document); // Write generated .tex file
|
fs.writeFileSync(`${tempDirRoot}${id}/equation.tex`, document); // Write generated .tex file
|
||||||
|
|
||||||
var result = {};
|
var result = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user