Skip to content

Commit 95f08f1

Browse files
Addition to snippet macros (#660)
1 parent 970d49c commit 95f08f1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

javascript/processingFunctions/processSnippetPdf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export const processSnippetPdf = (node, writeTo) => {
124124
const jsLonelySnippet = node.getElementsByTagName("JAVASCRIPT_LONELY")[0];
125125
const jsSnippet = node.getElementsByTagName("JAVASCRIPT")[0];
126126
const jsOutputSnippet = node.getElementsByTagName("JAVASCRIPT_OUTPUT")[0];
127+
const allowBreakAfter =
128+
jsSnippet && jsSnippet.getAttribute("BREAK_AFTER") === "yes"
129+
? "\\pagebreak"
130+
: "";
127131

128132
if (jsPromptSnippet) {
129133
writeTo.push(preSpace);
@@ -237,6 +241,7 @@ export const processSnippetPdf = (node, writeTo) => {
237241
"}\n" +
238242
"\\end{lrbox}" +
239243
"\\Usebox{\\UnbreakableBox}\\\\" +
244+
allowBreakAfter +
240245
midSpace +
241246
"\\begin{lrbox}{\\UnbreakableBox}" +
242247
"\\begin{" +
@@ -275,11 +280,11 @@ export const processSnippetPdf = (node, writeTo) => {
275280

276281
if (jsOutputSnippet) {
277282
if (indexTerms.length > 0) writeTo.push(indexTerms.pop());
278-
writeTo.push("\\Usebox{\\UnbreakableBox}");
283+
writeTo.push("\\Usebox{\\UnbreakableBox}" + allowBreakAfter);
279284
outputAdjacent = true;
280285
} else {
281286
if (indexTerms.length > 0) writeTo.push(indexTerms.pop());
282-
writeTo.push("\\Usebox{\\UnbreakableBox}");
287+
writeTo.push("\\Usebox{\\UnbreakableBox}" + allowBreakAfter);
283288
if (!followedByOtherSnippet && !skipPostPadding) {
284289
writeTo.push(postSpace);
285290
} else {

javascript/processingFunctions/replaceTagWithSymbol.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const tagsToReplaceDefault = {
2424

2525
SHORT_SPACE: "",
2626
SHORT_SPACE_AND_ALLOW_BREAK: "",
27+
ALLOW_BREAK: "",
2728

2829
EMDASH: "—",
2930
ENDASH: "–",
@@ -36,7 +37,8 @@ const tagsToReplaceDefault = {
3637

3738
const tagsToReplacePdf = {
3839
SHORT_SPACE: "@xxx", // will be replaced in processSnippet
39-
SHORT_SPACE_AND_ALLOW_BREAK: "@yyy" // will be replaced in processSnippet
40+
SHORT_SPACE_AND_ALLOW_BREAK: "@yyy", // will be replaced in processSnippet
41+
ALLOW_BREAK: "@yyy" // ok to alias short_space_and_allow_break because the short space is implicit in the splitting of code boxes for now
4042
};
4143

4244
export const replaceTagWithSymbol = (node, writeTo, type = "default") => {

0 commit comments

Comments
 (0)