Skip to content

Conversation

@scfrazer
Copy link

This PR is in reference to issue #504 . What is happening is:

  • Another library is using the slim version of diff2html
  • Here in getLanguage() it returns all mappings of extensions to language type
  • But here in the slim version not all possible language types are loaded into highlight.js (using Django as an example)
  • Then here in the base UI the mapping two steps back is used to choose language type
  • Now many file types are mapped, but only some are loaded into HLJS, so HLJS may be passed a file type it doesn't know about. The result is an exception that ends up causing problems in the library that is using diff2html.

So my solution below is to check if the language is known (has a map entry), but HLJS doesn't know about it, in which case you fall back to plaintext.

@rtfpessoa
Copy link
Owner

Thank you for looking into it. I got what you meant.
I detected a problem in your logic and issued a fixed version that I locally tested.
Fix here https://github.com/rtfpessoa/diff2html/pull/506|
Closing this PR in favor of the other one.

@rtfpessoa rtfpessoa closed this Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants