X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=highlighter.py;h=3213755526947638d6f15ab25563914ba85e35cf;hp=95cfa90c09c83567a0eb671ad89ac95264feb993;hb=2687a3c3b18c3a267ca60ecdd3759ed0856471e0;hpb=a17e899ab18f129ecc6e894e8b2ddc3322aef6f8 diff --git a/highlighter.py b/highlighter.py index 95cfa90..3213755 100644 --- a/highlighter.py +++ b/highlighter.py @@ -9,16 +9,24 @@ class SimpleHtmlHighlighter (PyQt4.QtGui.QSyntaxHighlighter): def highlightBlock (self, text): # define the character highlight formats + + # for tags charfmt1 = PyQt4.QtGui.QTextCharFormat () charfmt1.setFontWeight (PyQt4.QtGui.QFont.Bold) charfmt1.setForeground (PyQt4.QtCore.Qt.blue) + # for strings charfmt2 = PyQt4.QtGui.QTextCharFormat () charfmt2.setForeground (PyQt4.QtCore.Qt.darkGreen) + # for html entities + charfmt3 = PyQt4.QtGui.QTextCharFormat () + charfmt3.setForeground (PyQt4.QtCore.Qt.magenta) + # matching regular expressions htmltagexps = [ (PyQt4.QtCore.QRegExp ("<[^<>]+>"), charfmt1), - (PyQt4.QtCore.QRegExp ("\"[^\"]+\""), charfmt2) + (PyQt4.QtCore.QRegExp ("\"[^\"]+\""), charfmt2), + (PyQt4.QtCore.QRegExp ("&[^;]+;"), charfmt3) ] # run through the list of regular expressions to highlight