Skip to content

Commit

Permalink
fix: exclude_languages does not work in code blocks (#5088)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Oct 27, 2022
1 parent e9e9885 commit 4d760fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/plugins/tag/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ module.exports = ctx => function codeTag(args, content) {
languageAttr: typeof language_attr === 'boolean' ? language_attr : hljsCfg.language_attr
};

if (Array.isArray(hljsCfg.exclude_languages) && hljsCfg.exclude_languages.includes(hljsOption.lang)) {
// Only wrap with <pre><code class="lang"></code></pre>
hljsOption.wrap = false;
hljsOption.gutter = false;
hljsOption.autoDetect = false;
}

if (!highlight) highlight = require('hexo-util').highlight;

content = highlight(content, hljsOption);
Expand Down

0 comments on commit 4d760fe

Please sign in to comment.