@@ -100,20 +100,16 @@ def __init__(self, pygments_style):
100100 super ().__init__ ()
101101 self .pygments_style = pygments_style
102102 self .title = None # will be set by header()
103- self ._headercounts = {}
104103
105104 def _get_header_link (self , title ):
106105 """Return a github-style link target for a title.
107106
108- >>> r = TutorialRenderer()
109- >>> r._get_header_link('Hello there!')
107+ >>> TutorialRenderer()._get_header_link('Hello there!')
110108 '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- >>>
116109 """
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.
117113 result = ''
118114 for character in title :
119115 if character in string .whitespace :
@@ -122,16 +118,7 @@ def _get_header_link(self, title):
122118 pass
123119 else :
124120 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
135122
136123 def header (self , text , level , raw ):
137124 """Create a header that is also a link and a # link target."""
0 commit comments