-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from qiusyan-projects/main
新增功能:为 Markdown 内容中的 <del> 标签添加遮罩效果
- Loading branch information
Showing
5 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* delete mask */ | ||
|
||
"use strict"; | ||
|
||
hexo.extend.filter.register( | ||
"after_post_render", | ||
function (data) { | ||
const theme = this.theme; | ||
|
||
// 处理del标签的代码 | ||
const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[^])*)<\/del>/g; | ||
|
||
data.content = data.content.replace( | ||
regPureDelTag, | ||
function (match, html) { | ||
// 只有在配置为true时才添加mask类 | ||
if (theme.config.articles.style.delete_mask === true) { | ||
return `<del class="mask">${html}</del>`; | ||
} | ||
return match; | ||
} | ||
); | ||
|
||
return data; | ||
}, | ||
0 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters