From d197c0feda1b789d6076e615273e1880282302e9 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 23 Jan 2019 19:56:13 +0700 Subject: [PATCH] fix: make syntax highlighting for md js code blocks same as for payload samples --- src/utils/highlight.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/utils/highlight.ts b/src/utils/highlight.ts index 061d05a8..07606d82 100644 --- a/src/utils/highlight.ts +++ b/src/utils/highlight.ts @@ -21,6 +21,30 @@ import 'prismjs/components/prism-swift.js'; const DEFAULT_LANG = 'clike'; +Prism.languages.insertBefore( + 'javascript', + 'string', + { + 'property string': { + pattern: /([{,]\s*)"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i, + lookbehind: true, + }, + } as any, + undefined as any, +); + +Prism.languages.insertBefore( + 'javascript', + 'punctuation', + { + property: { + pattern: /([{,]\s*)[a-z]\w*(?=\s*:)/i, + lookbehind: true, + }, + }, + undefined as any, +); + /** * map language names to Prism.js names */