--- a/QScintilla/Exporters/ExporterTEX.py Tue Oct 15 22:03:54 2013 +0200 +++ b/QScintilla/Exporters/ExporterTEX.py Fri Oct 18 23:00:41 2013 +0200 @@ -42,7 +42,7 @@ def __getTexRGB(self, color): """ - Private method to convert a color object to a TeX color string + Private method to convert a color object to a TeX color string. @param color color object to convert (QColor) @return TeX color string (string) @@ -62,7 +62,8 @@ def __texStyle(self, style): """ - Private method to calculate a style name string for a given style number. + Private method to calculate a style name string for a given style + number. @param style style number (integer) @return style name string (string) @@ -87,8 +88,9 @@ @param istyle style number (integer) """ closing_brackets = 3 - file.write("\\newcommand{{\\eric{0}}}[1]{{\\noindent{{\\ttfamily{{".format( - self.__texStyle(istyle))) + file.write( + "\\newcommand{{\\eric{0}}}[1]{{\\noindent{{\\ttfamily{{".format( + self.__texStyle(istyle))) if font.italic(): file.write("\\textit{") closing_brackets += 1 @@ -96,10 +98,12 @@ file.write("\\textbf{") closing_brackets += 1 if color != self.defaultColor: - file.write("\\textcolor[rgb]{{{0}}}{{".format(self.__getTexRGB(color))) + file.write( + "\\textcolor[rgb]{{{0}}}{{".format(self.__getTexRGB(color))) closing_brackets += 1 if paper != self.defaultPaper: - file.write("\\colorbox[rgb]{{{0}}}{{".format(self.__getTexRGB(paper))) + file.write( + "\\colorbox[rgb]{{{0}}}{{".format(self.__getTexRGB(paper))) closing_brackets += 1 file.write("#1{0}\n".format('}' * closing_brackets)) @@ -121,8 +125,10 @@ if tabSize == 0: tabSize = 4 - onlyStylesUsed = Preferences.getEditorExporter("TeX/OnlyStylesUsed") - titleFullPath = Preferences.getEditorExporter("TeX/FullPathAsTitle") + onlyStylesUsed = Preferences.getEditorExporter( + "TeX/OnlyStylesUsed") + titleFullPath = Preferences.getEditorExporter( + "TeX/FullPathAsTitle") lex = self.editor.getLexer() self.defaultPaper = lex and \ @@ -176,7 +182,8 @@ colour = lex.color(istyle) paper = lex.paper(istyle) - self.__defineTexStyle(font, colour, paper, f, istyle) + self.__defineTexStyle(font, colour, paper, f, + istyle) istyle += 1 else: colour = self.editor.color() @@ -192,7 +199,8 @@ title = self.editor.getFileName() else: title = os.path.basename(self.editor.getFileName()) - f.write("Source File: {0}\n\n\\noindent\n\\tiny{{\n".format(title)) + f.write( + "Source File: {0}\n\n\\noindent\n\\tiny{{\n".format(title)) styleCurrent = self.editor.styleAt(0) f.write("\\eric{0}{{".format(self.__texStyle(styleCurrent))) @@ -208,7 +216,8 @@ style = self.editor.styleAt(pos) if style != styleCurrent: # new style - f.write("}}\n\\eric{0}{{".format(self.__texStyle(style))) + f.write( + "}}\n\\eric{0}{{".format(self.__texStyle(style))) styleCurrent = style if ch == b'\t': @@ -219,11 +228,13 @@ f.write("{\\textbackslash}") elif ch in [b'>', b'<', b'@']: f.write("${0}$".format(ch[0])) - elif ch in [b'{', b'}', b'^', b'_', b'&', b'$', b'#', b'%', b'~']: + elif ch in [b'{', b'}', b'^', b'_', b'&', b'$', b'#', + b'%', b'~']: f.write("\\{0}".format(ch[0])) elif ch in [b'\r', b'\n']: lineIdx = -1 # because incremented below - if ch == b'\r' and self.editor.byteAt(pos + 1) == b'\n': + if ch == b'\r' and \ + self.editor.byteAt(pos + 1) == b'\n': pos += 1 # skip the LF styleCurrent = self.editor.styleAt(pos + 1) f.write("}} \\\\\n\\eric{0}{{".format( @@ -261,8 +272,8 @@ E5MessageBox.critical(self.editor, self.trUtf8("Export source"), self.trUtf8( - """<p>The source could not be exported to <b>{0}</b>.</p>""" - """<p>Reason: {1}</p>""")\ + """<p>The source could not be exported to""" + """ <b>{0}</b>.</p><p>Reason: {1}</p>""")\ .format(filename, str(err))) finally: QApplication.restoreOverrideCursor()