Using Katex to render math and want to ignore something wrapped in $ $

Discussão em 'Angular' iniciado por cekborg, Abril 14, 2025.

  1. cekborg

    cekborg Guest

    I currently am using ngx-markdown katex library to markdown math. I have a response right now that gets formatted weird because it is 'wrapped' in $ $. How can I bypass this? I have tried replacing the $ with \$, \\$, and \text{$}. None of these have worked. In my code to get Katex to render I need to wrap equations in \[ \]. Is there a way I can make the render completely ignore the $ rule?

    .replace(/\\\(/g, '\\\\(') // Replace opening \( with \\(
    .replace(/\\\)/g, '\\\\)') // Replace closing \) with \\)
    .replace(/\\\[/g, '\\\\[') // Replace opening \[ with \\[
    .replace(/\\\]/g, '\\\\]') // Replace closing \] with \\]

    1. Day 1: $1
    2. Day 2: $2 (doubles to $2)
    3. Day 3: $4 (doubles to $4)
    4. Day 4: $8 (doubles to $8)
    5. Day 5: $16 (doubles to $16)

    Here is whats getting funky. The text between $$. So for instance 2 (doubles to gets a weird markdown applied. If I do \$ I see same result and then if I replace to \\$ I see normal text but now the $ are \$.

    Continue reading...

Compartilhe esta Página