Skip to content

[Bug]: Tilde (~) is converted to non-breaking whitespace #1314

Description

@wouterj

Summary

Not really a 100% bug, but something a bit unexpected as far as I can see.

The ~ character is converted to NBSP by the InlineLexer:

This behavior was present in the Doctrine RST Parser as well, but I cannot find any reference to this in the Sphinx documentation or reStructured Text specification. A test using Sphinx also confirms that it renders the ~ as tilde character.

I can't find a good way to disable this behavior, given the InlineLexer is final and not defined as a service. Overriding the template is also not safe, as WhitespaceInlineNode can also be created using the new :nbsp: text role.

Escaping the character in the documentation (\~) works fine, but I'm just wondering if this deviation from Sphinx/reStructured Text was intentional :)

Code snippet that reproduces the problem

Duration: ~1,000ms

Duration: \~1,000ms

Expected output

<p>Duration: ~1,000ms</p>
<p>Duration: ~1,000ms</p>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions