Skip to content

Commit

Permalink
fix: #927 对style的过滤没有兼容单引号的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Oct 8, 2024
1 parent 216b759 commit 25d3b0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/scripts/index-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ var basicConfig = {
customResourceURL: 'https://github.githubassets.com/images/icons/emoji/unicode/${code}.png?v8',
upperCase: false,
},
// htmlBlock: {
// filterStyle: true,
// }
// toc: {
// tocStyle: 'nested'
// }
Expand Down
3 changes: 2 additions & 1 deletion src/core/hooks/HtmlBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default class HtmlBlock extends ParagraphBase {
$str = $str.replace(/\$#60;/g, '<').replace(/\$#62;/g, '>');
// 过滤HTML标签的style属性
if (this.filterStyle) {
$str = $str.replace(/<([^/][^>]+?) style="[^"]+"([^>]*)>/gi, '<$1$2>');
$str = $str.replace(/<([^/][^>]+?) style="[^>\n]+?"([^>\n]*)>/gi, '<$1$2>');
$str = $str.replace(/<([^/][^>]+?) style='[^>\n]+?'([^>\n]*)>/gi, '<$1$2>');
}
return $str;
}
Expand Down

0 comments on commit 25d3b0c

Please sign in to comment.