Project

coradoc

0.01
There's a lot of open issues
No release in over a year
Experimental AsciiDoc parser for metanorma
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.0.0
~> 1.13
>= 0
>= 1.3.0
~> 0.1.1
 Project Readme

Coradoc: object-oriented AsciiDoc parser

Gem Version Build Status Pull Requests Commits since latest

Coradoc is a modern Parser for Asciidoc document. It defines a grammar for AsciiDoc, and then build the Parser for that grammar.

Once the document is parsed, it provides a pure ruby object Coradoc::Document, which can used to customize the document in easiest way.

Installation

Add this line to your application’s Gemfile:

gem "coradoc"

And then execute:

bundle install

Or install it yourself as:

gem install coradoc

Setup

Clone the repository.

git clone https://github.com/metanorma/coradoc.git

Setup your environment in docker

make setup

Run the test suite

make test

Usage from command line

Converting a document

$ coradoc help convert
$ coradoc convert file.html -o file.adoc

Usage from Ruby

Parsing a document

To parse any AsciiDoc, we can use the following:

Coradoc::Parser.parse(sample_asciidoc)

This interface will return the abstract syntax tree.

Converting a document

To convert any document of a supported format (right now: .html, .adoc, .docx) to any supported format (right now: .adoc), you can execute:

Coradoc::Converter.("input.html", "output.adoc")

The converters are chosen based on file extension, but you can select a converter manually like so:

Coradoc::Converter.("input", "output", input_processor: :html, output_processor: :adoc)

Some converters may support additional options, which can likewise be passed as keyword arguments:

Coradoc::Converter.(
  "input.html", "output.adoc",
  input_options: { external_images: true, split_sections: 2 }
)

It is also possible to pass IO objects instead of filenames. By default, if an argument is not provided, it defaults to STDIN/STDOUT. Note that not all combinations of formats and converter options are supported in this mode.

Legacy README for converting from HTML to AsciiDoc (formerly reverse_adoc)