How do you set tab width in HTML output of Sphinx code snippets highlighted by Pygments? By default it is the annoying 8, but I want 4. Did not find a word about this setting in Sphinx conf.py.
Add something like this to your conf.py:
import re
def process_docstring(app, what, name, obj, options, lines):
spaces_pat = re.compile(r"( {8})")
ll = []
for l in lines:
ll.append(spaces_pat.sub(" ",l))
lines[:] = ll
def setup(app):
app.connect('autodoc-process-docstring', process_docstring)
See also Sphinx Docstring preprocessing documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With