.properties: Use `key`, `value` for token names; `attr-name`, `attr-value` as aliases (#3377)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
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.