Pandoc: a universal document converter, ePub creator, etc

Pandoc is called "a universal document converter". It "can read markdown and (subsets of) reStructuredText, textile, HTML, and LaTeX" and it "can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, textile, groff man pages, Emacs org-mode, EPUB ebooks, and S5 and Slidy HTML slide shows". This makes it feasible as a universal document restructurer that could feasibly serve as a key segment in publishing electronic books.

It "understands a number of useful markdown syntax extensions, including document metadata (title, author, date); footnotes; tables; definition lists; superscript and subscript; strikeout; enhanced ordered lists (start number and numbering style are significant); delimited code blocks; markdown inside HTML blocks; and TeX math".

Pandoc is in the MacPorts, Debian, Ubuntu, Slackware, Arch, Fedora, NetBSD, and FreeBSD ports repositories.