Skip to content

Commit

Permalink
.properties: Use key, value for token names; attr-name, `attr-v…
Browse files Browse the repository at this point in the history
…alue` as aliases (#3377)
  • Loading branch information
hoonweiting committed Mar 9, 2022
1 parent 8a843a1 commit b94a664
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
10 changes: 7 additions & 3 deletions 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': /[=:]/
};
2 changes: 1 addition & 1 deletion components/prism-properties.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions tests/languages/properties/key_value_feature.test
Expand Up @@ -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.
Checks for keys and values.

0 comments on commit b94a664

Please sign in to comment.