-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with svelte #104
Comments
Welcome @tobiasBora! 👋 That said, there is still a way to handle this. |
This comment has been minimized.
This comment has been minimized.
@ChristianMurphy Thanks, even if I'm a bit sad to see that there is no plan to solve this. But I'm curious, would it make sense to allow the user to define a custom wrapper code around the html produced by remark-math? This may be a wrapper like
Out of curiosity, aren't they valid HTML syntaxically? Like in HTML, nothing prevents me from writing
Hum interesting, I need to check how far I can go with this. But I guess I will not be able anymore to use svelte-syntax in the html like:
EDIT
(there might be a more efficient way than stringify + parse again… but at least it seems to be parsed correctly by hast as valid HTML) |
It would make a lot of sense yes to wrap things. It already exists: that wrapper is Note: MDX itself also supports Svelte, somewhat. It should not have these problems: https://mdxjs.com/docs/getting-started/#jsx. That being said, Svelte does not itself implement a JSX runtime, which is why |
So if my understanding is correct, for now stuff goes like
Regarding MDX it is another option to try if you say it should work, but I guess I lose some of the nice integration between mdsvex and svelte (like I can call a svelte component from the markdown)… And also svelte-jsx seems unmaintained and sveltejs/svelte#8256 mentions it is also buggy, so this seems overkill compared to a ~ one-line addition to rehype-katex… In the worst case, if neither you nor mdsvex want to implement a solution, would it make sense to create a rehype plugin running right after rehype-katex that picks all div with class like |
I do not know exactly how mdsvex works so I cannot comment exactly on its pipeline. I am not interested in adding some workaround for you. The proper solution is to either maintain some version of svelte-jsx, there, or in svelte (which makes sense to me because every other framework does that, vue solid preact whatever). Or for mdsvex to know whether a human wrote something or something exists in a string Indeed, you can also do workarounds with plugins yourself |
Ok, too bad, that's life. Will use rehype-katex-svelte then until a cleaner solution is found. |
Initial checklist
Affected package
[email protected]
Steps to reproduce
Rehype-katex does not work with svelte with simple expressions involving
\mathbb{N}
or\sqrt{x}
, apparently due to the fact that svelte interprets{}
as a template. Other projects like https://github.com/kwshi/rehype-katex-svelte have been created to solve this issue using instead{@html "..."}
, but they seem unmaintained.To reproduce:
Clone tobiasBora/understand-pid-algo@af0b30e and checkout to the commit af0b30e9ffcfc7b55b19cb5a023b28b3acc20aac, run
npm run dev
, and visit the home page.Actual behavior
Observe that you have an error due to the line:
the error being on the sqrt:
Expected behavior
Should work as his expression is valid latex.
Runtime
[email protected]
Package manager
[email protected]
Operating system
NixOs unstable
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered: