Skip to content

添加 kramdown_enhancer 插件#435

Open
neveler wants to merge 7 commits intoHMCL-dev:mainfrom
neveler:link
Open

添加 kramdown_enhancer 插件#435
neveler wants to merge 7 commits intoHMCL-dev:mainfrom
neveler:link

Conversation

@neveler
Copy link
Copy Markdown
Contributor

@neveler neveler commented Mar 28, 2026

添加 kramdown_enhancer 插件

变更

  1. 移除 nokogiri 依赖项
  2. 整合 auto-alert auto-link 插件
    • 现在插件不会额外对引用块插入 “注意” “谨慎” 等粗体字样
  3. 支持 PNG、JPEG、TIFF 三种格式的图片自动生成 WEBP 格式图片
  4. 支持存在 WEBP 格式的图片优先使用 WEBP

Note

变更 3 通过引入新的依赖实现,需要注意的是该依赖仅在特定环境下方可使用。
https://github.com/le0pard/webp-ffi

Note

本 PR 中包含了手动转换为 WebP 的 GIF 文件,这些文件是在 win 平台下由 gif2webp 工具 gif2webp input.gif -o input.gif.webp 手动转换生成的。

resolve #318


https://link-docs.hmcl.workers.dev

@neveler neveler marked this pull request as ready for review April 1, 2026 05:21
@neveler neveler changed the title 重构 auto-link 插件 相对链接修复与 WebP 图片优化 Apr 1, 2026
@neveler neveler changed the title 相对链接修复与 WebP 图片优化 重构插件实现相对链接自动转换及图片资源优先 webp Apr 1, 2026
@zkitefly zkitefly requested a review from huanghongxun April 1, 2026 09:02
@neveler
Copy link
Copy Markdown
Contributor Author

neveler commented Apr 2, 2026

鉴于等待黄鱼审核可能会拉长本 PR 的审核周期,故此使用了由 drone 提供的环境变量 CI 用于判断构建环境是否启用 WEBP 以避免对 drone.yml 文件的修改。

@neveler neveler changed the title 重构插件实现相对链接自动转换及图片资源优先 webp 添加 kramdown_enhancer 插件 Apr 2, 2026
@zkitefly
Copy link
Copy Markdown
Member

zkitefly commented Apr 2, 2026

WebP.encode 所得到的产物 webp 压缩率怎么样?


自动转换 webp 后原图片文件会清除吗,这样可以减轻源服务器的储存压力吗?(有压力吗?)

@neveler
Copy link
Copy Markdown
Contributor Author

neveler commented Apr 2, 2026

WebP.encode 所得到的产物 webp 压缩率怎么样?

这个我没有统计过,不过这个压缩可以通过 quality 参数调节,我没指定默认应该是 100

https://github.com/le0pard/webp-ffi/blob/167b865e1f8f7a589cd0964fb57aae4627cfe578/lib/webp/options.rb#L47

自动转换 webp 后原图片文件会清除吗,这样可以减轻源服务器的储存压力吗?(有压力吗?)

不会清除原文件,当前是通过把 img 包在 picture 里,如浏览器不支持 webp 会自动回退到原文件。

<picture>
  <source srcset="/assets/img/docs/isolation/img1.png.webp" type="image/webp">
  <img src="/assets/img/docs/isolation/img1.png" alt="">
</picture>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

全面迁移至 Webp

2 participants