26 August 2013

Tips: standalone HTML file with pandoc


If like me you want to avoid as much as possible using MS Word, you've probably heard about Pandoc. This tool allows to convert from various text formats (text, rst, Markdown...) to HTML, epub or pdf for instance.

One common option is to generate a HTML file with a css, to have a better rendering.

pandoc -s -S -c pandoc.css myfile.rst -o output.html

OK but then let's say you want to send the file output.html to someone by mail, how do you do? You would need to send the html and the css file, and that would be weird for fast and/or internal communication for instance.

Well there is an option to include the css automatically in the generated html: the -H option.

pandoc -s -S -H pandoc.css myfile.rst -o output.html

 Just make sure your css file starts and ends with the <style> tag:

<style type="text/css">
 ...
</style>

Source

0 comments:

Post a Comment