Skip to content

Commit b2c40e3

Browse files
authored
Use languageId as key in prism generator (#1617)
Signed-off-by: Christian Dietrich <[email protected]>
1 parent d122afc commit b2c40e3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/langium-cli/src/generator/highlighting/prism-generator.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
******************************************************************************/
66
import { GrammarAST, type Grammar, GrammarUtils, RegExpUtils } from 'langium';
77
import { expandToNode, joinToNode, toString, type Generated } from 'langium/generate';
8-
import _ from 'lodash';
98
import type { LangiumLanguageConfig } from '../../package-types.js';
109
import { collectKeywords } from '../langium-util.js';
1110

@@ -47,17 +46,17 @@ export function generatePrismHighlighting(grammar: Grammar, config: LangiumLangu
4746
pattern: `/\\b(${filteredKeywords.join('|')})\\b/${modifier}`
4847
};
4948

50-
return generate(highlighter, grammar.name ?? 'unknown');
49+
return generate(highlighter, config.id);
5150
}
5251

53-
function generate(highlighter: PrismHighlighter, grammarName: string): string {
52+
function generate(highlighter: PrismHighlighter, languageId: string): string {
5453
/* eslint-disable @typescript-eslint/indent */
5554
return toString(
5655
expandToNode`
5756
// This file is generated using a best effort guess for your language.
5857
// It is not guaranteed contain all expected prism syntax highlighting rules.
5958
// For more documentation, take a look at https://prismjs.com/extending.html'
60-
Prism.languages.${_.camelCase(grammarName)} = {
59+
Prism.languages["${languageId}"] = {
6160
${joinToNode(
6261
Object.entries(highlighter),
6362
([name, value]) => {

0 commit comments

Comments
 (0)