eric6/QScintilla/Exporters/ExporterHTML.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7960
e8fc383322f7
child 8273
698ae46f40a4
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
42 def generate(self, tabSize=4, useTabs=False, wysiwyg=True, folding=False, 42 def generate(self, tabSize=4, useTabs=False, wysiwyg=True, folding=False,
43 onlyStylesUsed=False, titleFullPath=False): 43 onlyStylesUsed=False, titleFullPath=False):
44 """ 44 """
45 Public method to generate HTML for the source editor. 45 Public method to generate HTML for the source editor.
46 46
47 @keyparam tabSize size of tabs (integer) 47 @param tabSize size of tabs (integer)
48 @keyparam useTabs flag indicating the use of tab characters (boolean) 48 @param useTabs flag indicating the use of tab characters (boolean)
49 @keyparam wysiwyg flag indicating colorization (boolean) 49 @param wysiwyg flag indicating colorization (boolean)
50 @keyparam folding flag indicating usage of fold markers 50 @param folding flag indicating usage of fold markers
51 @keyparam onlyStylesUsed flag indicating to include only style 51 @param onlyStylesUsed flag indicating to include only style
52 definitions for styles used in the source (boolean) 52 definitions for styles used in the source (boolean)
53 @keyparam titleFullPath flag indicating to include the full file path 53 @param titleFullPath flag indicating to include the full file path
54 in the title tag (boolean) 54 in the title tag (boolean)
55 @return generated HTML text (string) 55 @return generated HTML text (string)
56 """ 56 """
57 self.editor.recolor(0, -1) 57 self.editor.recolor(0, -1)
58 58
84 self.editor.getFileName()) 84 self.editor.getFileName())
85 else: 85 else:
86 html += '''<title>{0}</title>\n'''.format( 86 html += '''<title>{0}</title>\n'''.format(
87 os.path.basename(self.editor.getFileName())) 87 os.path.basename(self.editor.getFileName()))
88 html += ( 88 html += (
89 '''<meta name="Generator" content="eric6" />\n''' 89 '''<meta name="Generator" content="eric" />\n'''
90 '''<meta http-equiv="Content-Type" ''' 90 '''<meta http-equiv="Content-Type" '''
91 '''content="text/html; charset=utf-8" />\n''' 91 '''content="text/html; charset=utf-8" />\n'''
92 ) 92 )
93 if folding: 93 if folding:
94 html += ( 94 html += (
163 html += ''' text-decoration: inherit;\n''' 163 html += ''' text-decoration: inherit;\n'''
164 if wysiwyg: 164 if wysiwyg:
165 html += ''' font-size: {0:d}pt;\n'''.format( 165 html += ''' font-size: {0:d}pt;\n'''.format(
166 QFontInfo(font).pointSize()) 166 QFontInfo(font).pointSize())
167 html += '''}\n''' 167 html += '''}\n'''
168
169 # get substyles
170 subs_start, subs_count = self.editor.getSubStyleRange(
171 istyle)
172 for subs_idx in range(subs_count):
173 styleIsUsed[subs_idx - subs_start] = True
174 font = lex.font(subs_start + subs_idx)
175 colour = lex.color(subs_start + subs_idx)
176 paper = lex.paper(subs_start + subs_idx)
177 html += '.S{0:d} {{\n'.format(
178 subs_idx - subs_start)
179 if font.italic():
180 html += ' font-style: italic;\n'
181 if font.bold():
182 html += ' font-weight: bold;\n'
183 if wysiwyg:
184 html += " font-family: '{0}';\n".format(
185 font.family())
186 html += ' color: {0};\n'.format(colour.name())
187 if wysiwyg:
188 html += ' font-size: {0:d}pt;\n'.format(
189 QFontInfo(font).pointSize())
190 html += '}\n'
168 else: 191 else:
169 styleIsUsed[istyle] = False 192 styleIsUsed[istyle] = False
170 istyle += 1 193 istyle += 1
171 else: 194 else:
172 colour = self.editor.color() 195 colour = self.editor.color()
657 self.editor.getFileName()) 680 self.editor.getFileName())
658 else: 681 else:
659 head += '''<title>{0}</title>\n'''.format( 682 head += '''<title>{0}</title>\n'''.format(
660 os.path.basename(self.editor.getFileName())) 683 os.path.basename(self.editor.getFileName()))
661 head += ( 684 head += (
662 '''<meta name="Generator" content="eric6" />\n''' 685 '''<meta name="Generator" content="eric" />\n'''
663 '''<meta http-equiv="Content-Type" ''' 686 '''<meta http-equiv="Content-Type" '''
664 '''content="text/html; charset=utf-8" />\n''' 687 '''content="text/html; charset=utf-8" />\n'''
665 '''{0}''' 688 '''{0}'''
666 '''{1}''' 689 '''{1}'''
667 '''<style type="text/css">''' 690 '''<style type="text/css">'''

eric ide

mercurial