Commit b94a664db6fe3c194ee5e807bdde4bf5a2805bc6

Wei Ting 2022-03-10T02:05:35

.properties: Use `key`, `value` for token names; `attr-name`, `attr-value` as aliases (#3377)

diff --git a/components/prism-properties.js b/components/prism-properties.js
index e9e01ff..a5834fc 100644
--- a/components/prism-properties.js
+++ b/components/prism-properties.js
@@ -1,9 +1,13 @@
 Prism.languages.properties = {
 	'comment': /^[ \t]*[#!].*$/m,
-	'attr-value': {
+	'value': {
 		pattern: /(^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?: *[=:] *(?! )| ))(?:\\(?:\r\n|[\s\S])|[^\\\r\n])+/m,
-		lookbehind: true
+		lookbehind: true,
+		alias: 'attr-value'
+	},
+	'key': {
+		pattern: /^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?= *[=:]| )/m,
+		alias: 'attr-name'
 	},
-	'attr-name': /^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?= *[=:]| )/m,
 	'punctuation': /[=:]/
 };
diff --git a/components/prism-properties.min.js b/components/prism-properties.min.js
index d90930c..5976d47 100644
--- a/components/prism-properties.min.js
+++ b/components/prism-properties.min.js
@@ -1 +1 @@
-Prism.languages.properties={comment:/^[ \t]*[#!].*$/m,"attr-value":{pattern:/(^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?: *[=:] *(?! )| ))(?:\\(?:\r\n|[\s\S])|[^\\\r\n])+/m,lookbehind:!0},"attr-name":/^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?= *[=:]| )/m,punctuation:/[=:]/};
\ No newline at end of file
+Prism.languages.properties={comment:/^[ \t]*[#!].*$/m,value:{pattern:/(^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?: *[=:] *(?! )| ))(?:\\(?:\r\n|[\s\S])|[^\\\r\n])+/m,lookbehind:!0,alias:"attr-value"},key:{pattern:/^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+(?= *[=:]| )/m,alias:"attr-name"},punctuation:/[=:]/};
\ No newline at end of file
diff --git a/tests/languages/properties/key_value_feature.test b/tests/languages/properties/key_value_feature.test
index 0762a53..70ecb9e 100644
--- a/tests/languages/properties/key_value_feature.test
+++ b/tests/languages/properties/key_value_feature.test
@@ -11,26 +11,26 @@ baz
 ----------------------------------------------------
 
 [
-	["attr-name", "foo"],
-	["attr-value", "bar"],
-	["attr-name", "foo\\:\\=\\ bar"],
-	["attr-value", "bar\\:\\= \\\r\nbaz"],
+	["key", "foo"],
+	["value", "bar"],
+	["key", "foo\\:\\=\\ bar"],
+	["value", "bar\\:\\= \\\r\nbaz"],
 
-	["attr-name", "foo"],
+	["key", "foo"],
 	["punctuation", "="],
-	["attr-value", "bar"],
-	["attr-name", "foo\\:\\=\\ bar"],
+	["value", "bar"],
+	["key", "foo\\:\\=\\ bar"],
 	["punctuation", "="],
-	["attr-value", "bar\\:\\= \\\r\nbaz"],
+	["value", "bar\\:\\= \\\r\nbaz"],
 
-	["attr-name", "foo"],
+	["key", "foo"],
 	["punctuation", ":"],
-	["attr-value", "bar"],
-	["attr-name", "foo\\:\\=\\ bar"],
+	["value", "bar"],
+	["key", "foo\\:\\=\\ bar"],
 	["punctuation", ":"],
-	["attr-value", "bar\\:\\= \\\r\nbaz"]
+	["value", "bar\\:\\= \\\r\nbaz"]
 ]
 
 ----------------------------------------------------
 
-Checks for keys and values.
\ No newline at end of file
+Checks for keys and values.