diff --git a/CHANGES.md b/CHANGES.md index 36ff62e2f3..b456d3d82a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,12 +14,17 @@ Language grammar improvements: - enh(php) Add `mixed` to list of keywords (#2997) [Ayesh][] - enh(php) Add support binary, octal, hex and scientific numerals with underscore separator support (#2997) [Ayesh][] +API: + +- enh(api) add `unregisterLanguage` method (#9999) [Antoine du Hamel][] + [Stef Levesque]: https://github.com/stef-levesque [Josh Goebel]: https://github.com/joshgoebel [John Cheung]: https://github.com/Real-John-Cheung [xDGameStudios]: https://github.com/xDGameStudios [Ayesh]: https://github.com/Ayesh [Vyron Vasileiadis]: https://github.com/fedonman +[Antoine du Hamel]: https://github.com/aduh95 ## Version 10.6.0 diff --git a/src/highlight.js b/src/highlight.js index 9caad5795e..7104e29078 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -814,6 +814,15 @@ const HLJS = function(hljs) { } } + /** + * Remove a language grammar module + * + * @param {string} languageName + */ + function unregisterLanguage(languageName) { + delete languages[languageName]; + } + /** * @returns {string[]} List of language internal names */ @@ -916,6 +925,7 @@ const HLJS = function(hljs) { initHighlighting, initHighlightingOnLoad, registerLanguage, + unregisterLanguage, listLanguages, getLanguage, registerAliases, diff --git a/types/index.d.ts b/types/index.d.ts index 825ad72301..d5caf9054f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -24,6 +24,7 @@ interface PublicApi { initHighlightingOnLoad: () => void highlightAll: () => void registerLanguage: (languageName: string, language: LanguageFn) => void + unregisterLanguage: (languageName: string) => void listLanguages: () => string[] registerAliases: (aliasList: string | string[], { languageName } : {languageName: string}) => void getLanguage: (languageName: string) => Language | undefined