2016-04-24 00:44:16 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from pygments.styles import get_all_styles
|
|
|
|
from pygments.formatters.html import HtmlFormatter
|
|
|
|
|
|
|
|
PYGMENTS_PATH = './../static/pygments'
|
|
|
|
|
|
|
|
|
|
|
|
def export():
|
|
|
|
if not os.path.exists(PYGMENTS_PATH):
|
|
|
|
os.makedirs(PYGMENTS_PATH)
|
|
|
|
|
|
|
|
styles = list(get_all_styles())
|
|
|
|
|
|
|
|
for style in styles:
|
|
|
|
print('Generating CSS for %s' % style)
|
|
|
|
|
|
|
|
opts = {
|
|
|
|
'style': style,
|
2018-06-24 05:01:22 +02:00
|
|
|
'noclasses': False,
|
|
|
|
'nobackground': False,
|
2016-04-24 00:44:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
path = os.path.join(PYGMENTS_PATH, '%s.css' % style)
|
|
|
|
formatter = HtmlFormatter(**opts)
|
2018-06-24 05:01:22 +02:00
|
|
|
css_content = formatter.get_style_defs('.highlight')
|
2016-04-24 00:44:16 +02:00
|
|
|
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
f.write(css_content)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
export()
|