mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
make html's IDs unique on using multiple code-blocks with 'linespans' option activate
This commit is contained in:
parent
3c514266dd
commit
f3bf3c7699
1 changed files with 12 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue