diff --git a/ts/editable/mathjax.ts b/ts/editable/mathjax.ts index 00a6027d8..6ef29cb57 100644 --- a/ts/editable/mathjax.ts +++ b/ts/editable/mathjax.ts @@ -36,6 +36,7 @@ export function convertMathjax( nightMode: boolean, fontSize: number, ): [string, string] { + input = revealClozeAnswers(input); const style = getStyle(getCSS(nightMode, fontSize)); if (input.trim().length === 0) { @@ -78,3 +79,9 @@ export function escapeSomeEntities(value: string): string { export function unescapeSomeEntities(value: string): string { return value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); } + +function revealClozeAnswers(input: string): string { + // one-line version of regex in cloze.rs + const regex = /\{\{c(\d+)::(.*?)(?:::(.*?))?\}\}/gis; + return input.replace(regex, "[$2]"); +}