Commit d4bd5e7850662961d4f34cf9a6db5a5fdc1f9c10

Simon Sapin 2012-09-13T20:00:27

Fix parsing of CSS at-rules Test case: @page { size: A4 landscape; margin: 2cm } The previous *atrule* regexp matched until the `;` but it should stop at the first `{`.

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/components/prism-css.js b/components/prism-css.js
index 4f92e2f..77f94d4 100644
--- a/components/prism-css.js
+++ b/components/prism-css.js
@@ -1,6 +1,6 @@
 Prism.languages.css = {
 	'comment': /\/\*[\w\W]*?\*\//g,
-	'atrule': /@[\w-]+?(\s+.+)?(?=\s*{|\s*;)/gi,
+	'atrule': /@[\w-]+?(\s+[^;{]+)?(?=\s*{|\s*;)/gi,
 	'url': /url\((["']?).*?\1\)/gi,
 	'selector': /[^\{\}\s][^\{\}]*(?=\s*\{)/g,
 	'property': /(\b|\B)[a-z-]+(?=\s*:)/ig,