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

Adding compilation from HTML #101

Closed
wants to merge 4 commits into from
Closed

Conversation

eduardo-escoto
Copy link

Hi there!

Thank you for making this package! It has been extremely useful 😄

Not sure if this fits into the scope of this package, but my use case required an HTML string to be compiled and not just MDX. I haven't really found another package that would do that, so after looking through the source of this one -- it felt like a natural fit since I only really needed to edit the unified pipeline and it worked perfectly.

@eduardo-escoto
Copy link
Author

I just realized it might help if I added options for rehype-parse. I can add that in if desired! If you feel that this pull doesn't fit into the scope of this project, please feel free to close it.

Thank you :D

@wooorm
Copy link
Owner

wooorm commented Nov 11, 2021

Huh... Well, my first thought is indeed that it doesn’t match this project: this feature is not about markdown and JSX 🤔
How are you using this? What’s the goal? The input, output, etc?

@eduardo-escoto
Copy link
Author

eduardo-escoto commented Nov 11, 2021

Input: HTML string
Output: Compiled JSX

My use case is I wanted to compile jupyter notebooks so I could use them as a blogging format for my statically generated website.

Essentially, I'd iterate through the cells and generate the html using other unified pipeline stuff and then end up with a big HTML string. This is because Jupyter notebook cells all have different formats so I cant just pass it through one unified pipeline. With this full html string, I compile it with xdm into jsx which next js can render as a component.

No worries if it doesn't fit in! :D just thought I'd try to contribute if you felt it was useful. Maybe a better option is to just turn this into a new project that is more focused around html compilation to jsx that just follows this project closely?

@wooorm
Copy link
Owner

wooorm commented Nov 11, 2021

Assuming you trust the content, why not use dangerouslySetInnerHTML?
It sounds like you’re not using much of the features of xdm, such as layouts, components passing, etc?

I’d be open to the idea but I think it’s a case that few people care about, whereas it’ll hurt many users. rehype-parse is quite big, hurting the the bundle size of everyone. Whereas most of this project has to do with parsing markdown and javascript, so most of the bundle size isn’t useful to your case.

@eduardo-escoto
Copy link
Author

eduardo-escoto commented Nov 11, 2021

That makes sense! I agree with your concern with the bundle size of rehype-parse, probably not worth adding it in for people who don't need this functionality.

I failed to mention earlier that I am actually using the components passing and the layout function of XDM which is one of the main motivations for using this in this way, and why I'm not just using dangerouslySetInnerHTML. So I'll probably just keep it as a fork of this.

Thank you!

@wooorm
Copy link
Owner

wooorm commented Nov 11, 2021

It’s a pretty interested idea though. You might want to publish it. You could also maybe use xdm as a dependency as use the plugins from here instead of a hard fork? They’re not exposed from import * as xdm from 'xdm', but you could import them from the file paths?

@eduardo-escoto
Copy link
Author

eduardo-escoto commented Nov 11, 2021

That's a great idea! I'll go ahead and do that! I can import what I need as you mentioned and publish it separately. Thanks for the help and suggestions! 👍🏼

Also, thanks for all of your work on unified!

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

Successfully merging this pull request may close these issues.

2 participants