Browse Source

Avoid fenced token mutation, #745

pull/747/head
Vitaly Puzrin 4 years ago
parent
commit
c9949dd585
  1. 2
      CHANGELOG.md
  2. 3
      lib/renderer.js

2
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [12.0.4] - WIP ## [12.0.4] - WIP
### Fixed ### Fixed
- Fix crash introduced in `12.0.3` when processing strikethrough (`~~`) and similar plugins, #742. - 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 ## [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). - 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.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.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 [12.0.1]: https://github.com/markdown-it/markdown-it/compare/12.0.0...12.0.1

3
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. // 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. // now we prefer to keep things local.
if (info) { if (info) {
i = token.attrIndex('class'); i = token.attrIndex('class');
@ -69,6 +69,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) {
if (i < 0) { if (i < 0) {
tmpAttrs.push([ 'class', options.langPrefix + langName ]); tmpAttrs.push([ 'class', options.langPrefix + langName ]);
} else { } else {
tmpAttrs[i] = tmpAttrs[i].slice();
tmpAttrs[i][1] += ' ' + options.langPrefix + langName; tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
} }

Loading…
Cancel
Save