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`:[visual studio](https://visualstudio.microsoft.com/zh-hans/vs/),下载后安装即可|在安装时选择“使用C++的桌面开发”,这样安装时就会安装C++的编译器了。
|
现在我们先来安装`Visual Studio`:[visual studio](https://visualstudio.microsoft.com/zh-hans/vs/),下载后安装即可|在安装时选择“使用C++的桌面开发”,这样安装时就会安装C++的编译器了。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# 安装 Cmake
|
# 安装 Cmake
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ tags:
|
|||||||

|

|
||||||
当然开源版固件功能有点少,又不想买烧录器自己折腾,所以把自己想要的功能写成网页:
|
当然开源版固件功能有点少,又不想买烧录器自己折腾,所以把自己想要的功能写成网页:
|
||||||
目前写了待办事项和倒计时,生成图片后上传
|
目前写了待办事项和倒计时,生成图片后上传
|
||||||
|
|
||||||
{% link 生成图,tu,https://letters.biss.click/gen/ %}
|
{% link 生成图,tu,https://letters.biss.click/gen/ %}
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
@@ -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) {
|
function inlineToSource(node) {
|
||||||
if (node.type === 'text' || node.type === 'inlineCode') return node.value ?? '';
|
if (node.type === 'text' || node.type === 'inlineCode') return node.value ?? '';
|
||||||
|
|
||||||
@@ -259,6 +313,12 @@ function inlineToSource(node) {
|
|||||||
return `[${text}](${node.url})`;
|
return `[${text}](${node.url})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.type === 'image') {
|
||||||
|
const alt = node.alt ?? '';
|
||||||
|
const title = node.title ? ` "${node.title}"` : '';
|
||||||
|
return ``;
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(node.children)) return node.children.map(inlineToSource).join('');
|
if (Array.isArray(node.children)) return node.children.map(inlineToSource).join('');
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -267,12 +327,25 @@ function visit(node) {
|
|||||||
if (!node || typeof node !== 'object') return;
|
if (!node || typeof node !== 'object') return;
|
||||||
|
|
||||||
if (Array.isArray(node.children)) transformBlockTags(node.children);
|
if (Array.isArray(node.children)) transformBlockTags(node.children);
|
||||||
|
if (Array.isArray(node.children)) transformMixedTagParagraphs(node.children);
|
||||||
|
|
||||||
if (node.type === 'paragraph' && Array.isArray(node.children)) {
|
if (node.type === 'paragraph' && Array.isArray(node.children)) {
|
||||||
const source = node.children.map(inlineToSource).join('');
|
const source = node.children.map(inlineToSource).join('');
|
||||||
const transformed = transformText(source);
|
const transformed = transformText(source);
|
||||||
|
|
||||||
if (transformed !== 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.type = 'html';
|
||||||
node.value = transformed;
|
node.value = transformed;
|
||||||
delete node.children;
|
delete node.children;
|
||||||
|
|||||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user