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 \ --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
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:
- AsciiDoc -> Docbook using asciidoc or asciidoctor
- Docbook -> org using pandoc
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