pngmath generates invalid html - fix proposed

Anonymous avatarAnonymous created an issue

When pngmath inserts an image into an html page, it closes tags out of order like this: <div><p>...</div></p> You can verify the bug by submitting the resulting html file to http://validator.w3.org/check . The fix is easy. I am uploading a patch and a test case.

I am using sphinx 0.5.2

Comments (3)

  1. Anonymous

    .. Here is a testcase. Compile this from a default sphinx configuration (including pngmath) and upload it to the W3C validator to see the error

    .. pngmath-test documentation master file, created by sphinx-quickstart on Fri Aug 28 17:30:16 2009. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive.

    Welcome to pngmath-test's documentation!

    Contents:

    .. toctree:: :maxdepth: 2

    Test

    This is valid math

    .. math::

    f(x) = x^2

    This is invalid math

    .. math::

    f(x) = }

    Indices and tables

    • :ref:`genindex`
    • :ref:`modindex`
    • :ref:`search`
  2. Anonymous

    Here is the patch to apply to pngmath.py

    --- pngmath.py 2009-08-28 17:32:46.000000000 -0600 +++ /usr/share/python-support/python-sphinx/sphinx/ext/pngmath.py 2009-08-28 17:33:07.000000000 -0600 @@ -226,9 +226,10 @@ self.body.append('<span class="math">%s</span>' % self.encode(node['latex']).strip()) else: - self.body.append('<img src="%s" alt="%s" />\n</div>' % + self.body.append('<img src="%s" alt="%s" />\n' % (fname, self.encode(node['latex']).strip())) self.body.append('</p>') + self.body.append('</div>') raise nodes.SkipNode

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.