10

The original AsciiDoc processor was written in python, but AsciiDoc evolved in the form of Asciidoctor written in Ruby.

On my search for how to process modern AsciiDoc (the Asciidoctor dialect), I only came across a post that there is an older project to port AsciiDoc to Python 3 (https://github.com/asciidoc/asciidoc/issues/83).

But since the origins of AsciiDoc are in Python, it is hard to find anything useful via google.

So what is currently the best way to process AsciiDoc from within a Python program? Call the Ruby version or commandline processor?

rdmueller
  • 10,742
  • 10
  • 69
  • 126

1 Answers1

14

You may use Python3 to go on: you can find the brand-new Python3 port AsciiDoc3 at www.asciidoc3.org and on gitlab.com/asciidoc3/asciidoc3.

All 170 AsciiDoc testcases are passed!

hobs
  • 18,473
  • 10
  • 83
  • 106
Berthold Gehrke
  • 336
  • 2
  • 3
  • 1
    cool and interesting. I assume this is a port of the old python2 asciidoc and not the ruby based aaciidoctor? – rdmueller Apr 18 '18 at 03:58
  • 3
    Yes, AsciiDoc3 is the port of 'the old python2' asciidoc to 100% pure Python3 - and has nothing to do with asciidoctor ... – Berthold Gehrke Apr 18 '18 at 16:31
  • How does it work? Website does not contain anything meaningful about actualy using this stuff from Python (not via running executable) – The Godfather Jul 04 '19 at 12:36
  • To use asciidoc3 or a2x3 through another (python) program just type something like this (or something similar - import module subprocess): `... p = subprocess.Popen(asciidoc3, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True, bufsize=-1) output = p.communicate(...) ...` – Berthold Gehrke Jul 22 '19 at 16:17
  • 1
    @TheGodfather Just stumbled on this. Asciidoc-py3 provides an API module: https://github.com/asciidoc/asciidoc-py3/blob/master/asciidocapi.py. Supposedly this should also be there in asciidoc3, but I didn't see it in the repo. – haraldkl Nov 19 '19 at 11:36
  • asciidoctor is not asciidoc. You can write stuff in asciidoctor that asciidoc will not understand. – Acebone Nov 17 '20 at 19:12
  • Here's [a definitive reference on the differences](https://docs.asciidoctor.org/asciidoctor/latest/migrate/asciidoc-py/#updated-and-deprecated-asciidoc-syntax) between the "old" (Python2/Asciidoc.py) and "new" (Ruby/Asciidoctor) syntaxes. "If a feature or attribute isn’t mentioned in the following tables, then it works in Asciidoctor just like it worked in AsciiDoc.py." – Nathaniel Jones Jun 29 '23 at 17:07