Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/13677

Vanessa1ee7848f93bb
diff --git a/app/src/protyle/render/highlightRender.ts b/app/src/protyle/render/highlightRender.ts
index 4af5ecef2d..585d36c900 100644
--- a/app/src/protyle/render/highlightRender.ts
+++ b/app/src/protyle/render/highlightRender.ts
@@ -138,8 +138,9 @@ export const lineNumberRender = (block: HTMLElement) => {
const lineNumberTemp = document.createElement("div");
lineNumberTemp.className = "hljs";
+ // 不能使用 codeElement.clientWidth,被忽略小数点导致宽度不一致
lineNumberTemp.setAttribute("style", `padding-left:${codeElement.style.paddingLeft};
-width: ${codeElement.clientWidth}px;
+width: ${codeElement.getBoundingClientRect().width}px;
white-space:${codeElement.style.whiteSpace};
word-break:${codeElement.style.wordBreak};
font-variant-ligatures:${codeElement.style.fontVariantLigatures};