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>
Summary
Not really a 100% bug, but something a bit unexpected as far as I can see.
The
~character is converted to NBSP by theInlineLexer:guides/packages/guides-restructured-text/src/RestructuredText/Parser/InlineLexer.php
Line 134 in 6a008ff
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
InlineLexeris final and not defined as a service. Overriding the template is also not safe, asWhitespaceInlineNodecan 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,000msExpected output