This commit is contained in:
Deleted user 2017-04-16 09:04:28 +00:00 committed by GitHub
commit 673ff615ca

View file

@ -15,6 +15,16 @@ import six
import pelican.settings as pys 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): class Pygments(Directive):
""" Source code syntax highlighting. """ Source code syntax highlighting.
""" """
@ -65,6 +75,11 @@ class Pygments(Directive):
if flag in self.options: if flag in self.options:
self.options[flag] = True 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... # noclasses should already default to False, but just in case...
formatter = HtmlFormatter(noclasses=False, **self.options) formatter = HtmlFormatter(noclasses=False, **self.options)
parsed = highlight('\n'.join(self.content), lexer, formatter) parsed = highlight('\n'.join(self.content), lexer, formatter)