make html's IDs unique on using multiple code-blocks with 'linespans' option activate

This commit is contained in:
Ferry Jérémie 2015-01-18 14:10:54 +01:00
commit f3bf3c7699

View file

@ -11,6 +11,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.
"""
@ -61,6 +71,8 @@ class Pygments(Directive):
if flag in self.options:
self.options[flag] = True
self.options['linespans'] += 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)