@@ -48,7 +48,8 @@ class HelpParser(HTMLParser):
4848 def __init__ (self , text ):
4949 HTMLParser .__init__ (self , convert_charrefs = True )
5050 self .text = text # text widget we're rendering into
51- self .tags = '' # current text tags to apply
51+ self .tags = '' # current block level text tags to apply
52+ self .chartags = '' # current character level text tags
5253 self .show = False # used so we exclude page navigation
5354 self .hdrlink = False # used so we don't show header links
5455 self .level = 0 # indentation level
@@ -78,11 +79,11 @@ def handle_starttag(self, tag, attrs):
7879 elif tag == 'p' and class_ != 'first' :
7980 s = '\n \n '
8081 elif tag == 'span' and class_ == 'pre' :
81- self .tags = 'pre'
82+ self .chartags = 'pre'
8283 elif tag == 'span' and class_ == 'versionmodified' :
83- self .tags = 'em'
84+ self .chartags = 'em'
8485 elif tag == 'em' :
85- self .tags = 'em'
86+ self .chartags = 'em'
8687 elif tag in ['ul' , 'ol' ]:
8788 if class_ .find ('simple' ) != - 1 :
8889 s = '\n '
@@ -120,16 +121,18 @@ def handle_starttag(self, tag, attrs):
120121 self .text .insert ('end' , '\n \n ' )
121122 self .tags = tag
122123 if self .show :
123- self .text .insert ('end' , s , self .tags )
124+ self .text .insert ('end' , s , ( self .tags , self . chartags ) )
124125
125126 def handle_endtag (self , tag ):
126127 "Handle endtags in help.html."
127- if tag in ['h1' , 'h2' , 'h3' , 'span' , 'em' ]:
128+ if tag in ['h1' , 'h2' , 'h3' ]:
128129 self .indent (0 ) # clear tag, reset indent
129130 if self .show and tag in ['h1' , 'h2' , 'h3' ]:
130131 title = self .data
131132 self .contents .append (('toc' + str (self .tocid ), title ))
132133 self .tocid += 1
134+ elif tag in ['span' , 'em' ]:
135+ self .chartags = ''
133136 elif tag == 'a' :
134137 self .hdrlink = False
135138 elif tag == 'pre' :
@@ -148,7 +151,7 @@ def handle_data(self, data):
148151 if d [0 :len (self .hprefix )] == self .hprefix :
149152 d = d [len (self .hprefix ):].strip ()
150153 self .data += d
151- self .text .insert ('end' , d , self .tags )
154+ self .text .insert ('end' , d , ( self .tags , self . chartags ) )
152155
153156
154157class HelpText (Text ):
@@ -165,7 +168,7 @@ def __init__(self, parent, filename):
165168 self .tag_configure ('h1' , font = (normalfont , 20 , 'bold' ))
166169 self .tag_configure ('h2' , font = (normalfont , 18 , 'bold' ))
167170 self .tag_configure ('h3' , font = (normalfont , 15 , 'bold' ))
168- self .tag_configure ('pre' , font = (fixedfont , 12 ))
171+ self .tag_configure ('pre' , font = (fixedfont , 12 ), background = '#f6f6ff' )
169172 self .tag_configure ('preblock' , font = (fixedfont , 10 ), lmargin1 = 25 ,
170173 borderwidth = 1 , relief = 'solid' , background = '#eeffcc' )
171174 self .tag_configure ('l1' , lmargin1 = 25 , lmargin2 = 25 )
0 commit comments