Reputation: 193
What I have to do to make it work that simple as in this example from official documentation?
:::python
print("The triple-colon syntax will *not* show line numbers.")
#!python
print("The path-less shebang syntax *will* show line numbers.")
What should I add to the pelicanconf.py? This is my requirements.txt:
blinker==1.4
colorama==0.4.4
commonmark==0.9.1
docutils==0.18
feedgenerator==2.0.0
Jinja2==3.0.2
Markdown==3.3.4
MarkupSafe==2.0.1
pelican==4.7.1
pelican-related-posts==1.0.0
pelican-series==2.1.0
Pygments==2.10.0
python-dateutil==2.8.2
pytz==2021.3
rich==10.12.0
six==1.16.0
Unidecode==1.3.2
I am using virtual environment, maybe that helps.
Upvotes: 1
Views: 299
Reputation:
To activate syntax highlighting in Pelican, some very simple steps are required. The documentation was not really helpful and it seems that quite some people get confused.
First, activate the codehilite
extension in markdown
pelicanconf.py
MARKDOWN = {
'extension_configs': {
'markdown.extensions.codehilite': {
'css_class': 'codehilite',
},
}
Ensure that the pygmentize
command is available. Else install pygmentize
via pip. In most cases, it gets installed as a dependency of Pelican.
List all available highlight-styles
pygmentize -L style
and then generate a stylesheet with the style of your choice. The example below uses the zenburn
style. The important part is, that the the value of the -a
argument must match the css_class
value from the pelicanconf.py
, but prepended by a .
.
pygmentize -S zenburn -f html -a .codehilite > themes/simple/static/css/styles.css
Then link the resulting style sheet in your base.html
.
<link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/css/styles.css" />
Upvotes: 1
Reputation: 85
You do not need to activate Pygments. This blog post has some information on Pygments and CodeHilite and how they work.
https://georgexyz.com/code-highlight-in-pelican.html
Upvotes: 1
Reputation: 193
Actually there is nothing to "activate", because everything is working "out of the box". I've been just confused by codehilite documentation since it points out that you need somehow "download and install the Pygments package on your PYTHONPATH". With download part there is all clear as Pygments was installed alongside Pelican, but I was having troubles with "install the Pygments package on your PYTHONPATH" due to my lack of knowledge of how PIP works inside of virtual environment. Please vote to delete this question if you find it useless.
Upvotes: 0