修复图片不显示
自动部署 / deploy (push) Successful in 3m44s

This commit is contained in:
biss committed 2026-06-19 14:53:59 +08:00
1 parent 5f0dbe05d7
commit e290f8fa04
5 files changed
+85 -7

No files matched your search

@@ -17,6 +17,7 @@ date: 2026-04-02 04:52:16
# 安装Visual Studio
现在我们先来安装`Visual Studio`:[visual studio](https://visualstudio.microsoft.com/zh-hans/vs/),下载后安装即可|在安装时选择“使用C++的桌面开发”,这样安装时就会安装C++的编译器了。
![](https://pic.biss.click/image/2d3be78a-320f-41de-8773-e2fd7a2af66e.webp)
# 安装 Cmake
+2
View File
@@ -18,6 +18,8 @@ tags:
![日历](https://pic.biss.click/image/124f7862-e8dc-45e8-b9fa-73de58381234.jpg)
当然开源版固件功能有点少,又不想买烧录器自己折腾,所以把自己想要的功能写成网页:
目前写了待办事项和倒计时,生成图片后上传
{% link 生成图,tu,https://letters.biss.click/gen/ %}
![待办事项](https://pic.biss.click/image/1b1c3f2c-fe42-4844-b681-f4b463900c1a.jpg)
![倒计时](https://pic.biss.click/image/66ea88ef-15c0-40bd-9f2d-6973266e3a01.webp)
+73
View File
@@ -251,6 +251,60 @@ function transformBlockTags(children) {
}
}
function splitMixedTagParagraph(node) {
if (node?.type !== 'paragraph' || !Array.isArray(node.children)) return [node];
if (!node.children.some((child) => child.type === 'image')) return [node];
const source = node.children.map(inlineToSource).join('');
if (!hexoTagPattern.test(source)) return [node];
hexoTagPattern.lastIndex = 0;
const result = [];
let currentChildren = [];
const flushParagraph = () => {
if (currentChildren.length === 0) return;
result.push({ type: 'paragraph', children: currentChildren });
currentChildren = [];
};
for (const child of node.children) {
if (child.type !== 'text' || typeof child.value !== 'string') {
currentChildren.push(child);
continue;
}
const pattern = new RegExp(hexoTagPattern);
let lastIndex = 0;
let match;
while ((match = pattern.exec(child.value))) {
const before = child.value.slice(lastIndex, match.index);
if (before) currentChildren.push({ type: 'text', value: before });
flushParagraph();
result.push({ type: 'html', value: renderTag(match[1], match[2]) });
lastIndex = pattern.lastIndex;
}
const after = child.value.slice(lastIndex);
if (after) currentChildren.push({ type: 'text', value: after });
}
flushParagraph();
return result.length > 0 ? result : [node];
}
function transformMixedTagParagraphs(children) {
for (let index = 0; index < children.length; index += 1) {
const replacement = splitMixedTagParagraph(children[index]);
if (replacement.length === 1 && replacement[0] === children[index]) continue;
children.splice(index, 1, ...replacement);
index += replacement.length - 1;
}
}
function inlineToSource(node) {
if (node.type === 'text' || node.type === 'inlineCode') return node.value ?? '';
@@ -259,6 +313,12 @@ function inlineToSource(node) {
return `[${text}](${node.url})`;
}
if (node.type === 'image') {
const alt = node.alt ?? '';
const title = node.title ? ` "${node.title}"` : '';
return `![${alt}](${node.url}${title})`;
}
if (Array.isArray(node.children)) return node.children.map(inlineToSource).join('');
return '';
}
@@ -267,12 +327,25 @@ function visit(node) {
if (!node || typeof node !== 'object') return;
if (Array.isArray(node.children)) transformBlockTags(node.children);
if (Array.isArray(node.children)) transformMixedTagParagraphs(node.children);
if (node.type === 'paragraph' && Array.isArray(node.children)) {
const source = node.children.map(inlineToSource).join('');
const transformed = transformText(source);
if (transformed !== source) {
if (node.children.some((child) => child.type === 'image')) {
node.children = node.children.map((child) => {
if (child.type !== 'text' || typeof child.value !== 'string') return child;
const childTransformed = transformText(child.value);
if (childTransformed === child.value) return child;
return { type: 'html', value: childTransformed };
});
return;
}
node.type = 'html';
node.value = transformed;
delete node.children;
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more