diff2html icon indicating copy to clipboard operation
diff2html copied to clipboard

How to highlight with a custom language and extension mapping

Open quentin opened this issue 3 years ago • 1 comments

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.

quentin avatar Jun 12 '22 11:06 quentin

👋 Thanks for the contribution. Left a comment in the PR.

rtfpessoa avatar Jun 24 '22 20:06 rtfpessoa