ProjectWeb/Html5Prettifier.py

changeset 30
38092622e612
parent 29
38577502d613
child 34
a6d8718f37b5
equal deleted inserted replaced
29:38577502d613 30:38092622e612
5 5
6 """ 6 """
7 Module implementing a class to prettify HTML code. 7 Module implementing a class to prettify HTML code.
8 """ 8 """
9 9
10 from __future__ import unicode_literals
11
12 import re 10 import re
13
14 11
15 from PyQt5.QtCore import QObject 12 from PyQt5.QtCore import QObject
16 13
17 import Preferences 14 import Preferences
18 15
57 Public method to prettify HTML tags. 54 Public method to prettify HTML tags.
58 55
59 @param tag tag to be prettified (string) 56 @param tag tag to be prettified (string)
60 @return prettified tag (string) 57 @return prettified tag (string)
61 """ 58 """
62 result = re.sub(" {{1,{0}}}".format(self.__indentWidth), " ", tag, 59 return re.sub(" {{1,{0}}}".format(self.__indentWidth), " ", tag,
63 flags=re.MULTILINE) 60 flags=re.MULTILINE)
64 return result
65 61
66 def commentPrettify(self, matchobj): 62 def commentPrettify(self, matchobj):
67 """ 63 """
68 Public method to prettify HTML comments. 64 Public method to prettify HTML comments.
69 65
70 @param matchobj reference to the match object (re.MatchObject) 66 @param matchobj reference to the match object (re.MatchObject)
71 @return prettified comment (string) 67 @return prettified comment (string)
72 """ 68 """
73 if re.search("\n", matchobj.group()): 69 if re.search("\n", matchobj.group()):
74 result = self.tagPrettify(matchobj.group()) 70 return self.tagPrettify(matchobj.group())
75 else: 71 else:
76 result = matchobj.group() 72 return matchobj.group()
77 return result

eric ide

mercurial