Fix diff-{language} highlighting #94 #95
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References:
Basically, the diff-{language} identifier wasn't working.
Looks like the problem was in the
PrismLoader.js
where we setPrism.languages[ fullLanguageName ]
toPrismDiff
which will always be an empty object, sinceprism-diff.js
contains just a IIFE that doesn't return anything and only add thediff
loader object insidePrism.languages
(global object).So, I've set
Prism.languages[ fullLanguageName ]
toPrism.languages.diff
which returns the proper grammar that is received inmarkdownSyntaxHighlightOptions.js
to call thePrism.highlight(str, loader, language)
method.Note:
Prism.languages[ fullLanguageName ]
since it will be created for us in the hooks that are run when calling thePrism.highlight()
method. But I've refrained from directly returning thediff
loader speculating it could have another utility and I didn't want to break things..mjs
file extension. Having these cases could've prevented the bug from getting in.