src/eric7/QScintilla/Lexers/LexerHTML.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class LexerHTML(Lexer, QsciLexerHTML): 18 class LexerHTML(Lexer, QsciLexerHTML):
19 """ 19 """
20 Subclass to implement some additional lexer dependant methods. 20 Subclass to implement some additional lexer dependant methods.
21 """ 21 """
22
22 def __init__(self, parent=None): 23 def __init__(self, parent=None):
23 """ 24 """
24 Constructor 25 Constructor
25 26
26 @param parent parent widget of this lexer 27 @param parent parent widget of this lexer
27 """ 28 """
28 QsciLexerHTML.__init__(self, parent) 29 QsciLexerHTML.__init__(self, parent)
29 Lexer.__init__(self) 30 Lexer.__init__(self)
30 31
31 self.streamCommentString = { 32 self.streamCommentString = {"start": "<!-- ", "end": " -->"}
32 'start': '<!-- ', 33
33 'end': ' -->'
34 }
35
36 self.keywordSetDescriptions = [ 34 self.keywordSetDescriptions = [
37 self.tr("HTML elements and attributes"), 35 self.tr("HTML elements and attributes"),
38 self.tr("JavaScript keywords"), 36 self.tr("JavaScript keywords"),
39 self.tr("VBScript keywords"), 37 self.tr("VBScript keywords"),
40 self.tr("Python keywords"), 38 self.tr("Python keywords"),
41 self.tr("PHP keywords"), 39 self.tr("PHP keywords"),
42 self.tr("SGML and DTD keywords"), 40 self.tr("SGML and DTD keywords"),
43 ] 41 ]
44 42
45 def initProperties(self): 43 def initProperties(self):
46 """ 44 """
47 Public slot to initialize the properties. 45 Public slot to initialize the properties.
48 """ 46 """
49 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor")) 47 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor"))
50 self.setCaseSensitiveTags( 48 self.setCaseSensitiveTags(Preferences.getEditor("HtmlCaseSensitiveTags"))
51 Preferences.getEditor("HtmlCaseSensitiveTags"))
52 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 49 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
53 with contextlib.suppress(AttributeError): 50 with contextlib.suppress(AttributeError):
54 self.setFoldScriptComments( 51 self.setFoldScriptComments(Preferences.getEditor("HtmlFoldScriptComments"))
55 Preferences.getEditor("HtmlFoldScriptComments")) 52 self.setFoldScriptHeredocs(Preferences.getEditor("HtmlFoldScriptHeredocs"))
56 self.setFoldScriptHeredocs(
57 Preferences.getEditor("HtmlFoldScriptHeredocs"))
58 with contextlib.suppress(AttributeError): 53 with contextlib.suppress(AttributeError):
59 self.setDjangoTemplates( 54 self.setDjangoTemplates(Preferences.getEditor("HtmlDjangoTemplates"))
60 Preferences.getEditor("HtmlDjangoTemplates"))
61 self.setMakoTemplates(Preferences.getEditor("HtmlMakoTemplates")) 55 self.setMakoTemplates(Preferences.getEditor("HtmlMakoTemplates"))
62 56
63 def isCommentStyle(self, style): 57 def isCommentStyle(self, style):
64 """ 58 """
65 Public method to check, if a style is a comment style. 59 Public method to check, if a style is a comment style.
66 60
67 @param style style to check (integer) 61 @param style style to check (integer)
68 @return flag indicating a comment style (boolean) 62 @return flag indicating a comment style (boolean)
69 """ 63 """
70 return style in [QsciLexerHTML.HTMLComment, 64 return style in [
71 QsciLexerHTML.ASPXCComment, 65 QsciLexerHTML.HTMLComment,
72 QsciLexerHTML.SGMLComment, 66 QsciLexerHTML.ASPXCComment,
73 QsciLexerHTML.SGMLParameterComment, 67 QsciLexerHTML.SGMLComment,
74 QsciLexerHTML.JavaScriptComment, 68 QsciLexerHTML.SGMLParameterComment,
75 QsciLexerHTML.JavaScriptCommentDoc, 69 QsciLexerHTML.JavaScriptComment,
76 QsciLexerHTML.JavaScriptCommentLine, 70 QsciLexerHTML.JavaScriptCommentDoc,
77 QsciLexerHTML.ASPJavaScriptComment, 71 QsciLexerHTML.JavaScriptCommentLine,
78 QsciLexerHTML.ASPJavaScriptCommentDoc, 72 QsciLexerHTML.ASPJavaScriptComment,
79 QsciLexerHTML.ASPJavaScriptCommentLine, 73 QsciLexerHTML.ASPJavaScriptCommentDoc,
80 QsciLexerHTML.VBScriptComment, 74 QsciLexerHTML.ASPJavaScriptCommentLine,
81 QsciLexerHTML.ASPVBScriptComment, 75 QsciLexerHTML.VBScriptComment,
82 QsciLexerHTML.PythonComment, 76 QsciLexerHTML.ASPVBScriptComment,
83 QsciLexerHTML.ASPPythonComment, 77 QsciLexerHTML.PythonComment,
84 QsciLexerHTML.PHPComment] 78 QsciLexerHTML.ASPPythonComment,
85 79 QsciLexerHTML.PHPComment,
80 ]
81
86 def isStringStyle(self, style): 82 def isStringStyle(self, style):
87 """ 83 """
88 Public method to check, if a style is a string style. 84 Public method to check, if a style is a string style.
89 85
90 @param style style to check (integer) 86 @param style style to check (integer)
91 @return flag indicating a string style (boolean) 87 @return flag indicating a string style (boolean)
92 """ 88 """
93 return style in [QsciLexerHTML.HTMLDoubleQuotedString, 89 return style in [
94 QsciLexerHTML.HTMLSingleQuotedString, 90 QsciLexerHTML.HTMLDoubleQuotedString,
95 QsciLexerHTML.SGMLDoubleQuotedString, 91 QsciLexerHTML.HTMLSingleQuotedString,
96 QsciLexerHTML.SGMLSingleQuotedString, 92 QsciLexerHTML.SGMLDoubleQuotedString,
97 QsciLexerHTML.JavaScriptDoubleQuotedString, 93 QsciLexerHTML.SGMLSingleQuotedString,
98 QsciLexerHTML.JavaScriptSingleQuotedString, 94 QsciLexerHTML.JavaScriptDoubleQuotedString,
99 QsciLexerHTML.JavaScriptUnclosedString, 95 QsciLexerHTML.JavaScriptSingleQuotedString,
100 QsciLexerHTML.ASPJavaScriptDoubleQuotedString, 96 QsciLexerHTML.JavaScriptUnclosedString,
101 QsciLexerHTML.ASPJavaScriptSingleQuotedString, 97 QsciLexerHTML.ASPJavaScriptDoubleQuotedString,
102 QsciLexerHTML.ASPJavaScriptUnclosedString, 98 QsciLexerHTML.ASPJavaScriptSingleQuotedString,
103 QsciLexerHTML.VBScriptString, 99 QsciLexerHTML.ASPJavaScriptUnclosedString,
104 QsciLexerHTML.VBScriptUnclosedString, 100 QsciLexerHTML.VBScriptString,
105 QsciLexerHTML.ASPVBScriptString, 101 QsciLexerHTML.VBScriptUnclosedString,
106 QsciLexerHTML.ASPVBScriptUnclosedString, 102 QsciLexerHTML.ASPVBScriptString,
107 QsciLexerHTML.PythonDoubleQuotedString, 103 QsciLexerHTML.ASPVBScriptUnclosedString,
108 QsciLexerHTML.PythonSingleQuotedString, 104 QsciLexerHTML.PythonDoubleQuotedString,
109 QsciLexerHTML.PythonTripleDoubleQuotedString, 105 QsciLexerHTML.PythonSingleQuotedString,
110 QsciLexerHTML.PythonTripleSingleQuotedString, 106 QsciLexerHTML.PythonTripleDoubleQuotedString,
111 QsciLexerHTML.ASPPythonDoubleQuotedString, 107 QsciLexerHTML.PythonTripleSingleQuotedString,
112 QsciLexerHTML.ASPPythonSingleQuotedString, 108 QsciLexerHTML.ASPPythonDoubleQuotedString,
113 QsciLexerHTML.ASPPythonTripleDoubleQuotedString, 109 QsciLexerHTML.ASPPythonSingleQuotedString,
114 QsciLexerHTML.ASPPythonTripleSingleQuotedString, 110 QsciLexerHTML.ASPPythonTripleDoubleQuotedString,
115 QsciLexerHTML.PHPDoubleQuotedString, 111 QsciLexerHTML.ASPPythonTripleSingleQuotedString,
116 QsciLexerHTML.PHPSingleQuotedString] 112 QsciLexerHTML.PHPDoubleQuotedString,
117 113 QsciLexerHTML.PHPSingleQuotedString,
114 ]
115
118 def defaultKeywords(self, kwSet): 116 def defaultKeywords(self, kwSet):
119 """ 117 """
120 Public method to get the default keywords. 118 Public method to get the default keywords.
121 119
122 @param kwSet number of the keyword set (integer) 120 @param kwSet number of the keyword set (integer)
123 @return string giving the keywords (string) or None 121 @return string giving the keywords (string) or None
124 """ 122 """
125 return QsciLexerHTML.keywords(self, kwSet) 123 return QsciLexerHTML.keywords(self, kwSet)

eric ide

mercurial