Skip to content

Commit 9a48b0a

Browse files
LaTeX fixing §1--3
1 parent e2a4750 commit 9a48b0a

File tree

14 files changed

+720
-24
lines changed

14 files changed

+720
-24
lines changed

javascript/parseXmlLatex.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,16 @@ const processTextFunctionsDefaultLatex = {
253253
SCHEMEINLINE: (node, writeTo) =>
254254
processTextFunctionsLatex["JAVASCRIPTINLINE"](node, writeTo),
255255
JAVASCRIPTINLINE: (node, writeTo) => {
256-
writeTo.push("{\\lstinline[mathescape=true]$");
256+
if (node.getAttribute("break")) {
257+
writeTo.push(
258+
"{\\lstinline[breaklines=true, breakatwhitespace=true,mathescape=true]$"
259+
);
260+
} else {
261+
writeTo.push("{\\lstinline[mathescape=true]$");
262+
}
257263
recursiveProcessPureText(node.firstChild, writeTo, {
258-
removeNewline: "all"
264+
removeNewline: "all",
265+
escapeCurlyBracket: true
259266
});
260267
writeTo.push("$}");
261268
},
@@ -317,7 +324,8 @@ const processTextFunctionsEpub = {
317324
JAVASCRIPTINLINE: (node, writeTo) => {
318325
writeTo.push("{\\lstinline[mathescape=true, language=JavaScript]$");
319326
recursiveProcessPureText(node.firstChild, writeTo, {
320-
removeNewline: "all"
327+
removeNewline: "all",
328+
escapeCurlyBracket: true
321329
});
322330
writeTo.push("$}");
323331
},

javascript/processingFunctions/processSnippetPdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const processSnippetPdf = (node, writeTo) => {
186186

187187
if (jsOutputSnippet) {
188188
writeTo.push("\n\\begin{JavaScriptOutput}");
189-
writeTo.push(jsOutputSnippet.firstChild.nodeValue);
189+
writeTo.push(jsOutputSnippet.firstChild.nodeValue.trimRight());
190190
writeTo.push("\\end{JavaScriptOutput}");
191191
}
192192

javascript/processingFunctions/recursiveProcessPureText.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const recursiveProcessPureText = (
1717
if (options.removeNewline == "all") {
1818
value = value.replace(/[\r\n]+/g, " ");
1919
}
20+
if (options.escapeCurlyBracket) {
21+
value = value.replace(/\{/g, "\\{");
22+
value = value.replace(/\}/g, "\\}");
23+
}
2024
writeTo.push(value);
2125
}
2226
return recursiveProcessPureText(node.nextSibling, writeTo, options);

scripts/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ js_svgs: $(js_path)/ch2-Z-G-65.svg.pdf \
152152
$(js_path)/Fig5.15c.std.svg.pdf \
153153
$(js_path)/ch2-Z-G-ex-2-24.svg.pdf \
154154
$(js_path)/ch2-Z-G-ex-2-24-tree.svg.pdf \
155+
$(js_path)/ch3-Z-G-35.svg.pdf \
156+
$(js_path)/ch3-Z-G-49.svg.pdf \
155157
$(js_path)/Fig2.14b.std.svg.pdf

0 commit comments

Comments
 (0)