diff --git a/src/app/components/elements/markup/latexRendering.ts b/src/app/components/elements/markup/latexRendering.ts index cd5ecf87b6..c9d101d5b8 100644 --- a/src/app/components/elements/markup/latexRendering.ts +++ b/src/app/components/elements/markup/latexRendering.ts @@ -252,7 +252,14 @@ export function katexify(html: string, user: Immutable | null, bo endMatch(match, search); } if (search.matched && match) { - const latex = html.substring(index + (search.olen || 0), match.index + match[0].length - (search.clen || 0)); + let latex = html.substring(index + (search.olen || 0), match.index + match[0].length - (search.clen || 0)); + + const charAfter = html[match.index + match[0].length]; + if (/[.,"':;?!)]/.test(charAfter)) { + latex += charAfter; + match.index++; + } + const latexUnEntitied = he.decode(latex); const latexMunged = munge(latexUnEntitied); let macrosToUse; diff --git a/src/test/pages/__image_snapshots__/ada/Question types' regression test page should have no visual regressions #0.png b/src/test/pages/__image_snapshots__/ada/Question types' regression test page should have no visual regressions #0.png index e0fd201130..4acc30b836 100644 Binary files a/src/test/pages/__image_snapshots__/ada/Question types' regression test page should have no visual regressions #0.png and b/src/test/pages/__image_snapshots__/ada/Question types' regression test page should have no visual regressions #0.png differ diff --git a/src/test/pages/__image_snapshots__/phy/Question types' regression test page should have no visual regressions #0.png b/src/test/pages/__image_snapshots__/phy/Question types' regression test page should have no visual regressions #0.png index f28040d562..b6467ee7fa 100644 Binary files a/src/test/pages/__image_snapshots__/phy/Question types' regression test page should have no visual regressions #0.png and b/src/test/pages/__image_snapshots__/phy/Question types' regression test page should have no visual regressions #0.png differ