From bf8e032623d0954969374e51d02d3640faa6f1b1 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 09:10:59 +0200 Subject: [PATCH] Fix SCSS media queries --- components/prism-scss.js | 8 +++++++- components/prism-scss.min.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/prism-scss.js b/components/prism-scss.js index 36b956c4ed..907b6632bc 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -5,7 +5,13 @@ Prism.languages.scss = Prism.languages.extend('css', { }, // aturle is just the @***, not the entire rule (to highlight var & stuffs) // + add ability to highlight number & unit for media queries - 'atrule': /@[\w-]+.*?(?=\s+(\(|\{|;))/i, + 'atrule': { + pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i, + inside: { + 'property': Prism.languages.css.property, + 'punctuation': /[():]/ + } + }, // url, compassified 'url': /([-a-z]+-)*url(?=\()/i, // CSS selector regex is not appropriate for Sass diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index ef62fb7fe4..a8444e438c 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:/@[\w-]+.*?(?=\s+(\(|\{|;))/i,url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{property:Prism.languages.css.property,punctuation:/[():]/}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file