Convert documents from AsciiDoc to Org

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 Org1, 2:

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

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 hello.org
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!
Alice
2021-08-06

Hello, World!

[source,ruby]
----
  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!
#+end_src

  1. https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00295.html:

    I have a large document (a book) written in AsciiDoc, and I’ve been thinking of converting it to org-mode, which I find eminently more readable. The method I’ve come up with is:

    1. AsciiDoc -> Docbook using asciidoc or asciidoctor
    2. Docbook -> org using pandoc
    ↩︎
  2. https://pandoc.org/MANUAL.html#using-pandoc:

    By default, pandoc produces a document fragment. To produce a standalone document (e.g. a valid HTML file including <head> and <body>), use the -s or --standalone flag:

    pandoc -s -o output.html input.txt
    
    ↩︎