Skip to content

Commit 4937241

Browse files
committed
Don't wrap punctuation after LaTeX
If punctuation follows a latex expression, consider the punctuation as part of the expression to avoid it being wrapped on to the next line. This doesn't address the root cause of why this bug appeared, but it works as a quick fix.
1 parent 4089610 commit 4937241

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/app/components/elements/markup/latexRendering.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,14 @@ export function katexify(html: string, user: Immutable<PotentialUser> | null, bo
252252
endMatch(match, search);
253253
}
254254
if (search.matched && match) {
255-
const latex = html.substring(index + (search.olen || 0), match.index + match[0].length - (search.clen || 0));
255+
let latex = html.substring(index + (search.olen || 0), match.index + match[0].length - (search.clen || 0));
256+
257+
const charAfter = html[match.index + match[0].length];
258+
if (/[.,"':;?!)]/.test(charAfter)) {
259+
latex += charAfter;
260+
match.index++;
261+
}
262+
256263
const latexUnEntitied = he.decode(latex);
257264
const latexMunged = munge(latexUnEntitied);
258265
let macrosToUse;

0 commit comments

Comments
 (0)