prism-javascript.js 1.0 KB

12345678910111213141516171819202122232425262728
  1. Prism.languages.javascript = Prism.languages.extend('clike', {
  2. 'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,
  3. 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,
  4. 'function': /(?!\d)[a-z0-9_$]+(?=\()/i
  5. });
  6. Prism.languages.insertBefore('javascript', 'keyword', {
  7. 'regex': {
  8. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
  9. lookbehind: true
  10. }
  11. });
  12. if (Prism.languages.markup) {
  13. Prism.languages.insertBefore('markup', 'tag', {
  14. 'script': {
  15. pattern: /<script[\w\W]*?>[\w\W]*?<\/script>/i,
  16. inside: {
  17. 'tag': {
  18. pattern: /<script[\w\W]*?>|<\/script>/i,
  19. inside: Prism.languages.markup.tag.inside
  20. },
  21. rest: Prism.languages.javascript
  22. },
  23. alias: 'language-javascript'
  24. }
  25. });
  26. }