ousia / from-pandoc-to-context

Environment to parse XHTML from pandoc with ConTeXt
http://www.from-pandoc-to-context.tk
GNU General Public License v2.0
13 stars 3 forks source link

centered paragraphs #19

Closed juh2 closed 8 years ago

juh2 commented 8 years ago

I don't know how to get centered paragraphs with pandoc and context. Any hints?

ousia commented 8 years ago

The solution would be better if attributes were enabled in Markdown for paragraphs. But anyway, your source code may read

<div class="centered">
Your centered paragraph comes here.

One or many ones
</div>

You should add to your CSS file (file specified in stylesheet in YAML metadata):

div#centered {
    text-align: center;
}

And you should add to your pandoc-xhtml.tex source (I want to update mine, but I messed my local git repo :cold_sweat:):

\xmlsetsetup{\xmldocument}
    {div[@class='centered']}
    {xml:centeredblock}

\startxmlsetups xml:centeredblock
    \startalign[center]\xmlflush{#1}\stopalign
\stopxmlsetups
juh2 commented 8 years ago

Thanks a lot.

In my case the CSS has to be

div.centered p {
    text-align: center;
}

I hope you can save your repo.

ousia commented 8 years ago

@juh2, you’re right, it was a newbie mistake.

My selector was for a unique identifier and the code requires a class.

Although this should work too:

div.centered {
    text-align: center;
}

That centers the whole block (the division), no matter which elements it contains.

[As not done previously, I have tested the above CSS code myself.]