Skip to content

Commit

Permalink
Merge branch 'Kwpolska-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anteru committed Jan 3, 2022
2 parents 0983703 + be4ae6d commit 4c21628
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Version 2.11.2

* Java: Fixed an issue with ``record`` keywords result in ``Error`` tokens in some cases (#2018)

- Fix links to line numbers not working correctly (#2014)

Version 2.11.1
--------------
(released December 31st, 2021)
Expand Down
2 changes: 1 addition & 1 deletion pygments/formatters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def _wrap_lineanchors(self, inner):
for t, line in inner:
if t:
i += 1
href = "" if self.linenos else ' href="%s-%d"' % (s, i)
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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_html_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_lineanchors():
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
assert re.search("<pre>\\s*<span>\\s*</span>\\s*<a id=\"foo-1\" name=\"foo-1\" href=\"foo-1\">", html)
assert re.search("<pre>\\s*<span>\\s*</span>\\s*<a id=\"foo-1\" name=\"foo-1\" href=\"#foo-1\">", html)


def test_lineanchors_with_startnum():
Expand All @@ -108,7 +108,7 @@ def test_lineanchors_with_startnum():
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
assert re.search("<pre>\\s*<span>\\s*</span>\\s*<a id=\"foo-5\" name=\"foo-5\" href=\"foo-5\">", html)
assert re.search("<pre>\\s*<span>\\s*</span>\\s*<a id=\"foo-5\" name=\"foo-5\" href=\"#foo-5\">", html)


def test_valid_output():
Expand Down

0 comments on commit 4c21628

Please sign in to comment.