Skip to content

Conversation

sharavananpa
Copy link
Contributor

References:

Basically, the diff-{language} identifier wasn't working.

Looks like the problem was in the PrismLoader.js where we set Prism.languages[ fullLanguageName ] to PrismDiff which will always be an empty object, since prism-diff.js contains just a IIFE that doesn't return anything and only add the diff loader object inside Prism.languages (global object).

So, I've set Prism.languages[ fullLanguageName ] to Prism.languages.diff which returns the proper grammar that is received in markdownSyntaxHighlightOptions.js to call the Prism.highlight(str, loader, language) method.

Note:

  • I think we don't even have to set Prism.languages[ fullLanguageName ] since it will be created for us in the hooks that are run when calling the Prism.highlight() method. But I've refrained from directly returning the diff loader speculating it could have another utility and I didn't want to break things.
  • There were existing test cases that covered this scenario but I think they got omitted since they had the .mjs file extension. Having these cases could've prevented the bug from getting in.
  • Lastly I think the test files could use some refactoring. I'm interested in doing that. Do let me know if you want me to do that!

@zachleat zachleat added this to the Syntax Highlight v5.0.2 milestone Aug 1, 2025
@zachleat zachleat merged commit 6f64cf8 into 11ty:main Aug 1, 2025
@zachleat
Copy link
Member

zachleat commented Aug 1, 2025

Appreciate this PR so much! Yeah, if you want to take a swing at some test refactoring or general cleanup here, feel free!

@zachleat
Copy link
Member

zachleat commented Aug 1, 2025

Shipping with v5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants