Skip to content

Mathbase.py: math with labels with whitespace cause html error #4438

@Blendify

Description

@Blendify

Subject: When math elements have labels with spaces html validators are unhappy

Problem

Issue happens here: https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/mathbase.py#L89 but also other areas in that file where id is set,

Procedure to reproduce the problem

.. math::
    :label: This is a label

    \nabla^2 f =
    \frac{1}{r^2} \frac{\partial}{\partial r}
    \left( r^2 \frac{\partial f}{\partial r} \right)

Error logs / results

Error: Bad value equation-This is a label for attribute id on element div: An ID must not contain whitespace.

From line 299, column 1; to line 299, column 48

`ther:</p>↩<div class="math" id="equation-This is a label">↩<span`

Expected results

It should convert whitespace from the label to use dashes.

Reproducible project / your project

https://sphinx-rtd-theme.readthedocs.io/en/latest/demo/demo.html#math

Environment info

  • OS: All
  • Python version: 3.6
  • Sphinx version: 1.6.x

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions