Skip to content
Permalink
Browse files
JS: Added properties (#3099)
  • Loading branch information
RunDevelopment committed Oct 10, 2021
1 parent 3f24dc7 commit 3b2238fa8ffd81f25e638468d0260045a72b9bfd
@@ -4,6 +4,10 @@ Prism.languages.actionscript = Prism.languages.extend('javascript', {
});
Prism.languages.actionscript['class-name'].alias = 'function';

// doesn't work with AS because AS is too complex
delete Prism.languages.actionscript['parameter'];
delete Prism.languages.actionscript['literal-property'];

if (Prism.languages.markup) {
Prism.languages.insertBefore('actionscript', 'string', {
'xml': {

Some generated files are not rendered by default. Learn more.

@@ -98,9 +98,23 @@ Prism.languages.insertBefore('javascript', 'string', {
},
'string': /[\s\S]+/
}
},
'string-property': {
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
lookbehind: true,
greedy: true,
alias: 'property'
}
});

Prism.languages.insertBefore('javascript', 'operator', {
'literal-property': {
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
lookbehind: true,
alias: 'property'
},
});

if (Prism.languages.markup) {
Prism.languages.markup.tag.addInlined('script', 'javascript');

Some generated files are not rendered by default. Learn more.

@@ -4,6 +4,7 @@

// doesn't work with TS because TS is too complex
delete Prism.languages.tsx['parameter'];
delete Prism.languages.tsx['literal-property'];

// This will prevent collisions between TSX tags and TS generic types.
// Idea by https://github.com/karlhorky

Some generated files are not rendered by default. Learn more.

@@ -21,6 +21,7 @@

// doesn't work with TS because TS is too complex
delete Prism.languages.typescript['parameter'];
delete Prism.languages.typescript['literal-property'];

// a version of typescript specifically for highlighting types
var typeInside = Prism.languages.extend('typescript', {});

Some generated files are not rendered by default. Learn more.

@@ -1647,9 +1647,23 @@ Prism.languages.insertBefore('javascript', 'string', {
},
'string': /[\s\S]+/
}
},
'string-property': {
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
lookbehind: true,
greedy: true,
alias: 'property'
}
});

Prism.languages.insertBefore('javascript', 'operator', {
'literal-property': {
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
lookbehind: true,
alias: 'property'
},
});

if (Prism.languages.markup) {
Prism.languages.markup.tag.addInlined('script', 'javascript');

@@ -47,66 +47,66 @@ transfer-encoding: chunked
["application-json", [
["punctuation", "{"],

["string", "\"id\""],
["string-property", "\"id\""],
["operator", ":"],
["number", "1"],
["punctuation", ","],

["string", "\"name\""],
["string-property", "\"name\""],
["operator", ":"],
["string", "\"John Doe\""],
["punctuation", ","],

["string", "\"userName\""],
["string-property", "\"userName\""],
["operator", ":"],
["string", "\"jdoe\""],
["punctuation", ","],

["string", "\"email\""],
["string-property", "\"email\""],
["operator", ":"],
["string", "\"whatever@something.zzz\""],
["punctuation", ","],

["string", "\"phone\""],
["string-property", "\"phone\""],
["operator", ":"],
["string", "\"1234567890\""],
["punctuation", ","],

["string", "\"birthDate\""],
["string-property", "\"birthDate\""],
["operator", ":"],
["string", "\"1878-05-06\""],
["punctuation", ","],

["string", "\"address\""],
["string-property", "\"address\""],
["operator", ":"],
["punctuation", "{"],

["string", "\"street\""],
["string-property", "\"street\""],
["operator", ":"],
["string", "\"Fake St\""],
["punctuation", ","],

["string", "\"street2\""],
["string-property", "\"street2\""],
["operator", ":"],
["string", "\"Apt. 556\""],
["punctuation", ","],

["string", "\"city\""],
["string-property", "\"city\""],
["operator", ":"],
["string", "\"Gwenborough\""],
["punctuation", ","],

["string", "\"state\""],
["string-property", "\"state\""],
["operator", ":"],
["string", "\"ZZ\""],
["punctuation", ","],

["string", "\"zip\""],
["string-property", "\"zip\""],
["operator", ":"],
["string", "\"12345\""],

["punctuation", "}"],

["punctuation", "}"]
]]
]
]
@@ -57,10 +57,10 @@ class Test {
["punctuation", "("],
["parameter", [
["punctuation", "{"],
" props",
["literal-property", "props"],
["operator", ":"],
["punctuation", "{"],
" a",
["literal-property", "a"],
["operator", ":"],
" _A",
["punctuation", ","],
@@ -43,18 +43,16 @@ a = function () {}, b = () => {}
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],
["punctuation","}"],
["punctuation","}"],
["punctuation", "}"],
["punctuation", "}"],

["function-variable", "bar"],
["operator", "="],
["keyword", "async"],
["keyword", "function"],
["function", "baz"],
["punctuation", "("],
["parameter", [
"x"
]],
["parameter", ["x"]],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
@@ -63,18 +61,16 @@ a = function () {}, b = () => {}
["operator", "="],
["keyword", "async"],
["punctuation", "("],
["parameter", [
"x"
]],
["parameter", ["x"]],
["punctuation", ")"],
["operator", "=>"], " x\r\n",
["operator", "=>"],
" x\r\n",

["function-variable", "fooBar"],
["operator", "="],
["parameter", [
"x"
]],
["operator", "=>"], " x\r\n",
["parameter", ["x"]],
["operator", "=>"],
" x\r\n",

["function-variable", "fooBar"],
["operator", "="],
@@ -85,7 +81,8 @@ a = function () {}, b = () => {}
" y"
]],
["punctuation", ")"],
["operator", "=>"], " x\r\n",
["operator", "=>"],
" x\r\n",

["function-variable", "ಠ_ಠ"],
["operator", "="],
@@ -118,10 +115,10 @@ a = function () {}, b = () => {}
["punctuation", "("],
["parameter", [
["punctuation", "{"],
" props",
["literal-property", "props"],
["operator", ":"],
["punctuation", "{"],
" a",
["literal-property", "a"],
["operator", ":"],
" _A",
["punctuation", ","],

0 comments on commit 3b2238f

Please sign in to comment.