Skip to content

Commit

Permalink
Use languageId as key in prism generator
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <[email protected]>
  • Loading branch information
cdietrich committed Aug 5, 2024
1 parent d122afc commit 69813aa
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
******************************************************************************/
import { GrammarAST, type Grammar, GrammarUtils, RegExpUtils } from 'langium';
import { expandToNode, joinToNode, toString, type Generated } from 'langium/generate';
import _ from 'lodash';
import type { LangiumLanguageConfig } from '../../package-types.js';
import { collectKeywords } from '../langium-util.js';

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

return generate(highlighter, grammar.name ?? 'unknown');
return generate(highlighter, config.id);
}

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

0 comments on commit 69813aa

Please sign in to comment.