QScintilla/Exporters/ExporterHTML.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
diff -r 1b59c4ba121e -r 8cd4d08fa9f6 QScintilla/Exporters/ExporterHTML.py
--- a/QScintilla/Exporters/ExporterHTML.py	Fri Mar 11 08:55:14 2011 +0100
+++ b/QScintilla/Exporters/ExporterHTML.py	Fri Mar 11 16:51:57 2011 +0100
@@ -23,6 +23,7 @@
 import Preferences
 import Utilities
 
+
 class HTMLGenerator(object):
     """
     Class implementing an HTML generator for exporting source code.
@@ -35,8 +36,8 @@
         """
         self.editor = editor
     
-    def generate(self, tabSize = 4, useTabs = False, wysiwyg = True, folding = False, 
-                 onlyStylesUsed = False, titleFullPath = False):
+    def generate(self, tabSize=4, useTabs=False, wysiwyg=True, folding=False,
+                 onlyStylesUsed=False, titleFullPath=False):
         """
         Public method to generate HTML for the source editor.
         
@@ -212,7 +213,7 @@
                 if inStyleSpan:
                     html += '''</span>'''
                     inStyleSpan = False
-                if ch not in [b'\r', b'\n']: # no need of a span for the EOL
+                if ch not in [b'\r', b'\n']:  # no need of a span for the EOL
                     if styleIsUsed[style]:
                         html += '''<span class="S{0:d}">'''.format(style)
                         inStyleSpan = True
@@ -221,8 +222,8 @@
             if ch == b' ':
                 if wysiwyg:
                     prevCh = b''
-                    if column == 0: 
-                        # at start of line, must put a &nbsp; 
+                    if column == 0:
+                        # at start of line, must put a &nbsp;
                         # because regular space will be collapsed
                         prevCh = b' '
                     while pos < lengthDoc and self.editor.byteAt(pos) == b' ':
@@ -233,7 +234,7 @@
                         prevCh = self.editor.byteAt(pos)
                         pos += 1
                         column += 1
-                    pos -= 1 
+                    pos -= 1
                     # the last incrementation will be done by the outer loop
                 else:
                     html += ' '
@@ -258,7 +259,7 @@
                     html += '''</span>'''
                     inFoldSpan = False
                 if ch == b'\r' and self.editor.byteAt(pos + 1) == b'\n':
-                    pos += 1 # CR+LF line ending, skip the "extra" EOL char
+                    pos += 1  # CR+LF line ending, skip the "extra" EOL char
                 column = 0
                 if wysiwyg:
                     html += '''<br />'''
@@ -272,7 +273,7 @@
                         while levelStack[-1] > newLevel:
                             html += '''</span>'''
                             levelStack.pop()
-                    html += '\n' # here to get clean code
+                    html += '\n'  # here to get clean code
                     if newLevel > level:
                         html += '''<span id="ln{0:d}">'''.format(line)
                         levelStack.append(newLevel)
@@ -312,14 +313,14 @@
                                 utf8Len = 3
                             elif (utf8Ch[0] & 0xC0) == 0xC0:
                                 utf8Len = 2
-                            column -= 1 # will be incremented again later
+                            column -= 1  # will be incremented again later
                         elif len(utf8Ch) == utf8Len:
                             ch = utf8Ch.decode('utf8')
                             html += Utilities.html_encode(ch)
                             utf8Ch = b""
                             utf8Len = 0
                         else:
-                            column -= 1 # will be incremented again later
+                            column -= 1  # will be incremented again later
                     else:
                         html += ch.decode()
                 column += 1
@@ -343,11 +344,12 @@
         
         return html
 
+
 class ExporterHTML(ExporterBase):
     """
     Class implementing an exporter for HTML.
     """
-    def __init__(self, editor, parent = None):
+    def __init__(self, editor, parent=None):
         """
         Constructor
         
@@ -379,16 +381,16 @@
             
             generator = HTMLGenerator(self.editor)
             html = generator.generate(
-                tabSize = tabSize, 
-                useTabs = tabs, 
-                wysiwyg = wysiwyg, 
-                folding = folding, 
-                onlyStylesUsed = onlyStylesUsed, 
-                titleFullPath = titleFullPath
+                tabSize=tabSize,
+                useTabs=tabs,
+                wysiwyg=wysiwyg,
+                folding=folding,
+                onlyStylesUsed=onlyStylesUsed,
+                titleFullPath=titleFullPath
             )
             
             try:
-                f = open(filename, "w", encoding = "utf-8")
+                f = open(filename, "w", encoding="utf-8")
                 f.write(html)
                 f.close()
             except IOError as err:
@@ -400,4 +402,4 @@
                         """<p>Reason: {1}</p>""")\
                         .format(filename, str(err)))
         finally:
-            QApplication.restoreOverrideCursor()
\ No newline at end of file
+            QApplication.restoreOverrideCursor()

eric ide

mercurial