How to convert HTML to AsciiDoc with Pandoc

If you ever need to convert HTML to AsciiDoc, I just used this Pandoc command and it seems to work well:

pandoc --wrap=none -f html -t asciidoc myfile.html > myfile.adoc

The wrapping part of that command isn’t 100% necessary, but if you don’t use it, Pandoc will wrap the plain paragraph text, which I don’t like because I’ll be editing the resulting AsciiDoc text.

Here’s some of the AsciiDoc text that this command generated:

[[problem]]
Problem
~~~~~~~

The Scala Build Tool (SBT) doesn’t include a command to create a new http://scala-lang.org/[Scala] project, and you’d like to quickly and easily create the directory structure for a new project.

[[solution]]
Solution
~~~~~~~~

Use either a shell script or a tool like Giter8 to create your project’s directory structure. Both approaches are shown here.

[[use-a-shell-script]]
Use a shell script
^^^^^^^^^^^^^^^^^^

There may be a way to control what sort of AsciiDoc tags are emitted — such as using == instead of ~~~ — but I haven’t looked into that yet.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.