diff --git a/CHANGES.md b/CHANGES.md index f784a645a8..10a40b6464 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,28 @@ +## Release v9.18.5 + +**Version 9 has reached end-of-support and will not receive future updates or fixes.** + +Please see [VERSION_10_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md) and perhaps [SECURITY.md](https://github.com/highlightjs/highlight.js/blob/master/SECURITY.md). + +- enh: Post-install script can be disabled with `HLJS_HIDE_UPGRADE_WARNING=yes` +- fix: Deprecation notice logged at library startup a `console.log` vs `console.warn`. + - Notice only shown if actually highlighting code, not just requiring the library. + - Node.js treats `warn` the same as `error` and that was problematic. + - You (or perhaps your indirect dependency) may disable the notice with + the `hideUpgradeWarningAcceptNoSupportOrSecurityUpdates` option + - You can also set `HLJS_HIDE_UPGRADE_WARNING=yes` in your envionment to disable the warning + +Example: + +```js +hljs.configure({ + hideUpgradeWarningAcceptNoSupportOrSecurityUpdates: true +}) +``` + +Reference: +https://github.com/highlightjs/highlight.js/issues/2877 + ## Release v9.18.4 **Version 9 has reached end-of-support and will not receive future updates or fixes.** diff --git a/README.md b/README.md index 20fffa8f33..daa854acd5 100644 --- a/README.md +++ b/README.md @@ -362,7 +362,7 @@ it can be added manually: ```html + src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.5/languages/go.min.js"> ``` **On Almond.** You need to use the optimizer to give the module a name. For diff --git a/deprecated.js b/deprecated.js index 2f85d059a6..9ae57158c5 100644 --- a/deprecated.js +++ b/deprecated.js @@ -12,7 +12,8 @@ ${BgRed + FgWhite} ${Reset}${Bright}${FgWhite} Verion 9 of Highlight.js has reached EOL. It will no longer be supported or receive security updates in the future. - Please upgrade to version 10. + Please upgrade to version 10 or encourage your indirect + dependencies to do so. For more info: ${FgBlue} @@ -20,6 +21,8 @@ ${Reset}${Bright}${FgWhite} https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md ${BgRed + FgWhite} -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*${Reset} -.`.trim() +`.trim() -console.log(DEPRECATION) +if (!process.env["HLJS_HIDE_UPGRADE_WARNING"]) { + console.log(DEPRECATION) +} diff --git a/docs/conf.py b/docs/conf.py index c5558a7c27..0d5f28ac39 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,7 +50,7 @@ # The short X.Y version. version = '9.18' # The full version, including alpha/beta/rc tags. -release = '9.18.4' +release = '9.18.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/package-lock.json b/package-lock.json index 15b2cf1a1c..2f06d67356 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "highlight.js", - "version": "9.18.4", + "version": "9.18.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 31b8b4ced3..79a4ae78c1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "syntax" ], "homepage": "https://highlightjs.org/", - "version": "9.18.4", + "version": "9.18.5", "author": { "name": "Ivan Sagalaev", "email": "maniac@softwaremaniacs.org" diff --git a/src/highlight.js b/src/highlight.js index 207faa3bcc..b6f2a52d13 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -28,10 +28,7 @@ https://highlightjs.org/ } }(function(hljs) { - - var warn = console.warn || console.log; - warn("Version 9 of Highlight.js has reached EOL and is no longer supported. Please upgrade to version 10."); - + var showedUpgradeWarning = false; // Convenience variables for build-in objects var ArrayProto = [], @@ -60,6 +57,7 @@ https://highlightjs.org/ // Global options used when within external APIs. This is modified when // calling the `hljs.configure` function. var options = { + hideUpgradeWarningAcceptNoSupportOrSecurityUpdates: false, classPrefix: 'hljs-', tabReplace: null, useBR: false, @@ -518,6 +516,13 @@ https://highlightjs.org/ compileMode(language); } + function hideUpgradeWarning() { + if (options.hideUpgradeWarningAcceptNoSupportOrSecurityUpdates) + return true; + + if (typeof process === "object" && typeof process.env === "object" && process.env["HLJS_HIDE_UPGRADE_WARNING"]) + return true; + } /** * Core highlighting function. @@ -535,6 +540,17 @@ https://highlightjs.org/ * @property {boolean} illegal - indicates whether any illegal matches were found */ function highlight(languageName, code, ignore_illegals, continuation) { + if (!hideUpgradeWarning()) { + if (!showedUpgradeWarning) { + showedUpgradeWarning = true; + console.log( + "Version 9 of Highlight.js has reached EOL and is no longer supported.\n" + + "Please upgrade or ask whatever dependency you are using to upgrade.\n" + + "https://github.com/highlightjs/highlight.js/issues/2877" + ); + } + } + var codeToHighlight = code; function escapeRe(value) {