Browse Source

feat(graphql): treat block strings as markdown

Pavel Lang 6 years ago
parent
commit
1ff4648d05
2 changed files with 9 additions and 10 deletions
  1. 2 8
      src/graphql/graphql.test.ts
  2. 7 2
      src/graphql/graphql.ts

+ 2 - 8
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: "" }
 			],
 		},
 		{

+ 7 - 2
src/graphql/graphql.ts

@@ -115,14 +115,19 @@ export const language = <ILanguage>{
 			// 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'],