pypandoc provides a thin wrapper for pandoc, a universal document converter. Use it as follows:
import pypandoc
output = pypandoc.convert('somefile.md', 'rst')
# alternatively you could just pass some string to it and define its format
output = pypandoc.convert('#some title', 'rst', format='md')
The code infers pandoc --from
format automatically based on given file extension unless one is provided explicitly. extra_args
parameter makes it possible to access various pandoc options. Please refer to pandoc -h
and the official documentation for further details.
See also pyandoc.
- Valentin Haenel - String conversion fix
pypandoc is available under MIT license. See LICENSE for more details.