title: Using CSS when converting Markdown to PDF with Pandoc
body: <p>I'm trying out Pandoc on OS X, and results thus far are impressive. One blocking problem, however, is getting CSS styles to work on inline code samples. I'm converting from Markdown to PDF.</p>
  <p>I have this string in my source:</p>
  <pre><code>* Create a simple HTML document (&lt;span class=&quot;filename&quot;&gt;simple.html&lt;/span&gt;) and load it into the browser via the file system
  </code></pre>
  <p>I've also tried this:</p>
  <pre><code>* Create a simple HTML document (`simple.html`{.filename}) and load it into the browser via the file system
  </code></pre>
  <p>I'd like to apply the class &quot;filename&quot; to the enclosed text in each case, but it doesn't seem to do anything to the output. However the manual says:</p>
  <blockquote>
  <p>Some output formats can use this information to do syntax highlighting. Currently, the only output formats that uses this information are HTML and LaTeX.</p>
  </blockquote>
  <p>Here's my command:</p>
  <pre><code>pandoc \
      --output ./output.pdf \
      --css source/styles.css \
      source/en/docs/input.md
  </code></pre>
  <p>I'm converting to PDF, which is written by LaTeX by Pandoc internally. Can I get this to work? Or, can I use a style defined using a LaTeX command? - it doesn't have to be CSS. However, it must be a style system - it's not workable to change italic/font/colour attributes on each occasion.</p>
  <p>I've tried sending output temporarily to HTML, and in that situation the styles are imported directly from the specific style asset. So, my stylesheet specification and span markup is correct, at least for one output format.</p>
  <h2>Addenda</h2>
  <p>A couple of afterthoughts:</p>
  <ul>
  <li>The solution does not have to be Pandoc or Markdown. However, it does need to be a trivial text-based markup language that can convert reliably to PDF, as I want to store the document files on Git for easy forking and merging. I'm not keen on HTML as it is verbose, and engines to convert it aren't that great (though, admittedly, my formatting requirements are modest).</li>
  <li>The HTML output from Pandoc is fine, so if I can find something that converts the (simple) HTML/CSS to PDF reliably, I'll be fine. Of course, Pandoc should be able to do this, but inline styles (for the background colour on code fragments) aren't rendered. This might be a faff, as I'll have to reintroduce things like page-breaks, which can be non-trivial in HTML-to-PDF converters.</li>
  </ul>