Skip to content

Instantly share code, notes, and snippets.

@mojavelinux
Created June 7, 2013 21:24
Show Gist options
  • Save mojavelinux/5732518 to your computer and use it in GitHub Desktop.
Save mojavelinux/5732518 to your computer and use it in GitHub Desktop.
Steps to convert WordPress post to AsciiDoc
  1. Pull out content from <content> tag in exported XML file

  2. Replace blank lines w/ </p><p>, add <p> as first line and </p> as last line

  3. Put that content into the body of a basic HTML document structure (so it looks like an HTML file)

  4. convert using

    pandoc --no-wrap -f html -t asciidoc post-content.html > post-content.adoc
  5. use sed to cleanup

    sed -i s/^image:/image::/ post-content.adoc
    sed -i s/^----.*/----/ post-content.adoc
  6. Add document title, author and date (manual, atm)

    = Post title
    Jason Brooks
    2012-08-31
  7. run through Asciidoctor

    asciidoctor -a linkcss! post-content.adoc
  8. profit

@hascode
Copy link

hascode commented May 2, 2021

Thanks for sharing! In newer versions of pandoc, --no-wrap is replaced by --wrap=none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment