Add optional css_selector arg to get_stylesheet

This commit is contained in:
Septatrix 2020-03-08 13:46:24 +01:00
parent a4d4401fc4
commit 3f9be211ee

View File

@ -10,7 +10,7 @@
from functools import partial
from importlib import import_module
from typing import Any, Dict
from typing import Any, Dict, Union, Iterable
from pygments import highlight
from pygments.filters import ErrorToken
@ -157,9 +157,9 @@ class PygmentsBridge:
# MEMO: this is done to escape Unicode chars with non-Unicode engines
return texescape.hlescape(hlsource, self.latex_engine)
def get_stylesheet(self) -> str:
def get_stylesheet(self, *, css_selector: Union[str, Iterable[str]] = '.highlight') -> str:
formatter = self.get_formatter()
if self.dest == 'html':
return formatter.get_style_defs('.highlight')
return formatter.get_style_defs(css_selector)
else:
return formatter.get_style_defs() + _LATEX_ADD_STYLES