Skip to content

Commit

Permalink
9.18.5
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Nov 19, 2020
1 parent c34318b commit f54e96c
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 11 deletions.
25 changes: 25 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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.**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ it can be added manually:
```html
<script
charset="UTF-8"
src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.4/languages/go.min.js"></script>
src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.5/languages/go.min.js"></script>
```

**On Almond.** You need to use the optimizer to give the module a name. For
Expand Down
9 changes: 6 additions & 3 deletions deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ ${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}
https://github.com/highlightjs/highlight.js/issues/2877
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)
}
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 20 additions & 4 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit f54e96c

Please sign in to comment.