Skip to content
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

feature request: serialize nodes and attributes to custom code #154

Open
drudv opened this issue Feb 3, 2018 · 0 comments
Open

feature request: serialize nodes and attributes to custom code #154

drudv opened this issue Feb 3, 2018 · 0 comments

Comments

@drudv
Copy link

drudv commented Feb 3, 2018

Modifying of source HTML files and converting them again to JSX using HTMLtoJSX requires a lot of manual work to re-apply custom changes made in JSX (e.g. set custom properties, strip out some tags, etc.). It's pretty annoying, when you need to periodically make multiple changes to source HTML files and it would be great to have a functionality to replace certain nodes or element attributes with custom code to automate compilation to JSX. In my case I convert a number of SVG files to React classes, where I need to strip out some meta tags and attributes and assign some calculated properties.

I propose to add two optional hooks to config: onNode and onElementAttribute which either return undefined (i.e. use default serializer) or a string that should be used to serialize nodes and attributes to the output JSX.

I prepared a PoC of this functionality here. Please take a look. If it's fine, I would make a PR.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant