Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unreadable code blocks. #312

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Do not creeate a fenced block if <pre> tag contains an image
  • Loading branch information
WetHat committed Apr 3, 2024
commit 156fde1e6b5d06d2a7304eff5dadbe06d5230917
6 changes: 5 additions & 1 deletion src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ function turndown(content, options, article) {

// handle <pre> as code blocks
turndownService.addRule('pre', {
filter: (node, tdopts) => node.nodeName == 'PRE' && (!node.firstChild || node.firstChild.nodeName != 'CODE'),
filter: (node, tdopts) => {
return node.nodeName == 'PRE'
&& (!node.firstChild || node.firstChild.nodeName != 'CODE')
&& !node.querySelector('img');
},
replacement: (content, node, tdopts) => {
return convertToFencedCodeBlock(node, tdopts);
}
Expand Down
-