summaryrefslogtreecommitdiff
path: root/pygments/formatters
diff options
context:
space:
mode:
authorDavid Bold <dave@ipp.mpg.de>2021-11-26 13:50:02 +0100
committerDavid Bold <dave@ipp.mpg.de>2021-11-26 13:50:02 +0100
commitb5dc79a786c61a77b8e1fbceea3497bfe31ae3ee (patch)
treebf5e9ea3adaa8e5590c6f301adf08ed695b6bcae /pygments/formatters
parente025989fb0b6c35493bbe8dd7882a1fdf43de82e (diff)
downloadpygments-git-b5dc79a786c61a77b8e1fbceea3497bfe31ae3ee.tar.gz
Add links to lines with css-line numbers
Diffstat (limited to 'pygments/formatters')
-rw-r--r--pygments/formatters/html.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index 3029c1cc..f9588f78 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -765,7 +765,8 @@ class HtmlFormatter(Formatter):
for t, line in inner:
if t:
i += 1
- yield 1, '<a id="%s-%d" name="%s-%d"></a>' % (s, i, s, i) + line
+ 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