From 1ff4648d0563998b7dbe56dc6a9dcd4ccebac9e8 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 03:35:28 +0100 Subject: [PATCH] feat(graphql): treat block strings as markdown --- src/graphql/graphql.test.ts | 10 ++-------- src/graphql/graphql.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts index 99cc4464..20f112b4 100644 --- a/src/graphql/graphql.test.ts +++ b/src/graphql/graphql.test.ts @@ -100,15 +100,9 @@ testTokenization('graphql', [ ], }, { - line: 'Node interface', + line: 'This is MarkDown', tokens: [ - { startIndex: 0, type: "string.gql" } - ], - }, - { - line: '- allows (re)fetch arbitrary entity only by ID', - tokens: [ - { startIndex: 0, type: "string.gql" } + { startIndex: 0, type: "" } ], }, { diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index 95620114..2799971f 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -115,14 +115,19 @@ export const language = { // delimiter: after number because of .\d floats [/[;,.]/, 'delimiter'], - [/"""/, 'string', '@mlstring'], + [/"""/, + { token: 'string', next: '@mlstring', nextEmbedded: 'markdown' } + ], // strings [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }], ], - mlstring: [[/[^"]+/, 'string'], ['"""', 'string', '@pop']], + mlstring: [ + [/[^"]+/, 'string'], + ['"""', { token: 'string', next: '@pop', nextEmbedded: '@pop' }] + ], string: [ [/[^\\"]+/, 'string'],