Literals with Spaces in Sphinx
[email protected] (Stefan Ram)
| Newsgroups | comp.lang.python |
|---|---|
| Organization | Stefan Ram |
| Message-ID | <[email protected]> |
In Sphinx reST, you can't put spaces at the beginning or end of certain literals and similar things. I think this is more to help catch or avoid mistakes than a real technical requirement. With three changes to the source code, you can apparently get around this restriction, but I have no idea if it always works or if it's safe, since I barely tested it and just messed around in the Sphinx code without knowing what I was doing. Here are the details: The following four literals are usually not allowed in Sphinx reST source because they start or end with a space: abc `` def`` ghi third change jkl ``mno `` pqr first change stu :literal:` vwx` yza third change bcd :literal:`efg ` hij second change But if you make these three changes to the Sphinx "docutils/parsers/rst/states.py" file, it works (no guarantees, try it at your own risk!): First change Original code literal=re.compile(self.non_whitespace_before + '(``)' + end_string_suffix), Changed code literal=re.compile( '(``)' + end_string_suffix), Second change Original code non_unescaped_whitespace_escape_before = r'(?<!(?<!\x00)[\s\x00])' Changed code non_unescaped_whitespace_escape_before = r'(?<!(?<!\x00)[\x00])' Third change Original code non_whitespace_after = r'(?!\s)' Changed code non_whitespace_after = r'()'