class Rouge::Lexers::Javascript
IMPORTANT NOTICE:
Please do not copy this lexer and open a pull request for a new language. It will not get merged, you will be unhappy, and kittens will cry.
Public Class Methods
Source
# File lib/rouge/lexers/javascript.rb, line 126 def self.builtins @builtins ||= %w( Array Boolean Date Error Function Math netscape Number Object Packages RegExp String sun decodeURI decodeURIComponent encodeURI encodeURIComponent Error eval isFinite isNaN parseFloat parseInt document window navigator self global Promise Set Map WeakSet WeakMap Symbol Proxy Reflect Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Uint16ClampedArray Int32Array Uint32Array Uint32ClampedArray Float32Array Float64Array DataView ArrayBuffer ) end
Source
# File lib/rouge/lexers/javascript.rb, line 122 def self.constants @constants ||= Set.new %w(true false null NaN Infinity undefined) end
Source
# File lib/rouge/lexers/javascript.rb, line 108 def self.declarations @declarations ||= Set.new %w( var let const with function class extends constructor get set static ) end
Source
# File lib/rouge/lexers/javascript.rb, line 23 def self.detect?(text) return 1 if text.shebang?('node') return 1 if text.shebang?('jsc') # TODO: rhino, spidermonkey, etc end
Pseudo-documentation: stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names
Source
# File lib/rouge/lexers/javascript.rb, line 141 def self.id_regex /[\p{L}\p{Nl}$_][\p{Word}]*/io end
Source
# File lib/rouge/lexers/javascript.rb, line 100 def self.keywords @keywords ||= Set.new %w( async await break case catch continue debugger default delete do else export finally from for if import in instanceof new of return super switch this throw try typeof void while yield ) end
Source
# File lib/rouge/lexers/javascript.rb, line 115 def self.reserved @reserved ||= Set.new %w( enum implements interface package private protected public ) end