Over a million developers have joined DZone.

Debugging rst2pdf and Pygments

DZone's Guide to

Debugging rst2pdf and Pygments

Want to learn how to debug rst2pdf and pygments? Check out this awesome tutorial with instructions and tips on debugging pygments and rst2pdf.

· Performance Zone ·
Free Resource

xMatters delivers integration-driven collaboration that relays data between systems, while engaging the right people to proactively resolve issues. Read the Monitoring in a Connected Enterprise whitepaper and learn about 3 tools for resolving incidents quickly.

I create my slide decks from ReStructuredText, which is a text markup format. Working this way makes it easy to add source control, it's fast to work with, and it's also accessible, since I don't use a mouse or other pointing device so traditional slide deck creation programs are kind of difficult. Text-based wins every time for me. While working on a new slide template, I ran into some difficulties and had to figure out how to inspect what was going on. I seem to struggle with this every time, so I am writing my troubleshooting guide here for when I need it next.

Debugging Rst

I generate slides with the rst2pdf command but for debugging purposes, try rst2pseudoxml instead. This shows me which styles are actually being used and therefore I can edit the stylesheet to amend the thing I'm looking at, rather than making changes at random! It's not XML at all but it's enough to see which styles are in play.

Sometimes the rst2html is also helpful as it also closes tags so you can see where something starts and finishes. Also pay attention to the program output as it usually spits out some really useful warnings (and the ones about fonts are right at the top and may scroll out of sight).

Debugging Pygments

Pygments styles each element of highlighted code with a specific style. So the function name is one style and the brackets another, the arguments a third, and so on. I don't use pygments enough to remember what all the styles are called and I always seem to struggle to herd all my code into looking good at one time! To figure out how to style a specific element, try this:

  1. Put the code into its own file
  2. Run pygments to get HTML output: pygmentize -o test.html test.php
  3. Look at the resulting output - the style names are in the CSS classes in the HTML, those are the styles you need to change in your rst2pdf stylesheet

Such minor points but they do make the tools easier to work with so here they are. I'll be able to find them next time and if they're useful to you too, then great! Feel free to add your own tips and tricks in the comments :)

Discovering, responding to, and resolving incidents is a complex endeavor. Read this narrative to learn how you can do it quickly and effectively by connecting AppDynamics, Moogsoft and xMatters to create a monitoring toolchain.

performance ,rst2pdf ,pygments

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}