syntax-tree / hast-util-to-estree Goto Github PK
View Code? Open in Web Editor NEWhast utility to transform to estree (JavaScript AST) JSX
Home Page: https://unifiedjs.com
License: MIT License
hast utility to transform to estree (JavaScript AST) JSX
Home Page: https://unifiedjs.com
License: MIT License
I would like to be able to customize (replacing existing and/or adding more) handlers via options.
I tried to use this module to parse my hast
to estree
, but I have something extra in my hast (via raw
nodes) I would like to be able to deal with myself. It's easy to copy & paste code here into my project, but it'd be good to be able to leverage this module instead.
add handlers
option in options
and merge it with the default one.
Can't think of any good ones.
2.3.2
No response
Install the package.
The package should contain index.d.ts
file as described in README and package.json file. Was the build command skipped before releasing the package?
index.d.ts
file is missing.
any
No response
No response
No response
To set up MDX with Solid (e.g. Solid Start), I need to use @mdx-js/rollup
which calls @mdx-js/mdx
, which uses the rehypeRecma
plugin, which calls this util. Then, this util has the element
handler which takes care of creating the AST for the JSX elements.
The way it works seems tailored to React in some ways. The two problematic ones I've found are:
className
prop: while it still works in Solid, it's been deprecated and will probably be removed at some point - ref: https://www.solidjs.com/docs/latest#classliststyle
prop: this library turns inline CSS strings into CSS-in-JS syntax, which Solid does understand, but it does so in camel-case. Solid expects the properties to be in their original casing (e.g. background-color
not backgroundColor
), which makes the output of some rehype plugins incompatible - ref: ref: https://www.solidjs.com/docs/latest#classlist (again 😄)There might be more instances of this, but I'm not sure.
I've seen that this library supports configuring the handlers, which is great. However, I have two thoughts about this:
@mdx-js/rollup
. I guess it could be a jsxSomething
option (jsxFlavor
? haha). This util it could have the same option and then it could be passed to the default handlers through the state (I guess? not super familiar so I can't tell if that makes sense).A solution I've thought of is to create a rehype plugin that "undoes" these changes (e.g. renaming className
to class
and de-camelcasing the style
objects). The problem is that rehypeRecma
runs after the external plugins, so there's no way to cleanly execute this.
The only way would be to patch @mdx-js/mdx
to introduce the plugin (in core.js
), but if I'm patching the package, I might as well just patch this one (element
handler) to prevent this from happening in the first place.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.