k2052 / org-to-markdown

org mode to markdown/mdx
ISC License
31 stars 2 forks source link

Tables support #71

Closed kepi closed 1 year ago

kepi commented 1 year ago

Hi,

I'm trying to use Org files with Qwik project. I'm currently looking for any, not necesearily clean, way how to do this.

I suppose best approach would be to mimic way how MDX is implemented in Qwik City using Orga.js. But frankly, I'm completely out of my depth.

But then I found your project and it look like something I can manage to get working. At least for proof-of-concept :)

I created small script which takes org files from our repo and convert it to directory-based structure Qwik City needs. So far it is working, but tables are probably not supported, as I'm getting error:

Missing compiler for node of type `table.cell`: `[object Object]`'

And with that, I'm currently done, as whole unified, remark and others are complete mystery to me at this moment. Is it possible to implement support for tables or at least point me to files which might be relevant so I can try to hack it together?

Example document:

| Name | Value     |
|------+-----------|
| Test | Something |
| And  | Anything  |
k2052 commented 1 year ago

This project is mostly just wrappers around https://github.com/orgapp/orgajs which incorporated JSX support a couple years ago when he rewrote the entire thing, so I would probably use that directly now instead. If you want to use orgajs in a script directly see the getting-started example: https://github.com/orgapp/orgajs/blob/main/examples/getting-started/index.js. If you want to use my project instead you can if you are brave implement table support by modifying https://github.com/k2052/org-to-markdown/blob/master/packages/orga-remark/index.js. I don't have the time to work on this myself but I'll happily accept and merge any pull requests.

That said, both our projects are pretty much abandoned at this point and you are liable to encounter a few unfixed bugs that without knowledge of the ecosystem can be painful to fix. I think everyone that was doing JSX and MDX with Emacs settled on using custom exporters from Emacs itself. Parsing org-mode outside of Emacs proved to be both too niche to develop a community around and too much of a pain to keep working and updated.

If you are comfortable writing Elisp a custom exporter might be a good route to pursue. It mostly just involves modifying ox-html to use JSX compatible syntax (e.g changing class to className) or modifying ox-md to export the contents of begin_export jsx as a just a string instead of a code block. There are a few examples of this if you search around people's dotfiles and gists. No one has taken the time to polish anything up into a maintained package though. I might try to get around to cleaning up and open sourcing my hacky ox-jsx exporter one day. Happy to provide pointers, snippets of code, and guidance if you need it.

kepi commented 1 year ago

Funny enough, I didn't realize that those last updates in this repo were just dependabot merges :D and that your project isn't based on the more recent OrgaJS.

Anyway, huge thanks for all the info! I'm really glad I opened the issue as it will definitely help me get our project working.

I have some experience with OrgaJS as we are using it in our current solution with Gatsby. But all the magic happened there by itself and I never (successfully) dug deep enough. But from the example you provided, it seems that it might be easy to process multiple files as I need.

As for OrgaJS abandonment - that's really a pity. I hoped that in the end, I'll manage to integrate OrgaJS with its React components support into Qwik City.

I might be comfortable writing Elisp, just not really good at it :) But you are right that it might be, in the end, an easier solution. I know it should be possible to run it from the command line too. If you publish your ox-jsx somewhere, definitely let me know. The only downside of exporting from Org for me is that I'll have to create some automation around it. We have multiple people creating and changing Org content and I'll have to spawn Emacs with some Elisp after every change, which would be a bit more heavy-weight than using current OrgaJS in Gatsby, but at least there is some way.

I suppose we can close this. If I choose to go with your project instead of OrgaJS directly, I'll definitely send you a PR.