Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Simre1/neorg-haskell-parser
https://github.com/Simre1/neorg-haskell-parser
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Simre1/neorg-haskell-parser
- Owner: Simre1
- License: mit
- Created: 2021-10-16T18:11:25.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T23:11:18.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T11:50:24.835Z (about 2 months ago)
- Language: Haskell
- Size: 8.65 MB
- Stars: 91
- Watchers: 6
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Neorg Haskell Parser
Reimplementation of the parser with the [Neorg markup specification](https://github.com/nvim-neorg/norg-specs). It will be able to transform .norg files to the [pandoc](https://github.com/jgm/pandoc) AST and subsequently to the plethora of formats that pandoc supports.
## Create an issue if you find unexpected behavior!
Help me to find all edge cases of the parser. If you find a parsing error, you can create an issue with the **Parsing / Generation error** template.
## Parser Implementation State
I will focus on the first three layers for now. Layers 4 and 5 are on hold for now.
- [x] Layer 1
- [x] Layer 2
- [ ] Layer 3## Pandoc Implementation State
- [x] Layer 1
- [x] Layer 2
- [ ] Layer 3
- [ ] PDF creation## Installation
### Using a precompiled binary
I have added a compiled binary for linux in the [releases section of github](https://github.com/Simre1/neorg-haskell-parser/releases), which should work on most x86 linux systems.
### Building from Source
You will need ghc and cabal. Then you can build the project with:
```bash
cabal build neorg-pandoc
```You can run the tests with:
```bash
cabal run neorg-test
```## Usage
After having aquired a binary of `neorg-pandoc`, you can use it to transform Neorg files into Pandoc json documents. You have two ways of feeding your norg document to `neorg-pandoc`:
1. `-f file.norg`: neorg-pandoc will read file.norg and print a pandoc json to stdout
2. `-i`: neorg-pandoc will read stdin and print a pandoc json to stdoutErrors are thrown on stderr.
An example usage might be:
```bash
./neorg-pandoc-linux86 -f testing/test.norg | pandoc -f json -o testing/out.pdf
```Here, I have used the `neorg-pandoc-linux86` binary to transform my `norg` file into the pandoc `json` format. The result is piped into pandoc to create a pdf. The `-f json` argument tells pandoc that the input is a `json` file and `-o testing/out.pdf` is the location of the `pdf` file. It is also possible to transform your `norg` file into other formats; for example to markdown by replacing `-o testing/out.pdf` with `-o testing/out.md`. For further options refer to the `pandoc` documentation.
## How to Contribute
1. Fix one of the issues
2. Find parsing errors and create issues for them using the parsing error template### Testing Pipeline
I have set up a Github Action pipeline which runs the tests for neorg. So you do not need to worry much that you break something, since it will be detected most of the time.
There are two kinds of tests:
- `parser-tests`: Small snippets are parsed and the resulting AST is validated
- `norg-markdown-equal-test`: Norg and Markdown files are parsed and the resulting Pandoc AST is checked for equality