The Living Thing / Notebooks :


On the esoteric difficulties of bullet points

See also text editors, LaTeX , citation management, scientific computation workflow, plain text blogging, academic writing workflow

pandoc tricks

Modify a template to include a custom preamble, e.g. for latex formatting. Here’s how you change that globally.

$ pandoc -D latex \> \~/.pandoc/templates/default.latex

But if you only want some basic macros, simply prepend a header file

$ pandoc -H \_macros.tex chapter\ -o chapter\_splitting.pdf

There are many other pandoc template tricks , inlcuding, e.g. phd thesis templates.

Pandoc will expand basic LaTeX Macros in even HTML.

reStructuredText tricks

Pandoc’s reStructuredText reader is not great for converting to markdown. One option is to go via HTML, e.g.

$ \--math-output=MathJax document.rst \| pandoc -f html -t
$ markdown -

This will mangle your mathematical equations.

Or, this will mangle your links and headings:

> pandoc -f rst -t markdown document.rst

There are also reST-specific converters which might circumvent this.

A python option leveraging the reST infrastructure is rst_to_md:

This writer lets you convert reStructuredText documents to Markdown with Docutils. The package includes a writer and translator along with a command-line tool for doing conversions.

This was originally developed to support Sixty North’s publication efforts, so it may have behaviors that are specific to those needs. However, it should be generally useful for rst-to-md conversion.

It is missing some needful things, e.g. math markup support. Nonetheless, this is the right way to do it.

To demonstrate that, I added math support in my own fork. It took 15 minutes.

> pip install git+https:///
> rst-to-md module_1.rst >

Or you could do it the way that involves unnecessarily reimplementing something in javascript. rst2mdown is restructuredtext for node.js.