From 2474f06d937e0688a115908ce1165f56e53427e2 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 22 Oct 2017 14:38:37 +0200 Subject: [PATCH] GraphQL: Regexp optimisation and simplification --- components/prism-graphql.js | 4 ++-- components/prism-graphql.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-graphql.js b/components/prism-graphql.js index 6fbe93beb1..ad7ef7a0d0 100644 --- a/components/prism-graphql.js +++ b/components/prism-graphql.js @@ -1,7 +1,7 @@ Prism.languages.graphql = { 'comment': /#.*/, 'string': { - pattern: /"(?:\\.|[^\\"])*"/, + pattern: /"(?:\\.|[^\\"\r\n])*"/, greedy: true }, 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/, @@ -14,7 +14,7 @@ Prism.languages.graphql = { 'attr-name': /[a-z_]\w*(?=\s*:)/i, 'keyword': [ { - pattern: /(fragment\s+(?!on)[a-z_]\w*\s+|\.\.\.\s*)on\b/, + pattern: /(fragment\s+(?!on)[a-z_]\w*\s+|\.{3}\s*)on\b/, lookbehind: true }, /\b(?:query|fragment|mutation)\b/ diff --git a/components/prism-graphql.min.js b/components/prism-graphql.min.js index 2658c23946..368c71bac4 100644 --- a/components/prism-graphql.min.js +++ b/components/prism-graphql.min.js @@ -1 +1 @@ -Prism.languages.graphql={comment:/#.*/,string:{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/,"boolean":/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":/[a-z_]\w*(?=\s*:)/i,keyword:[{pattern:/(fragment\s+(?!on)[a-z_]\w*\s+|\.\.\.\s*)on\b/,lookbehind:!0},/\b(?:query|fragment|mutation)\b/],operator:/!|=|\.{3}/,punctuation:/[!(){}\[\]:=,]/}; \ No newline at end of file +Prism.languages.graphql={comment:/#.*/,string:{pattern:/"(?:\\.|[^\\"\r\n])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/,"boolean":/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":/[a-z_]\w*(?=\s*:)/i,keyword:[{pattern:/(fragment\s+(?!on)[a-z_]\w*\s+|\.{3}\s*)on\b/,lookbehind:!0},/\b(?:query|fragment|mutation)\b/],operator:/!|=|\.{3}/,punctuation:/[!(){}\[\]:=,]/}; \ No newline at end of file