horizontal space/indent and HTML/PDF

Waylan Limberg waylan at gmail.com
Tue Oct 30 12:33:36 EDT 2012


On Tue, Oct 30, 2012 at 11:57 AM, Chris Lott <chris at chrislott.org> wrote:

> What is the best method to introduce horizontal space in text in a

> Pandoc document? Preferably something that would work for both HTML

> and PDF output?


Well, there are a few different things you could try:

The easiest would be to put the entire poem in a code block. Of
course, that may not be as pretty (with a monospaced font) and you
lose inline markdown (emphasis, links, etc).

http://johnmacfarlane.net/babelmark2/?normalize=1&text=++++hickory+dickory+dock%0A++++++++the+mouse+ran+up+the+clock%0A+++++++++++++the+clock+struck+one%0A++++the+mouse+ran+down

A second option would be to use html entities for non-braking spaces
(`&nbsp;`). You only need to make every other space non-breaking. And
don't forget to end each line with two spaces to force the line
breaks. Like this:

hickory dickory dock
&nbsp; &nbsp; &nbsp; the mouse ran up the clock
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the clock struck one
the mouse ran down

http://johnmacfarlane.net/babelmark2/?normalize=1&text=hickory+dickory+dock++%0A+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+the+mouse+ran+up+the+clock++%0A+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+%26nbsp%3B+the+clock+struck+one++%0Athe+mouse+ran+down

Of course, that doesn't look so nice in markdown, but works great in HTML.

The HTML spec actually suggests that poetry could be wrapped in a
`<pre>` tag (but without the inner `<code>` tags of the code block).
So, you could use raw html like this:

<pre>
hickory dickory dock
the mouse ran up the clock
the clock struck one
the mouse ran down
</pre>

http://johnmacfarlane.net/babelmark2/?normalize=1&text=%3Cpre%3E%0Ahickory+dickory+dock%0A++++the+mouse+ran+up+the+clock%0A+++++++++the+clock+struck+one%0Athe+mouse+ran+down%0A%3C%2Fpre%3E

I'm not sure if Pandoc will parse inline markdown in there or not
(some parers might if you set markdown=1 on the pre tag). And I'm not
sure how any of the above will translate to PDF. But that should get
you started.

--
----
\X/ /-\ `/ |_ /-\ |\|
Waylan Limberg


More information about the Markdown-Discuss mailing list