fixed highlighter for sass
This commit is contained in:
+5
-11
@@ -12,6 +12,7 @@
|
|||||||
# based on code from :
|
# based on code from :
|
||||||
# Copyright (C) 2008 Christophe Kibleur <kib2@free.fr>
|
# Copyright (C) 2008 Christophe Kibleur <kib2@free.fr>
|
||||||
|
|
||||||
|
# TODO : see pyQode for more features https://github.com/pyQode
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@@ -38,9 +39,6 @@ class QFormatter(Formatter):
|
|||||||
self.style = get_style_by_name(style)
|
self.style = get_style_by_name(style)
|
||||||
# self.linenos = linenos
|
# self.linenos = linenos
|
||||||
|
|
||||||
# styles = list(get_all_styles())
|
|
||||||
# print(styles)
|
|
||||||
|
|
||||||
# Create a dictionary of text styles, indexed
|
# Create a dictionary of text styles, indexed
|
||||||
# by pygments token names, containing QTextCharFormat
|
# by pygments token names, containing QTextCharFormat
|
||||||
# instances according to pygments' description
|
# instances according to pygments' description
|
||||||
@@ -71,8 +69,6 @@ class QFormatter(Formatter):
|
|||||||
# Just store a list of styles, one for each character
|
# Just store a list of styles, one for each character
|
||||||
# in the input. Obviously a smarter thing with
|
# in the input. Obviously a smarter thing with
|
||||||
# offsets and lengths is a good idea!
|
# offsets and lengths is a good idea!
|
||||||
print(tokensource)
|
|
||||||
|
|
||||||
for ttype, value in tokensource:
|
for ttype, value in tokensource:
|
||||||
l=len(value)
|
l=len(value)
|
||||||
t=str(ttype)
|
t=str(ttype)
|
||||||
@@ -83,12 +79,14 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
def __init__(self, parent, mode):
|
def __init__(self, parent, mode):
|
||||||
QSyntaxHighlighter.__init__(self, parent)
|
QSyntaxHighlighter.__init__(self, parent)
|
||||||
# self.tstamp=time.time()
|
|
||||||
|
styles = list(get_all_styles())
|
||||||
|
print(styles)
|
||||||
|
|
||||||
# Keep the formatter and lexer, initializing them
|
# Keep the formatter and lexer, initializing them
|
||||||
# may be costly.
|
# may be costly.
|
||||||
if not mode == "md":
|
if not mode == "md":
|
||||||
self.formatter=QFormatter(linenos=True, style="monokai-hcb")
|
self.formatter=QFormatter(linenos=True, style="monokai")
|
||||||
else:
|
else:
|
||||||
self.formatter=QFormatter(linenos=False, style="github")
|
self.formatter=QFormatter(linenos=False, style="github")
|
||||||
|
|
||||||
@@ -123,7 +121,3 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
self.setFormat(i,1,self.formatter.data[p+i])
|
self.setFormat(i,1,self.formatter.data[p+i])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# I may need to do something about this being called
|
|
||||||
# too quickly.
|
|
||||||
# self.tstamp=time.time()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user