Skip to content

Commit

Permalink
fix: Markdown base64 image (#206)
Browse files Browse the repository at this point in the history
* bugfix: Markdown base64编码图片支持

修复Markdown中内置base64编码图片的解析错误问题

* style: format code with prettier

---------

Co-authored-by: Isla <bot@nn.ci>
  • Loading branch information
CplusHua and HsuBot authored Dec 9, 2024
1 parent cbea0e0 commit 9254a9f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export function Markdown(props: {
content = content.replace(/!\[.*?\]\((.*?)\)/g, (match) => {
const name = match.match(/!\[(.*?)\]\(.*?\)/)![1]
let url = match.match(/!\[.*?\]\((.*?)\)/)![1]
// 检查是否为 base64 编码的图片
if (url.startsWith("data:image/")) {
return match // 如果是 base64 编码的图片,直接返回原标签
}
if (
url.startsWith("http://") ||
url.startsWith("https://") ||
Expand Down

0 comments on commit 9254a9f

Please sign in to comment.