blob: 40a8f81c82f894cab3feba7a2b227e46a74139b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import sys
import io
from typing import Optional
from pygments.formatters import HtmlFormatter
def configure_io():
sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
def write_style(formatter: HtmlFormatter, opt_style: Optional[str] = None):
sys.stdout.write('<style>')
if opt_style:
sys.stdout.write(opt_style)
sys.stdout.write(formatter.get_style_defs('.highlight'))
sys.stdout.write('</style>')
|