mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge 951b184017 into cfcf40f1f8
This commit is contained in:
commit
673ff615ca
1 changed files with 15 additions and 0 deletions
|
|
@ -15,6 +15,16 @@ import six
|
|||
import pelican.settings as pys
|
||||
|
||||
|
||||
def integers():
|
||||
"""Infinite sequence of integers."""
|
||||
i = 1
|
||||
while True:
|
||||
yield str(i)
|
||||
i = i + 1
|
||||
|
||||
code_block_id = integers()
|
||||
|
||||
|
||||
class Pygments(Directive):
|
||||
""" Source code syntax highlighting.
|
||||
"""
|
||||
|
|
@ -65,6 +75,11 @@ class Pygments(Directive):
|
|||
if flag in self.options:
|
||||
self.options[flag] = True
|
||||
|
||||
if '<id>' in self.options['linespans']:
|
||||
self.options['linespans'] = str(self.options['linespans']).replace(
|
||||
'<id>', next(code_block_id)
|
||||
)
|
||||
|
||||
# noclasses should already default to False, but just in case...
|
||||
formatter = HtmlFormatter(noclasses=False, **self.options)
|
||||
parsed = highlight('\n'.join(self.content), lexer, formatter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue