238: #line 263 "html_weaver.ipk" 239: def new_heading(self,level): 240: while level>len(self.hcount): self.hcount.append(0) 241: while level<len(self.hcount): del self.hcount[-1] 242: counter = self.hcount[level-1]+1 243: self.hcount[level-1] = counter 244: return counter 245: 246: def get_formatted_heading_number(self, sep): 247: hnumber = '' 248: for i in range(0,len(self.hcount)-1): 249: hnumber = hnumber + str(self.hcount[i])+sep 250: hnumber = hnumber + str(self.hcount[-1]) 251: return hnumber 252: 253: 254: def head(self,level, text, **kwds): 255: atext=kwds.get('short_text',text) 256: anchor=kwds.get('key','') 257: self._endmode() 258: myanchor = anchor 259: if myanchor == '': myanchor = atext 260: if myanchor == '': 261: myanchor = 'h'+str(self.acount) 262: self.acount = self.acount + 1 263: 264: self.new_heading(level) 265: hnumber = self.get_formatted_heading_number('.')+'. ' 266: hprefix = '' 267: if self.keywords.has_key('heading_prefix'): 268: hprefix = self.keywords['heading_prefix'] 269: ahref = '<A HREF="#'+anchor+'">'+hprefix+hnumber+str(text)+'</A>' 270: 271: html_level = level + self.heading_level_offset 272: if html_level > 6: html_level = 6 273: if anchor: atag = ' ID="'+anchor+'" TITLE="'+anchor+'"' 274: else: atag = ' ID="'+myanchor+'"' 275: self._writeline( '<H'+str(html_level)+atag+'>'+ 276: hprefix+hnumber+str(text)+\ 277: '</H'+str(html_level)+'>') 278: 279: counter = self.hcount[level-1] 280: self.toc.append((level,ahref)) 281: