Convert documents from AsciiDoc to Org

By on

To convert an AsciiDoc document to an Org document, convert to Docbook as an intermediate step, then send the Docbook file to Pandoc to convert it to Org:

asciidoctor \
    --backend docbook \
    --out-file - \
    hello.adoc | \
    pandoc \
        --from docbook \
        --wrap=preserve \
        --standalone \

This command pipes two commands together to produce the desired result:

asciidoctor --backend docbook --out-file - hello.adoc
Take the hello.adoc file and convert it to Docbook. Pass - as the --out-file to return the output to standard output
pandoc --from-docbook --wrap=preserve --standalone --output
Take the input file and convert it from Dobook to Org. Preserve the line wrapping instead of wrapping each line to 80 characters, and create a “standalone” document including document headers, as opposed to a document “fragment”.

Given an AsciiDoc file:

= Hello, World!

Hello, World!

  puts "Hello, World!"

The command above produces an Org file including the document headers, contents, and code blocks:

#+title: Hello, World!

#+author: Alice
#+date: 2021-08-06

Hello, World!

#+begin_src ruby
    puts Hello, World!