I see two ways to fix this:
\nstyled-jsx
packagerehype-typst
, and change this somehow.React does not support namespaces in the svg
string generated by typst:
SyntaxError: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.\n
We can work around this by ignoring the react error in the .babelrc
file, with the following config:
{\n \"presets\": [\n [\n \"next/babel\",\n {\n \"preset-react\": { \"throwIfNamespace\": false }\n }\n ]\n ],\n \"plugins\": []\n}
Perhaps one way to work around this is to add an option in rehype-typst
to convert the resulting SVG files into JSX format.
\nThis could be off by default, but would have to be turned on for React apps.
I did some quick searching, but could not find an npm plugin to automatically convert SVG to JSX, but I found this online app, which is open source. So we could take a look and see how they do it, perhaps publish it as an npm package.
\nLet me know what you think!
\nI'll try to do the following at some point in the future:
\nstyled-jsx
package.Thanks for the responses!
\nI just tried out the latest Next.js version, including the app router.
\nIt works fine!
\n(With the exception of a hydration error, but that's not a big problem.)
You can check out here: https://github.com/Loosetooth/next-rehype-typst-mdx
\nAs such you can ignore my opening comment above. I tried that out in an older project.
\nSeemingly, those issues have already been fixed one way or another.
-
Hey there, first of all, thanks for all the work on typst.ts! I like to write in MDX for blogs and the like, and Next.js does a good job of generating pages from MDX files. Yesterday I worked on getting Issue 1Inability to compile // styled-jsx/dist/babel/index.js
var isStyledJsx = function(param) {
var el = param.node;
return lib$1.isJSXElement(el) && el.openingElement.name.name === "style" && el.openingElement.attributes.some(function(attr) {
// OLD: return attr.name.name === STYLE_ATTRIBUTE;
// NEW:
return attr.name?.name === STYLE_ATTRIBUTE;
});
}; I see two ways to fix this:
Issue 2React does not support namespaces in the
We can work around this by ignoring the react error in the {
"presets": [
[
"next/babel",
{
"preset-react": { "throwIfNamespace": false }
}
]
],
"plugins": []
} Perhaps one way to work around this is to add an option in I did some quick searching, but could not find an npm plugin to automatically convert SVG to JSX, but I found this online app, which is open source. So we could take a look and see how they do it, perhaps publish it as an npm package. Let me know what you think! I'll try to do the following at some point in the future:
|
Beta Was this translation helpful? Give feedback.
-
@Enter-tainer may help. I'll also look at it later. |
Beta Was this translation helpful? Give feedback.
-
make sense to me. although i dont think empty style tag is a bug.
i dont really know how next.js works. from rehype-typst's view, it convert typst code to hast and cannot see jsx or relevant things. maybe the solution should be turning some switches on. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the responses! I just tried out the latest Next.js version, including the app router. You can check out here: https://github.com/Loosetooth/next-rehype-typst-mdx As such you can ignore my opening comment above. I tried that out in an older project. |
Beta Was this translation helpful? Give feedback.
Thanks for the responses!
I just tried out the latest Next.js version, including the app router.
It works fine!
(With the exception of a hydration error, but that's not a big problem.)
You can check out here: https://github.com/Loosetooth/next-rehype-typst-mdx
As such you can ignore my opening comment above. I tried that out in an older project.
Seemingly, those issues have already been fixed one way or another.