mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
website: Update prism regexes for better JavaScript code highlight
Summary: Before: ![screen shot 2017-05-19 at 20 01 28](https://cloud.githubusercontent.com/assets/16212576/26259151/4ed69f18-3cd0-11e7-8c83-6a64646100b5.png) After: ![screen shot 2017-05-19 at 20 01 11](https://cloud.githubusercontent.com/assets/16212576/26259166/58525ef6-3cd0-11e7-97e5-ed8f0e0a861a.png) Closes https://github.com/facebook/react-native/pull/14065 Differential Revision: D5142775 Pulled By: hramos fbshipit-source-id: 89dff95a5a6921365368ba223c1c8299092ba72f
This commit is contained in:
parent
26ee9b94d4
commit
6cd3167b99
@ -314,14 +314,38 @@ _.languages.clike = {
|
||||
};
|
||||
|
||||
_.languages.javascript = _.languages.extend('clike', {
|
||||
'keyword': /\b(var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g,
|
||||
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g
|
||||
'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
|
||||
'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
||||
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
||||
'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
|
||||
'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
|
||||
});
|
||||
|
||||
_.languages.insertBefore('javascript', 'keyword', {
|
||||
'regex': {
|
||||
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,
|
||||
lookbehind: true
|
||||
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
}
|
||||
});
|
||||
|
||||
_.languages.insertBefore('javascript', 'string', {
|
||||
'template-string': {
|
||||
pattern: /`(?:\\\\|\\?[^\\])*?`/,
|
||||
greedy: true,
|
||||
inside: {
|
||||
'interpolation': {
|
||||
pattern: /\$\{[^}]+\}/,
|
||||
inside: {
|
||||
'interpolation-punctuation': {
|
||||
pattern: /^\$\{|\}$/,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
rest: _.languages.javascript
|
||||
}
|
||||
},
|
||||
'string': /[\s\S]+/
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user