Literals with Spaces in Sphinx

Liste des GroupesRevenir à cl python 
Sujet : Literals with Spaces in Sphinx
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 09. May 2025, 18:23:01
Autres entêtes
Organisation : Stefan Ram
Message-ID : <Sphinx-20250509180701@ram.dialup.fu-berlin.de>
  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'()'



Date Sujet#  Auteur
9 May 25 * Literals with Spaces in Sphinx2Stefan Ram
9 May 25 `- Re: Literals with Spaces in Sphinx1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal