# 5.4 XHTML Renderer

The XHTML renderer is a subclass of the ZPT renderer (section 5.3). Since the ZPT renderer can render any variant of XML or HTML, the XHTML renderer has very little to do in the Python code. Almost all of the additionaly processing in the XHTML renderer has to do with generated images. Since HTML cannot render LaTeX’s vector graphics or equations natively, they are converted to images. In order for inline equations to line up correctly with the text around them, CSS attributes are used to adjust the vertical alignment. Since the images aren’t generated until after all of the document has been rendered, this CSS information is added in post-processing (i.e. the `cleanup` method).

In addition to the processing of images, all characters with a ordinal greater than 127 are converted into numerical entities. This should prevent any rendering problems due to unknown encodings.

Most of the work in this renderer was in creating the templates for every LaTeX construct. Since this renderer was intended to be the basis of all HTML-based renderers, it must be capable of rendering all LaTeX constructs; therefore, there are ZPT templates for every LaTeX command, and the commands in some common LaTeX packages.

While the XHTML renderer is fairly complete when it comes to standard LaTeX, there are many packages which are not currently supported. To add support for these packages, templates (and possibly Python based macros; section 4) must be created.

- 5.4.1 Themes