I use Sphinx to make a website that contains code samples.
I\'m successful using the .. code-block
directive to get syntax highlighting.
But I can\'t get inline syn
Found a better (sphinx-only) solution: in sphinx/builders/html.py
find a line
from docutils.core import Publisher
and change it to:
from docutils.core import Publisher
def process_programmatic_settings(self, settings_spec,
settings_overrides,
config_section):
if self.settings is None:
defaults = (settings_overrides or {}).copy()
# Propagate exceptions by default when used programmatically:
defaults.setdefault('traceback', True)
defaults.setdefault('syntax_highlight', 'short') # ADDED THIS LINE
self.get_settings(settings_spec=settings_spec,
config_section=config_section,
**defaults)
Publisher.process_programmatic_settings = process_programmatic_settings
This solution is better then previous ones: since it doesn't double the amount of css rules, and doesn't modify docutils.
Still, ideal solution would only change conf.py
. So there's a plenty space for improvement.