[opt] image.parse_markdown

This commit is contained in:
xaoxuu 2023-05-09 13:17:36 +08:00
parent 4195a103a6
commit 372a382bb0
2 changed files with 6 additions and 9 deletions

View File

@ -239,9 +239,9 @@ tag_plugins:
blobcat: https://gcore.jsdelivr.net/gh/norevi/waline-blobcatemojis@1.0/blobs/${name}.png blobcat: https://gcore.jsdelivr.net/gh/norevi/waline-blobcatemojis@1.0/blobs/${name}.png
# {% image %} # {% image %}
image: image:
fancybox: # true, false fancybox: false # true, false
replace_original: #把markdown格式的图片解析成图片标签 parse_markdown: true # 把 markdown 格式的图片解析成图片标签
enable: false
# {% timeline %} # {% timeline %}
timeline: timeline:
max-height: 80vh max-height: 80vh

View File

@ -4,12 +4,9 @@ hexo.extend.filter.register('after_render:html', require('./lib/img_lazyload').p
hexo.extend.filter.register('after_render:html', require('./lib/img_onerror').processSite); hexo.extend.filter.register('after_render:html', require('./lib/img_onerror').processSite);
function change_image(data) { function change_image(data) {
const cfg = this.theme.config.tag_plugins.image.replace_original; if (this.theme.config.tag_plugins.image.parse_markdown) {
if (cfg.enable){
data.content = data.content.replace(/!\[([^\]]*)]\(([^(]+)\)/g, '{% image $2 $1 %}'); data.content = data.content.replace(/!\[([^\]]*)]\(([^(]+)\)/g, '{% image $2 $1 %}');
} }
return data; return data;
} }