mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
py3: All python modules now import successfully
This commit is contained in:
parent
b9a3e1952e
commit
13a8b63d35
@ -13,6 +13,7 @@ from pygments.token import Comment, Punctuation, Number, Keyword, Text, String,
|
||||
import pygments.unistring as uni
|
||||
|
||||
from calibre.gui2.tweak_book.editor.syntax.pygments_highlighter import create_highlighter
|
||||
from polyglot.builtins import native_string_type
|
||||
|
||||
JS_IDENT_START = ('(?:[$_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') +
|
||||
']|\\\\u[a-fA-F0-9]{4})')
|
||||
@ -33,39 +34,39 @@ class JavascriptLexer(RegexLexer):
|
||||
flags = re.UNICODE | re.MULTILINE
|
||||
|
||||
tokens = {
|
||||
b'commentsandwhitespace': [
|
||||
native_string_type('commentsandwhitespace'): [
|
||||
(r'\s+', Text),
|
||||
(r'<!--', Comment),
|
||||
(r'//.*?$', Comment.Single),
|
||||
(r'/\*', Comment.Multiline, b'comment')
|
||||
(r'/\*', Comment.Multiline, native_string_type('comment'))
|
||||
],
|
||||
b'comment': [
|
||||
native_string_type('comment'): [
|
||||
(r'[^*/]+', Comment.Multiline),
|
||||
(r'\*/', Comment.Multiline, b'#pop'),
|
||||
(r'\*/', Comment.Multiline, native_string_type('#pop')),
|
||||
(r'[*/]', Comment.Multiline),
|
||||
],
|
||||
b'slashstartsregex': [
|
||||
include(b'commentsandwhitespace'),
|
||||
native_string_type('slashstartsregex'): [
|
||||
include(native_string_type('commentsandwhitespace')),
|
||||
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
||||
r'([gim]+\b|\B)', String.Regex, b'#pop'),
|
||||
(r'(?=/)', Text, (b'#pop', b'badregex')),
|
||||
default(b'#pop')
|
||||
r'([gim]+\b|\B)', String.Regex, native_string_type('#pop')),
|
||||
(r'(?=/)', Text, (native_string_type('#pop'), native_string_type('badregex'))),
|
||||
default(native_string_type('#pop'))
|
||||
],
|
||||
b'badregex': [
|
||||
(r'\n', Text, b'#pop')
|
||||
native_string_type('badregex'): [
|
||||
(r'\n', Text, native_string_type('#pop'))
|
||||
],
|
||||
b'root': [
|
||||
native_string_type('root'): [
|
||||
(r'\A#! ?/.*?\n', Comment), # shebang lines are recognized by node.js
|
||||
(r'^(?=\s|/|<!--)', Text, b'slashstartsregex'),
|
||||
include(b'commentsandwhitespace'),
|
||||
(r'^(?=\s|/|<!--)', Text, native_string_type('slashstartsregex')),
|
||||
include(native_string_type('commentsandwhitespace')),
|
||||
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
||||
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, b'slashstartsregex'),
|
||||
(r'[{(\[;,]', Punctuation, b'slashstartsregex'),
|
||||
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, native_string_type('slashstartsregex')),
|
||||
(r'[{(\[;,]', Punctuation, native_string_type('slashstartsregex')),
|
||||
(r'[})\].]', Punctuation),
|
||||
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
||||
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|'
|
||||
r'this)\b', Keyword, b'slashstartsregex'),
|
||||
(r'(var|let|with|function)\b', Keyword.Declaration, b'slashstartsregex'),
|
||||
r'this)\b', Keyword, native_string_type('slashstartsregex')),
|
||||
(r'(var|let|with|function)\b', Keyword.Declaration, native_string_type('slashstartsregex')),
|
||||
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
||||
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
||||
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
||||
|
Loading…
x
Reference in New Issue
Block a user