Using CSS when converting Markdown to PDF with Pandoc
I don't know LaTeX at all, but have hacked this solution using this helpful manual. First, create a style:
\definecolor{silver}{RGB}{230,230,230}
\newcommand{\inlinecodeblock}[1]{
\colorbox{silver}{
\texttt{#1}
}
}
And here's how to use it:
Some \inlinecodeblock{inline code}, and some widgets, go here
This creates a style with a background colour and a monospaced font. The margin and padding are a bit large for my preferences, but it's a very useable start. Here's what it looks like:
The disadvantage is that if I wish to output to a format that supports styles proper (such as HTML) then these are lost. Also, my solution only works with LaTeX/PDF. Thus, if you can fix these issues, please add a better answer!
Addendum: I have a better approach, which is thus:
\newcommand{\inlinecodeblock}[1]{
\fboxsep 1pt
\fboxrule 0pt
\colorbox{silver}{\strut{\texttt{#1}}}
}
This avoids the problem of excess horizontal padding - I think it was the line break in the colorbox
parameter that did it. I've added in strut
, which keeps highlights the same height regardless of whether the text has descenders.
It's not perfect though - there's still too much horizontal margin outside the box, and a comma after a box will still orphan onto the next line. I may give up with LaTeX, and render to HTML from Pandoc, and then use wkhtmltopdf
to render the final document.
Convert Markdown + CSS to .doc or .pdf
You can also generate HTML from Markdown and convert it to .pdf or .xls format using DocRaptor. DocRaptor also handles CSS better than competitors do.
Here's a link to DocRaptor
Related Topics
Concatenate Values in Less (Css) Without a Space
Why Do I Have to Put Media Queries at the Bottom of the Stylesheet
Text Blurry After 3D Transform
Redundant CSS Rules Ie Float & Display:Block
Google Webfont Conflict with Local Font
How to Recreate Perspective-Origin Effect by Transforming Child Elements
Css3 Animation and Background-Image in Firefox
How to Use CSS to Replace or Change Text
CSS Media Type: How to Load CSS for Mobile
How to Use Media Queries in CSS
CSS { Content: "Text"}, How to Add Tags
Use CSS Variables with Rgba for Gradient Transparency
How to Display a List in Two Rows
Font-Awesome Not Properly Displaying on Firefox/How to Vend via Cdn