diff --git a/CHANGELOG.md b/CHANGELOG.md index 697e82468..68d313630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [12.0.4] - WIP ### Fixed - Fix crash introduced in `12.0.3` when processing strikethrough (`~~`) and similar plugins, #742. +- Avoid fenced token mutation, #745. ## [12.0.3] - 2020-12-07 @@ -550,6 +551,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed presets folder (configs -> presets). +[12.0.4]: https://github.com/markdown-it/markdown-it/compare/12.0.3...12.0.4 [12.0.3]: https://github.com/markdown-it/markdown-it/compare/12.0.2...12.0.3 [12.0.2]: https://github.com/markdown-it/markdown-it/compare/12.0.1...12.0.2 [12.0.1]: https://github.com/markdown-it/markdown-it/compare/12.0.0...12.0.1 diff --git a/lib/renderer.js b/lib/renderer.js index d19b95449..5a173fe7d 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -60,7 +60,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) { } // If language exists, inject class gently, without modifying original token. - // May be, one day we will add .clone() for token and simplify this part, but + // May be, one day we will add .deepClone() for token and simplify this part, but // now we prefer to keep things local. if (info) { i = token.attrIndex('class'); @@ -69,6 +69,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) { if (i < 0) { tmpAttrs.push([ 'class', options.langPrefix + langName ]); } else { + tmpAttrs[i] = tmpAttrs[i].slice(); tmpAttrs[i][1] += ' ' + options.langPrefix + langName; }