prism-css.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Prism.languages.css = {
  2. 'comment': /\/\*[\w\W]*?\*\//,
  3. 'atrule': {
  4. pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
  5. inside: {
  6. 'punctuation': /[;:]/
  7. }
  8. },
  9. 'url': /url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,
  10. 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/,
  11. 'string': /("|')(\\\n|\\?.)*?\1/,
  12. 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
  13. 'important': /\B!important\b/i,
  14. 'punctuation': /[\{\};:]/,
  15. 'function': /[-a-z0-9]+(?=\()/i
  16. };
  17. if (Prism.languages.markup) {
  18. Prism.languages.insertBefore('markup', 'tag', {
  19. 'style': {
  20. pattern: /<style[\w\W]*?>[\w\W]*?<\/style>/i,
  21. inside: {
  22. 'tag': {
  23. pattern: /<style[\w\W]*?>|<\/style>/i,
  24. inside: Prism.languages.markup.tag.inside
  25. },
  26. rest: Prism.languages.css
  27. },
  28. alias: 'language-css'
  29. }
  30. });
  31. Prism.languages.insertBefore('inside', 'attr-value', {
  32. 'style-attr': {
  33. pattern: /\s*style=("|').*?\1/i,
  34. inside: {
  35. 'attr-name': {
  36. pattern: /^\s*style/i,
  37. inside: Prism.languages.markup.tag.inside
  38. },
  39. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  40. 'attr-value': {
  41. pattern: /.+/i,
  42. inside: Prism.languages.css
  43. }
  44. },
  45. alias: 'language-css'
  46. }
  47. }, Prism.languages.markup.tag);
  48. }