From 21a55ba408728af8b5a5d2687fb6690c2fc92bad Mon Sep 17 00:00:00 2001 From: Carla Goncalves Date: Fri, 6 Dec 2024 12:22:25 +0100 Subject: [PATCH] Update type --- src/theme/prism-prisma.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/theme/prism-prisma.js b/src/theme/prism-prisma.js index 497181e6ca..9cf6785db0 100644 --- a/src/theme/prism-prisma.js +++ b/src/theme/prism-prisma.js @@ -1,6 +1,6 @@ Prism.languages.prisma = Prism.languages.extend("clike", { - keyword: /\b(?:datasource|enum|generator|model|view)\b/, - "type-class-name": /(\s+)[A-Z]\w+/, ///(\b)(\s+)[A-Z]\w+/ + keyword: /\b(?:datasource|enum|generator|model|view)\b/, // Removed `type` from here + "type-class-name": /(\s+)[A-Z]\w+/, }); Prism.languages.javascript["class-name"][0].pattern = @@ -18,8 +18,25 @@ Prism.languages.insertBefore("prisma", "punctuation", { "type-args": /\b(?:references|fields|onDelete|onUpdate):/, }); +// Match `type` and the name in type definitions separately. +Prism.languages.insertBefore("prisma", "keyword", { + "type-definition": { + pattern: /(^|\s)type\s+\w+\s*(?=\{)/, + lookbehind: true, + inside: { + keyword: /^type/, // Highlight `type` as keyword + "type-class-name": /\b\w+\b/, // Highlight `Address` as type-class-name + }, + }, +}); + +// Add `type` to plain text (not as a keyword) in other contexts. Prism.languages.insertBefore("prisma", "type-class-name", { - "not-class": /\n(\s+)[A-Z]\w+/, + "plain-type": { + pattern: /(\bmodel\b.*\btype\s+)[A-Z]\w*/, + lookbehind: true, + alias: null, // Ensures it's treated as plain text + }, }); Prism.languages.json5 = Prism.languages.js;