// Frozen pre-optimization implementation: an independent streaming equivalence oracle. function originalReplace(line: string): string { let output = '' let index = 0 let codeDelimiterLength = 0 while (index < line.length) { if (line[index] === '`') { let runLength = 1 while (line[index + runLength] === '`') runLength += 1 if (codeDelimiterLength === 0 || codeDelimiterLength === runLength) { codeDelimiterLength = codeDelimiterLength === 0 ? runLength : 0 } output += line.slice(index, index + runLength) index += runLength continue } if (codeDelimiterLength === 0 && line[index] === '\\' && line[index - 1] !== '\\' && (line[index + 1] === '(' || line[index + 1] === ')')) { output += '$' index += 2 continue } output += line[index] index += 1 } return output } export function originalNormalize(content: string): string { let fence: { character: '`' | '~'; length: number } | undefined return content.split(/\r?\n/u).map(line => { if (fence) { const closingFence = new RegExp(`^ {0,3}${fence.character}{${fence.length},}\\s*$`, 'u') if (closingFence.test(line)) fence = undefined return line } const openingFence = /^ {0,3}(`{3,}|~{3,})/u.exec(line) if (openingFence) { const marker = openingFence[1]! fence = { character: marker[0] as '`' | '~', length: marker.length } return line } const standaloneDollar = /^ {0,3}\$(?!\$)(.+?)(?\r\n
\\(x\\)
\r\n