You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<div class="math math-inline">
… some stuff involving {x} that is interpreted by svelte
</div>
and it produces error as {x} usually comes from a math expression like \sqrt{x} and is not meant to be replaced as a svelte variable. People created a rehype-katex-svelte (as recommended in #302) to solve this issue and this seems to work reasonably well, but I don't know how well maintained this is (e.g. it requires a quite old remark-math, but so do rehype-katex so it might be unrelated) and the author mention some potential security flows. As such, it seems not at battle-tested as rehype-katex.
As such, I was wondering if would instead directly allow users to add in MDsveX (via the options) a list of classes that should be wrapped around {@html } appropriately (with escaping etc) in order not to be interpreted by svelte later in the process. As rehype-katex does not want to do it on their side (see remarkjs/remark-math#104), I see not much other solution, and this might anyway be useful in other scenarios.
The text was updated successfully, but these errors were encountered:
Haven't thought much about this, but for a general functionality of "escaping" Svelte code, wouldn't a custom remark-directive named notSvelte or similar be a good solution? Where theContent in the directive is replaced with @html{`theContent`}, and that can be used like this:
Between the square brackets :notSvelte[in here using { and } works].
::notSvelte[In here using { and } works.]
:::notSvelte
In here, using { and } works.
:::
Hum, that is also an interesting option (we can even nest ::notSvelte and ::svelte), but I'd say that both would be interesting: what you describe is cool to escape any code easily with no configuration, but is quite verbose and error-prone when used for math: I don't want to type in the markdown directly ::notSvelte[$a+b$] everytime I write some math as this is just too verbose. The class-based approach is useful when we don't want/can't change the markdown itself as the code is generated from an external library like Katex.
When using
rehype-katex
, it generates text like:and it produces error as
{x}
usually comes from a math expression like\sqrt{x}
and is not meant to be replaced as a svelte variable. People created a rehype-katex-svelte (as recommended in #302) to solve this issue and this seems to work reasonably well, but I don't know how well maintained this is (e.g. it requires a quite old remark-math, but so do rehype-katex so it might be unrelated) and the author mention some potential security flows. As such, it seems not at battle-tested asrehype-katex
.As such, I was wondering if would instead directly allow users to add in
MDsveX
(via the options) a list of classes that should be wrapped around{@html }
appropriately (with escaping etc) in order not to be interpreted by svelte later in the process. As rehype-katex does not want to do it on their side (see remarkjs/remark-math#104), I see not much other solution, and this might anyway be useful in other scenarios.The text was updated successfully, but these errors were encountered: