diff --git a/components/prism-sass.js b/components/prism-sass.js index 9115684fa3..4609ac0ab3 100644 --- a/components/prism-sass.js +++ b/components/prism-sass.js @@ -1,7 +1,10 @@ (function(Prism) { Prism.languages.sass = Prism.languages.extend('css', { // Sass comments don't need to be closed, only indented - 'comment': /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m + 'comment': { + pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m, + lookbehind: true + } }); Prism.languages.insertBefore('sass', 'atrule', { @@ -10,7 +13,7 @@ // Includes support for = and + shortcuts pattern: /^(?:[ \t]*)[@+=].+/m, inside: { - 'atrule': /^(?:[ \t]*)(?:@[\w-]+|[+=])/m + 'atrule': /(?:@[\w-]+|[+=])/m } } }); @@ -18,13 +21,12 @@ var variable = /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i; - var operator = /[-+]{1,2}|==?|!=|\|?\||\?|\*|\/|%/; + var operator = /[-+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/; Prism.languages.insertBefore('sass', 'property', { // We want to consume the whole line 'variable-line': { - pattern: /(^|(?:\r?\n|\r))[ \t]*\$.+/, - lookbehind: true, + pattern: /^[ \t]*\$.+/m, inside: { 'punctuation': /:/, 'variable': variable, @@ -33,8 +35,7 @@ }, // We want to consume the whole line 'property-line': { - pattern: /(^|(?:\r?\n|\r))[ \t]*(?:[^:\s]+[ ]*:.*|:[^:\s]+.*)/i, - lookbehind: true, + pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m, inside: { 'property': [ /[^:\s]+(?=\s*:)/, @@ -58,7 +59,7 @@ delete Prism.languages.sass.selector; Prism.languages.insertBefore('sass', 'punctuation', { 'selector': { - pattern: /([ \t]*).+(?:,(?:\r?\n|\r)\1[ \t]+.+)*/, + pattern: /([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/, lookbehind: true } }); diff --git a/components/prism-sass.min.js b/components/prism-sass.min.js index 8b4ea94203..085ead833a 100644 --- a/components/prism-sass.min.js +++ b/components/prism-sass.min.js @@ -1 +1 @@ -!function(e){e.languages.sass=e.languages.extend("css",{comment:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m}),e.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,inside:{atrule:/^(?:[ \t]*)(?:@[\w-]+|[+=])/m}}}),delete e.languages.sass.atrule;var a=/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i,s=/[-+]{1,2}|==?|!=|\|?\||\?|\*|\/|%/;e.languages.insertBefore("sass","property",{"variable-line":{pattern:/(^|(?:\r?\n|\r))[ \t]*\$.+/,lookbehind:!0,inside:{punctuation:/:/,variable:a,operator:s}},"property-line":{pattern:/(^|(?:\r?\n|\r))[ \t]*(?:[^:\s]+[ ]*:.*|:[^:\s]+.*)/i,lookbehind:!0,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:a,operator:s,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,delete e.languages.sass.selector,e.languages.insertBefore("sass","punctuation",{selector:{pattern:/([ \t]*).+(?:,(?:\r?\n|\r)\1[ \t]+.+)*/,lookbehind:!0}})}(Prism); \ No newline at end of file +!function(e){e.languages.sass=e.languages.extend("css",{comment:{pattern:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,lookbehind:!0}}),e.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,inside:{atrule:/(?:@[\w-]+|[+=])/m}}}),delete e.languages.sass.atrule;var a=/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i,t=/[-+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/;e.languages.insertBefore("sass","property",{"variable-line":{pattern:/^[ \t]*\$.+/m,inside:{punctuation:/:/,variable:a,operator:t}},"property-line":{pattern:/^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:a,operator:t,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,delete e.languages.sass.selector,e.languages.insertBefore("sass","punctuation",{selector:{pattern:/([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/,lookbehind:!0}})}(Prism); \ No newline at end of file