Skip to content

Commit

Permalink
Update type
Browse files Browse the repository at this point in the history
  • Loading branch information
carlagn committed Dec 6, 2024
1 parent b310395 commit 21a55ba
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/theme/prism-prisma.js
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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;

0 comments on commit 21a55ba

Please sign in to comment.