CLI tool that converts Automerge rich text to/from other formats, leveraging Pandoc. Built using Haskell.
Not all Automerge rich text features are supported yet and most probably some corner cases are not handled properly yet. Importantly, images are not implemented yet. Same with the code block language attribute. 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.
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.
Install Haskell Stack so that you can run the CLI.
Pandoc needs pkg-config to be built in MacOS. To install it, first install Homebrew and then run brew install pkg-config.
Navigate to project root and run stack build to compile the project.
stack exec automerge-pandoc fromAutomerge -- --to pandoc AUTOMERGE_SPANS_JSON
stack exec automerge-pandoc fromAutomerge -- --to markdown AUTOMERGE_SPANS_JSON
stack exec automerge-pandoc fromAutomerge -- --to html AUTOMERGE_SPANS_JSON
stack exec automerge-pandoc fromAutomerge -- --to json AUTOMERGE_SPANS_JSON
stack exec automerge-pandoc toAutomerge -- --from pandoc PANDOC_AST
stack exec automerge-pandoc toAutomerge -- --from markdown MARKDOWN_STRING
stack exec automerge-pandoc toAutomerge -- --from html HTML_STRING
stack exec automerge-pandoc toAutomerge -- --from json JSON_STRING
There are instructions for building the project for WebAssembly here.
Navigate to the project root folder and run the following command to build and run the tests:
stack build --test