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

Add core.pandoc #684

Closed
wants to merge 3 commits into from
Closed

Add core.pandoc #684

wants to merge 3 commits into from

Conversation

bandithedoge
Copy link

@bandithedoge bandithedoge commented Nov 28, 2022

Very WIP and very temporary solution for reliably exporting Neorg documents into other formats via Pandoc. It will be deprecated once https://github.com/Simre1/neorg-haskell-parser is stable. You can test it right now, but it requires a pandoc binary to be available in your $PATH. This unfortunately introduces a rather large Haskell dependency, therefore it does not completely replace core.export yet (although it will be deprecated by this module in the future).

This module works by walking the AST of an norg document using tree_map_rec and transforming it into Pandoc's native JSON representation with vim.json.encode, making it very efficient1. This is only an exporter; it is not a proper parser and does not allow for converting other formats to norg.

If you're eager to try it out right now, add the module to your config, open an norg file and run :Neorg pandoc json. Don't panic if it errors out with node types as messages - those are just unimplemented and will not be included in the output. This will output JSON to json.json in your current working directory which can be read by Pandoc, for example: pandoc json.json -o test.md. Keep in mind that this interface probably won't survive very long.

Implementation status (copied from https://github.com/Simre1/neorg-haskell-parser#implementation-status)

  • Attached Modifiers: 🚧
  • Intersecting modifiers: ❌
  • Detached Modifiers: ❌
    • Heading: 🚧
    • List: ❌
      • Unordered lists: ❌
      • Ordered lists: ❌
      • TODO lists: ❌
      • Other list types: ❌
    • Quotes: ❌
    • Markers: ❌
    • Insertions: ❌
  • Definitions: ❌
  • Tags: 🚧
  • Trailing modifiers: ❌
  • Escaping: ❌
  • Horizontal line: ❌
  • Links: ❌
  • Anchors: ❌

Legend

  • Implemented: ✅
  • Work in Progress: 🚧
  • Not implemented: ❌

Footnotes

  1. Source: just trust me bro. There is currently no way to properly benchmark it since neither this module nor @Simre1's parser fully implement the spec. For now just believe me when I say it's fast enough for you not to notice it.

@raj-magesh
Copy link

Sorry if this isn't the best place to discuss this, but I was wondering if this could be turned into a custom reader/writer for Pandoc since the Haskell parser project appears to be temporarily stalled. I'm interested in helping work on this!

@vhyrro
Copy link
Member

vhyrro commented Sep 15, 2023

Since there are WIP implementations of true pandoc parsers I think it's safe to close this issue as "superseded by x". Currently the following parser has worked for almost any document up to level 3 for me! The official pandoc parser made in haskell will probably follow.

@vhyrro vhyrro closed this Sep 15, 2023
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.

3 participants