@@ -100,20 +100,16 @@ def __init__(self, pygments_style):
100
100
super ().__init__ ()
101
101
self .pygments_style = pygments_style
102
102
self .title = None # will be set by header()
103
- self ._headercounts = {}
104
103
105
104
def _get_header_link (self , title ):
106
105
"""Return a github-style link target for a title.
107
106
108
- >>> r = TutorialRenderer()
109
- >>> r._get_header_link('Hello there!')
107
+ >>> TutorialRenderer()._get_header_link('Hello there!')
110
108
'hello-there'
111
- >>> r._get_header_link('Hello there!')
112
- 'hello-there-1'
113
- >>> r._get_header_link('Hello there!')
114
- 'hello-there-2'
115
- >>>
116
109
"""
110
+ # This doesn't handle multiple titles with the same text in the
111
+ # same file, but usually that's not a problem. GitHub makes
112
+ # links like the-title, the-title-1, the-title-2 etc.
117
113
result = ''
118
114
for character in title :
119
115
if character in string .whitespace :
@@ -122,16 +118,7 @@ def _get_header_link(self, title):
122
118
pass
123
119
else :
124
120
result += character .lower ()
125
-
126
- if result not in self ._headercounts :
127
- # this title appears in this file for the first time
128
- self ._headercounts [result ] = 1
129
- return result
130
- # there has been already a link with the same text on this page,
131
- # we need to do thetitle, thetitle-1, thetitle-2, etc.
132
- real_result = '%s-%d' % (result , self ._headercounts [result ])
133
- self ._headercounts [result ] += 1
134
- return real_result
121
+ return result
135
122
136
123
def header (self , text , level , raw ):
137
124
"""Create a header that is also a link and a # link target."""
0 commit comments