ullenboom / asciidoctor-open-document

Open Document backend for Asciidoctor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

badge

Open Document backend for Asciidoctor

About

Open Document backend for Asciidoctor allows to convert asciidoc documentation into fodt (plain Open Document) format. It relies on Asciidoctor project.

Fodt file may be converted with LibreOffice SDK or CLI into pdf, odt, docx, doc etc.

Examples (built automatically as a part of CI routine):

The asciidoctor-open-document backend can be extended in the following ways:

  • custom fodt template. Allows to customize paragraph properties, text properties, page properties (orientation, header, footer and like), list properties, table properties. Custom fodt template can contain title page or any before/after content;

  • custom slim templates;

  • custom xml-content preprocessor;

  • custom Open Document style setters.

Usage

With docker

With a-od simplified utility

Assuming you need to convert test.adoc from the current directory to odt format.

docker run --rm -v $(pwd):/documents/ curs/asciidoctor-od a-od test.adoc odt

General syntax of a-od is:

a-od [file] [output format] [custom fodt temlate] [custom conversion library]

Or step by step without a-od

  • Convert adoc to preliminary Open Document content file

    The following steps assume that asciidoc file test.adoc is in the /my-adoc directory. As a result we want to get test.fodt and test.pdf.

    docker run --rm -v $(pwd):/documents/ curs/asciidoctor-od a-od-pre -r asciidoctor-mathematical -r asciidoctor-diagram test.adoc -o pre.xml

    Here asciidoctor-mathematical and asciidoctor-diagram extensions are used.

  • Convert preliminary Open Document content file to fodt

    docker run --rm -v $(pwd):/documents/ curs/asciidoctor-od a-od-out -c /usr/local/a-od/a-od-my/my-cp-example.rb -i pre.xml -o test.fodt

    Here the custom library is used. It contains examples of custom features: positioning equation number, paragraph alignment role, code highlighting, positioning admonitions inside of the list element.

  • Convert fodt to pdf, odt, docx etc.

    docker run --rm -v $(pwd):/documents/ curs/asciidoctor-od unoconv -f pdf test.fodt

    + Instead of pdf any format supported by Libre Office is possible.

As a ruby script

Conversion consists of 2 steps.

  1. Convert adoc to preliminary content file

  2. Convert preliminary content file to fodt

Convert adoc to preliminary content file

Conversion to preliminary content file is done by the standard asciidoctor command with a slim template (slim folder of a source code).

asciidoctor -T [path to slim] -b fodt asciidoc_file.adoc

There is a wrapper a-od-pre in docker image. Use it like a normal asciidoctor command. It just sets slim template and backend.

Convert preliminary content file to fodt

Conversion to final fodt file is done with the asciidoctor-od.rb script.

ruby [path to script]/a-od-producer.rb -i [prelimenary content file] -o [final file] -c [custom process library] -f [fodt template]

There is a wrapper a-od-out in docker image. It just runs ruby with a-od-producer.rb.

About

Open Document backend for Asciidoctor

License:MIT License


Languages

Language:Ruby 74.0%Language:Slim 19.0%Language:Shell 5.1%Language:Dockerfile 1.8%