(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'(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|' r'transient|volatile)\b', Keyword.Reserved), (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), (r'(Array|Boolean|Date|Error|Function|Math|netscape|' r'Number|Object|Packages|RegExp|String|sun|decodeURI|' r'decodeURIComponent|encodeURI|encodeURIComponent|' r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|' r'window)\b', Name.Builtin), (JS_IDENT, Name.Other), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'0x[0-9a-fA-F]+', Number.Hex), (r'[0-9]+', Number.Integer), (r'"(\\\\|\\"|[^"])*"', String.Double), (r"'(\\\\|\\'|[^'])*'", String.Single), ] } Highlighter = create_highlighter('JavascriptHighlighter', JavascriptLexer) if __name__ == '__main__': from calibre.gui2.tweak_book.editor.widget import launch_editor launch_editor(P('viewer/images.js'), syntax='javascript')
r"extends|final|float|goto|implements|import|int|interface|long|native|" r"package|private|protected|public|short|static|super|synchronized|throws|" r"transient|volatile)\b", Keyword.Reserved, ), (r"(true|false|null|NaN|Infinity|undefined)\b", Keyword.Constant), ( r"(Array|Boolean|Date|Error|Function|Math|netscape|" r"Number|Object|Packages|RegExp|String|sun|decodeURI|" r"decodeURIComponent|encodeURI|encodeURIComponent|" r"Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|" r"window)\b", Name.Builtin, ), (JS_IDENT, Name.Other), (r"[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?", Number.Float), (r"0x[0-9a-fA-F]+", Number.Hex), (r"[0-9]+", Number.Integer), (r'"(\\\\|\\"|[^"])*"', String.Double), (r"'(\\\\|\\'|[^'])*'", String.Single), ], } Highlighter = create_highlighter("JavascriptHighlighter", JavascriptLexer) if __name__ == "__main__": from calibre.gui2.tweak_book.editor.widget import launch_editor launch_editor(P("viewer/images.js"), syntax="javascript")
#!/usr/bin/env python # vim:fileencoding=utf-8 from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>' from pygments.lexers import PythonLexer from calibre.gui2.tweak_book.editor.syntax.pygments_highlighter import create_highlighter Highlighter = create_highlighter('PythonHighlighter', PythonLexer) if __name__ == '__main__': import os from calibre.gui2.tweak_book.editor.widget import launch_editor launch_editor(os.path.abspath(__file__), syntax='python')
(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, 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|' r'transient|volatile)\b', Keyword.Reserved), (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), (r'(Array|Boolean|Date|Error|Function|Math|netscape|' r'Number|Object|Packages|RegExp|String|sun|decodeURI|' r'decodeURIComponent|encodeURI|encodeURIComponent|' r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|' r'window)\b', Name.Builtin), (JS_IDENT, Name.Other), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'0x[0-9a-fA-F]+', Number.Hex), (r'[0-9]+', Number.Integer), (r'"(\\\\|\\"|[^"])*"', String.Double), (r"'(\\\\|\\'|[^'])*'", String.Single), ] } Highlighter = create_highlighter('JavascriptHighlighter', JavascriptLexer) if __name__ == '__main__': from calibre.gui2.tweak_book.editor.widget import launch_editor launch_editor(P('viewer/images.js'), syntax='javascript')