diff --git a/components/prism-graphql.js b/components/prism-graphql.js index efc61c3447..d276c3f4c0 100644 --- a/components/prism-graphql.js +++ b/components/prism-graphql.js @@ -28,7 +28,7 @@ Prism.languages.graphql = { greedy: true }, 'class-name': { - pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/, + pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*)[a-zA-Z_]\w*/, lookbehind: true }, 'fragment': { @@ -36,8 +36,8 @@ Prism.languages.graphql = { lookbehind: true, alias: 'function' }, - 'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/, - 'operator': /[!=|]|\.{3}/, + 'keyword': /\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/, + 'operator': /[!=|&]|\.{3}/, 'punctuation': /[!(){}\[\]:=,]/, 'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/ }; diff --git a/components/prism-graphql.min.js b/components/prism-graphql.min.js index df6e5aee6b..00b1dfc53a 100644 --- a/components/prism-graphql.min.js +++ b/components/prism-graphql.min.js @@ -1 +1 @@ -Prism.languages.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,greedy:!0,alias:"string",inside:{"language-markdown":{pattern:/(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,lookbehind:!0,inside:Prism.languages.markdown}}},string:{pattern:/"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":{pattern:/[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,greedy:!0},"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,lookbehind:!0,alias:"function"},keyword:/\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,operator:/[!=|]|\.{3}/,punctuation:/[!(){}\[\]:=,]/,constant:/\b(?!ID\b)[A-Z][A-Z_\d]*\b/}; \ No newline at end of file +Prism.languages.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,greedy:!0,alias:"string",inside:{"language-markdown":{pattern:/(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,lookbehind:!0,inside:Prism.languages.markdown}}},string:{pattern:/"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":{pattern:/[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,greedy:!0},"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*)[a-zA-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,lookbehind:!0,alias:"function"},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[!=|&]|\.{3}/,punctuation:/[!(){}\[\]:=,]/,constant:/\b(?!ID\b)[A-Z][A-Z_\d]*\b/}; \ No newline at end of file diff --git a/tests/languages/graphql/class-name_feature.test b/tests/languages/graphql/class-name_feature.test index 6ac1e29933..1680bafd44 100644 --- a/tests/languages/graphql/class-name_feature.test +++ b/tests/languages/graphql/class-name_feature.test @@ -1,6 +1,7 @@ interface Foo {} type Foo {} type Foo implements Bar {} +type Business implements NamedEntity & ValuedEntity {} enum Foo {} scalar Foo union Foo @@ -26,6 +27,15 @@ on Foo {} ["punctuation", "{"], ["punctuation", "}"], + ["keyword", "type"], + ["class-name", "Business"], + ["keyword", "implements"], + ["class-name", "NamedEntity"], + ["operator", "&"], + ["class-name", "ValuedEntity"], + ["punctuation", "{"], + ["punctuation", "}"], + ["keyword", "enum"], ["class-name", "Foo"], ["punctuation", "{"], @@ -45,4 +55,4 @@ on Foo {} ---------------------------------------------------- -Checks for class names. \ No newline at end of file +Checks for class names. diff --git a/tests/languages/graphql/keyword_feature.test b/tests/languages/graphql/keyword_feature.test index 9d30f88dfa..c22834121b 100644 --- a/tests/languages/graphql/keyword_feature.test +++ b/tests/languages/graphql/keyword_feature.test @@ -1,33 +1,57 @@ -enum -fragment -implements -input -interface -mutation -on -query -scalar -schema -type -union +directive, +enum, +extend, +fragment, +implements, +input, +interface, +mutation, +on, +query, +repeatable, +scalar, +schema, +subscription, +type, +union, ---------------------------------------------------- [ + ["keyword", "directive"], + ["punctuation", ","], ["keyword", "enum"], - ["class-name", "fragment"], + ["punctuation", ","], + ["keyword", "extend"], + ["punctuation", ","], + ["keyword", "fragment"], + ["punctuation", ","], ["keyword", "implements"], - ["class-name", "input"], + ["punctuation", ","], + ["keyword", "input"], + ["punctuation", ","], ["keyword", "interface"], - ["class-name", "mutation"], + ["punctuation", ","], + ["keyword", "mutation"], + ["punctuation", ","], ["keyword", "on"], - ["class-name", "query"], + ["punctuation", ","], + ["keyword", "query"], + ["punctuation", ","], + ["keyword", "repeatable"], + ["punctuation", ","], ["keyword", "scalar"], - ["class-name", "schema"], + ["punctuation", ","], + ["keyword", "schema"], + ["punctuation", ","], + ["keyword", "subscription"], + ["punctuation", ","], ["keyword", "type"], - ["class-name", "union"] + ["punctuation", ","], + ["keyword", "union"], + ["punctuation", ","] ] ---------------------------------------------------- -Checks for keywords. \ No newline at end of file +Checks for keywords. diff --git a/tests/languages/graphql/operator_feature.test b/tests/languages/graphql/operator_feature.test index c19fe7393e..465ad30258 100644 --- a/tests/languages/graphql/operator_feature.test +++ b/tests/languages/graphql/operator_feature.test @@ -1,4 +1,4 @@ -= ! | += ! | & ... ---------------------------------------------------- @@ -7,9 +7,10 @@ ["operator", "="], ["operator", "!"], ["operator", "|"], + ["operator", "&"], ["operator", "..."] ] ---------------------------------------------------- -Checks for operators. \ No newline at end of file +Checks for operators.