moved pygments, static and templates to the pelican/themes/Flex subdir

This commit is contained in:
Tobias Schmidl 2024-11-07 16:51:46 +01:00
parent a17ebec50f
commit 7a465d81e3
155 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# Pygments CSS generator
This is the correct way to generate all pygments CSS files.
## How to generate CSSs files
Before run `generate.py` remember to install all requirements.
This can done with `pip install -r requirements.txt`.
After this you can run `./generate.py`. Remember to run inside this folder.
Because it uses relative path to place inside `static/pygments` folder.
After that, go back to the Flex path and run `gulp pygments` to generate all `min.css` files.
## How to add new styles?
[See wiki](https://github.com/alexandrevicenzi/Flex/wiki/Code-Highlight#how-to-add-new-styles).

View file

@ -0,0 +1,38 @@
#!/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,
'noclasses': False,
'nobackground': False,
}
path = os.path.join(PYGMENTS_PATH, '%s.css' % style)
formatter = HtmlFormatter(**opts)
md_css = formatter.get_style_defs('.highlight')
rst_css = formatter.get_style_defs('.literal-block')
with open(path, 'w+') as f:
f.write(md_css)
f.write('\n')
f.write(rst_css)
if __name__ == '__main__':
export()

View file

@ -0,0 +1,2 @@
Pygments
pygments-style-github