Skip to content

Commit

Permalink
Avoid conflict between line-highlight and other plugins
Browse files Browse the repository at this point in the history
The line-highlight plugin should not overwrite env.code, because other
plugins (e.g. normalize-whitespace) might have modified it.
  • Loading branch information
zeitgeist87 committed Feb 13, 2017
1 parent 79b723d commit 224fdb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion plugins/line-highlight/prism-line-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,16 @@ Prism.hooks.add('before-sanity-check', function(env) {
* to cleanup any left-over tags, because the whitespace inside of the <div>
* tags change the content of the <code> tag.
*/
var num = 0;
$$('.line-highlight', pre).forEach(function (line) {
num += line.textContent.length;
line.parentNode.removeChild(line);
});

env.code = env.element.textContent;
// Remove extra whitespace
if (num && /^( \n)+$/.test(env.code.slice(-num))) {
env.code = env.code.slice(0, -num);
}
});

Prism.hooks.add('complete', function(env) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/line-highlight/prism-line-highlight.min.js

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

0 comments on commit 224fdb8

Please sign in to comment.