Markdown preview with dollar currency symbols get interpreted as LaTeX

based on LINQPad Beta 9.12.5

Given the following markdown, in a .md file, the preview displays LaTeX in between the '$' signs:

"Anthropic plans to spend more than $800 billion on computing infrastructure between now and 2045. The group has cash and equivalents of more than $112 billion, and investors anticipate it could raise about $100 billion more in the IPO."

...previews as this

Claude suggests the following (for LINQPad.UI.MarkdownPreviewRenderer.BuildDocument)

Claude analysis

The preview page runs KaTeX auto-render over the rendered DOM with a bare $ delimiter:

const MATH_DELIMS = [
    { left: '$$',  right: '$$',  display: true  },
    { left: '\\[', right: '\\]', display: true  },
    { left: '\\(', right: '\\)', display: false },
    { left: '$',   right: '$',   display: false },
];
renderMathInElement(document.getElementById('content'),
    { delimiters: MATH_DELIMS, throwOnError: false });

KaTeX auto-render matches delimiters by plain string search. It doesn't use currency heuristics used by GitHub or Pandoc: no whitespace after the opening $, no whitespace before the closing $, and no digit after the closing $.

Suggestions

  • Drop the bare $ delimiter and keep $$, \(...\) and \[...\].
  • Or make single-dollar math opt-in (a setting or front-matter flag).

All other rendering appears to work correctly including using the LatexViewer control which throws an error as expected.