Skip to content

Commit

Permalink
Patch for invalid pygments links (pygments/pygments#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed Dec 31, 2021
1 parent ed7da6e commit 8444457
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nikola/packages/pygments_better_html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,17 @@ def format_unencoded(self, tokensource, outfile):

for t, piece in source:
outfile.write(piece)

# FIXME patch for broken code in pygments 2.11.0/2.11.1 - remove when
# Pygments PR #2014 merged
def _wrap_lineanchors(self, inner):
s = self.lineanchors
# subtract 1 since we have to increment i *before* yielding
i = self.linenostart - 1
for t, line in inner:
if t:
i += 1
href = "" if self.linenos else ' href="#%s-%d"' % (s, i)
yield 1, '<a id="%s-%d" name="%s-%d"%s></a>' % (s, i, s, i, href) + line
else:
yield 0, line

0 comments on commit 8444457

Please sign in to comment.