blob: e4d7b92a6b717beec18aadb514879ffc28401562 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import os
from typing import cast, Callable
from pygments.formatters import HtmlFormatter
def get_style_defs() -> str:
# Workaround to avoid mypy to complain about untyped
# get_style_defs() call.
formatter = HtmlFormatter(style="bw")
selector = ".highlight"
f = cast(Callable[[str], str], formatter.get_style_defs)
return f(selector)
class Highlight(object):
@staticmethod
def generate(basedir: str) -> None:
highligh = os.path.join(basedir, "highlight.css")
with open(highligh, mode='w') as f:
style = get_style_defs()
f.write(style)
|