diff --git a/pelican/rstdirectives.py b/pelican/rstdirectives.py index b4f44aa1..4fae9e6f 100644 --- a/pelican/rstdirectives.py +++ b/pelican/rstdirectives.py @@ -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 '' in self.options['linespans']: + self.options['linespans'] = str(self.options['linespans']).replace( + '', 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)