diff2html
diff2html copied to clipboard
How to highlight with a custom language and extension mapping
Hi,
I have a custom language (say foolang) registered in the hljs instance, is it possible to highlight a language that is not listed there:
https://github.com/rtfpessoa/diff2html/blob/e5c813949fcbb9a0b96ce528f49539d63cbdcf40/src/ui/js/highlight.js-helpers.ts#L164
It is properly detected in the language variable (because the extension of the filename in the diff is .foolang):
https://github.com/rtfpessoa/diff2html/blob/e5c813949fcbb9a0b96ce528f49539d63cbdcf40/src/ui/js/diff2html-ui-base.ts#L144-L145
But this code discards it for 'plaintext' since it is not listed in languagesToExt:
https://github.com/rtfpessoa/diff2html/blob/e5c813949fcbb9a0b96ce528f49539d63cbdcf40/src/ui/js/highlight.js-helpers.ts#L653-L655
It would be convenient to be able to register custom language/extension mappings.
👋 Thanks for the contribution. Left a comment in the PR.