Skip to content

arisgk/automerge-pandoc

Repository files navigation

automerge-pandoc

CLI tool that converts Automerge rich text to/from other formats, leveraging Pandoc. Built using Haskell.

A Note on Maturity

Not all Automerge rich text features are supported yet and most probably some corner cases are not handled properly yet. The emphasis was on first covering heading and paragraph blocks and bold and italics marks. Incrementally, this repo will be extended to cover the Automerge Rich Text schema and then to reach feature parity with some important rich text representations such as Markdown.

How it Works

Automerge Spans (their JSON format) are used as the representation of Automerge rich text. When converting from Automerge spans to other formats, a conversion to the Haskell Pandoc type is done first. This type corresponds to Pandoc's model for rich text. Then, Pandoc can handle producing an output to any of its supported formats. The inverse operation (other formats to Automerge spans) are done by first converting to the Pandoc model and then mapping it to the Automerge spans. Reading from and writing to various formats using Pandoc is based on its simple example.

Prerequisites

Install Haskell Stack so that you can run the CLI.

MacOS

Pandoc needs pkg-config to be built in MacOS. To install it, first install Homebrew and then run brew install pkg-config.

How to Run

Navigate to project root and run stack build to compile the project.

Convert from Automerge Spans

To Pandoc AST

stack exec automerge-pandoc fromAutomerge -- --to pandoc AUTOMERGE_SPANS_JSON

To Markdown

stack exec automerge-pandoc fromAutomerge -- --to markdown AUTOMERGE_SPANS_JSON

To HTML

stack exec automerge-pandoc fromAutomerge -- --to html AUTOMERGE_SPANS_JSON

Convert to Automerge Spans

To Pandoc AST

stack exec automerge-pandoc toAutomerge -- --from pandoc PANDOC_AST

To Markdown

stack exec automerge-pandoc toAutomerge -- --from markdown MARKDOWN_STRING

To HTML

stack exec automerge-pandoc toAutomerge -- --from html HTML_STRING

Build for WebAssembly

There are instructions for building the project for WebAssembly here.

About

Automerge Rich Text to/from Pandoc AST

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published