@@ -54,11 +54,16 @@ const textIsHighlightDirective = (text, commentWrapper) => directive =>
5454/**
5555 * @param {Record<string, (message: string) => string> } languageCommentMap user-defined object mapping language keys to commenting functions
5656 * @param {Record<string, string> } languageAliases
57- * @param {* } grammarCache
57+ * @param {GatsbyCache } cache
5858 */
59- function createHighlightDirectiveLineTransformer ( languageCommentMap , languageAliases , grammarCache ) {
59+ function createHighlightDirectiveLineTransformer ( languageCommentMap , languageAliases , cache ) {
60+ let grammarCache ;
6061 /** @type {LineTransformer<HighlightCommentTransfomerState> } */
61- const transformer = ( { line, language, state } ) => {
62+ const transformer = async ( { line, language, state } ) => {
63+ if ( ! grammarCache ) {
64+ grammarCache = await cache . get ( 'grammars' ) ;
65+ }
66+
6267 const scope = getScope ( language , grammarCache , languageAliases ) ;
6368 const commentWrapper = getCommentForLanguage ( language , scope , languageCommentMap ) ;
6469 const isDirective = textIsHighlightDirective ( line . text , commentWrapper ) ;
@@ -101,7 +106,7 @@ function createHighlightDirectiveLineTransformer(languageCommentMap, languageAli
101106
102107 transformer . displayName = 'highlightCommentDirective' ;
103108 transformer . schemaExtension = `
104- type GRVSCLine {
109+ type GRVSCTokenizedLine {
105110 isHighlighted: Boolean
106111 }
107112 ` ;
0 commit comments