Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit d494370

Browse files
authored
Update README.org
1 parent 2ece199 commit d494370

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

README.org

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#+title: org-mode-hs
2-
3-
This repository provides a parser and exporters for Org Mode documents. The Org document is parsed into an AST similar to =org-element='s, and the exporters are highly configurable using HTML, Markdown or LaTeX templates.
41

52
#+begin_quote
63
Post Morten Note: I've learned a lot in my Org journey (which included writing this parser), but I have stopped using Org for anything other than tangling the Emacs config. Honestly, it's a quite messy language once you dig into its idiosyncrasies, its faults and its details. And it was not exactly planned to be used in the outside world.
74

85
I've come to appreciate simpler and more standardized languages, and if I were to recommend something it would be [[https://commonmark.org/][CommonMark]] with all the [[https://github.com/jgm/commonmark-hs/tree/master/commonmark-extensions][extensions]] enabled.
96
#+end_quote
107

8+
* org-mode-hs
9+
10+
This repository provides a parser and exporters for Org Mode documents. The Org document is parsed into an AST similar to =org-element='s, and the exporters are highly configurable using HTML, Markdown or LaTeX templates.
11+
12+
1113

12-
* Table of contents :TOC:
14+
** Table of contents :TOC:
1315
- [[#org-cli-horg][org-cli (horg)]]
1416
- [[#usage][Usage]]
1517
- [[#installation-from-source][Installation from source]]
@@ -21,11 +23,11 @@ I've come to appreciate simpler and more standardized languages, and if I were t
2123
- [[#org-exporters-library][org-exporters library]]
2224
- [[#defining-a-new-export-backend][Defining a new export backend]]
2325

24-
* org-cli (horg)
26+
** org-cli (horg)
2527

2628
You can find compiled binaries for Linux and MacOS on the [[https://github.com/lucasvreis/org-mode-hs/releases][releases page]].
2729

28-
** Usage
30+
*** Usage
2931
The =horg= CLI tool has some basic help pages, to see them type:
3032
#+begin_src bash
3133
# Global help
@@ -43,7 +45,7 @@ horg export html -i myfile.org -o out.html
4345
horg export html -i myfile.org --stdout
4446
#+end_src
4547

46-
*** Using Pandoc
48+
**** Using Pandoc
4749
The Pandoc exporter does not output Pandoc formats directly, but rather, it generates a JSON AST that can be fed into Pandoc. You can pipe this JSON into Pandoc to convert to Markdown or any other supported format:
4850

4951
#+begin_src bash
@@ -52,8 +54,8 @@ horg export pandoc -i myfile.org --stdout | pandoc --from json --to markdown
5254

5355
It can happen that the JSON API version is incompatible with your installed version of Pandoc. The CI compiles =horg= with the latest Pandoc API available at the build time, so using the latest released version of the Pandoc binary has a good chance of fixing the problem.
5456

55-
** Installation from source
56-
*** Using =cabal=
57+
*** Installation from source
58+
**** Using =cabal=
5759
#+begin_src bash
5860
git clone https://github.com/lucasvreis/org-mode-hs.git
5961
cd org-mode-hs
@@ -62,14 +64,14 @@ cabal install horg
6264

6365
Please note that this library and some of its dependencies are not on Hackage yet, so you need to clone this repository first.
6466

65-
** Customizing templates
67+
*** Customizing templates
6668
You can use the =horg init-templates= command to populate a =.horg= directory in the current directory with the default templates, which you can then modify.
6769

6870
Detailed documentation on how the templates work is TODO.
6971

70-
* org-parser library
71-
** How to test and play with it
72-
*** Testing the parser in =ghci=
72+
** org-parser library
73+
*** How to test and play with it
74+
**** Testing the parser in =ghci=
7375

7476
This assumes you have =cabal= installed.
7577

@@ -85,10 +87,10 @@ You can write the contents to be parsed between =[text|= and =|]=. More generall
8587

8688
Where =[parser to parse]= can be basically any of the functions from =Org.Parse.Document=, =Org.Parser.Elements= or =Org.Parser.Objects= whose types are wrapped by the =OrgParser= or =Marked OrgParser= monads. You don't need to import those modules yourself as they are already imported in the ~test~ namespace.
8789

88-
*** Unit tests
90+
**** Unit tests
8991
You can view the unit tests under [[org-parser/test][org-parser/test]]. They aim to touch as much corner cases as possible against org-element, so you can take a look there to see what already works, and how well it works.
9092

91-
** Progress
93+
*** Progress
9294
In the spec terms (see below the table for other features), the following components are implemented:
9395
| Component | Type | Parse |
9496
|---------------------+-------------------+-------|
@@ -148,7 +150,7 @@ In the spec terms (see below the table for other features), the following compon
148150
| Markup | X | X |
149151
(Thanks @tecosaur for the table)
150152

151-
*** Going beyond what is listed in the spec
153+
**** Going beyond what is listed in the spec
152154

153155
~org-element-parse-buffer~ does not parse /everything/ that will eventually be parsed or processed when exporting a document written in Org-mode. Examples of Org features that are not handled by the parser alone (so aren't described in the spec) include content from keywords like =#+title:=, that are parsed "later" by the exporter itself, references in lines of =src= or =example= blocks and link resolving, that are done in a post-processing step, and the use of =#+include:= keywords, =TODO= keywords and radio links, that are done in a pre-processing step.
154156

@@ -164,7 +166,7 @@ Since the aspects listed above are genuine /org-mode features/, and not optional
164166
| Per-file TODO keywords | not yet (on the way, some work is done) |
165167
| Macro definitions and substitution | not yet (on the way, some work is done) |
166168

167-
** Comparasion to Pandoc
169+
*** Comparasion to Pandoc
168170
The main difference between =org-parser= and the Pandoc Org Reader is that this one parses into an AST is more similar to the org-element's AST, while Pandoc's parses into the =Pandoc= AST, which cannot express all Org elements directly. This has the effect that some Org features are either unsupported by the reader or "projected" onto =Pandoc= in ways that bundle less information about the Org source. In contrast, this parser aims to represent Org documents more faithfully before "projecting" them into formats like HTML or the Pandoc AST itself. So you can expect more org-specific features to be parsed, and a hopefully more accurate parsing in general.
169171

170172
Also, if you are developer mainly interested in rendering Org documents to HTML, Pandoc is a very big library to depend upon, with very long build times (at least in my computer, sadly).
@@ -181,10 +183,10 @@ This single paragraph is broken into three by Pandoc, because it looks for a new
181183

182184
Another noteworthy difference is that =haskell-org-parser= uses a different parsing library, ~megaparsec~. Pandoc uses the older ~parsec~, but also bundles many features on its own library.
183185

184-
* org-exporters library
186+
** org-exporters library
185187
This library provides functions for post-processing of the Org AST and exporting to various formats with =ondim=.
186188

187-
** Defining a new export backend
189+
*** Defining a new export backend
188190
Basically:
189191
- Use the [[https://github.com/lucasvreis/ondim][~ondim~ library]] to create a Ondim template system for the desired format, if it does not already exist.
190192
- Import ~Org.Exporters.Common~ and create an ~ExportBackend~ for your format.

0 commit comments

Comments
 (0)