From cd2f9f4e7f8b4e3741e2bcd9adddb747f2ae150b Mon Sep 17 00:00:00 2001 From: boboqun Date: Fri, 23 Jan 2026 12:05:51 +0800 Subject: [PATCH 1/5] fix(docs): improve mkdocs admonition compatibility and robustness - normalize admonition types to lowercase (e.g., `!!! Note` -> `::: note`) to match VitePress custom container expectations. - automatically strip dangling code fences from admonition content to prevent rendering errors caused by malformed markdown (e.g., in `docs/coil/compose.md`). Solution: - Replaced the fixed `height` on `.card` with `min-height` to allow cards to grow dynamically with their content. - Added a `line-height` to `.cardTitle` to ensure multi-line titles are legible. - Introduced media queries (`@media`) to: - Decrease `padding` within `.cardContent` on smaller screens. - Scale down `font-size` for titles and descriptions on mobile viewports for a more balanced layout. --- docs/.vitepress/markdown-it-mk-admonitions.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/markdown-it-mk-admonitions.ts b/docs/.vitepress/markdown-it-mk-admonitions.ts index 269e5a97a..2a5707269 100644 --- a/docs/.vitepress/markdown-it-mk-admonitions.ts +++ b/docs/.vitepress/markdown-it-mk-admonitions.ts @@ -21,7 +21,7 @@ export default function markdownItMkAdmonition(md) { if (match) { const leadingWhitespace = match[1] || ''; // Whitespace before !!! - const type = match[2]; + const type = match[2].toLowerCase(); const title = match[3] || ''; // Title content, or empty string if not present const content = []; @@ -59,6 +59,25 @@ export default function markdownItMkAdmonition(md) { admonitionContentStartIndex = j + 1; // Update line counter } + + // Fix for dangling code fences (e.g., incorrect indentation in original MD) + // If content has an odd number of code fences, and the last line is a fence, remove it. + let fenceCount = 0; + for (const line of content) { + if (line.trim().startsWith('```') || line.trim().startsWith('~~~')) { + fenceCount++; + } + } + + if (fenceCount % 2 !== 0 && content.length > 0) { + const lastLineIndex = content.length - 1; + const lastLine = content[lastLineIndex].trim(); + if (lastLine.startsWith('```') || lastLine.startsWith('~~~')) { + // Remove the dangling fence + content.splice(lastLineIndex, 1); + } + } + if (hasActualContent) { // Construct VitePress container newLines.push(`${leadingWhitespace}::: ${type}${title ? ' ' + title.trim() : ''}`); @@ -67,6 +86,7 @@ export default function markdownItMkAdmonition(md) { })); newLines.push(`${leadingWhitespace}:::`); i = admonitionContentStartIndex; // Move master index past processed admonition + } else { // No valid content found, treat as regular line newLines.push(currentLine); From 41c6230a68fa004c54441299c7e9124284dba3cf Mon Sep 17 00:00:00 2001 From: boboqun Date: Mon, 26 Jan 2026 09:14:21 +0800 Subject: [PATCH 2/5] fix(docs): enhance mkdocs admonition support for unicode and stability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Relax regex to `\S+` to support non-ASCII admonition types (e.g., `!!! 注意`). - Add specific mapping for `!!! 注意` to render as `::: note 注意`. - Normalize standard admonition types to lowercase (e.g., `!!! Note` -> `::: note`). - Automatically strip dangling code fences from admonition content to fix rendering issues in files like `docs/coil/compose.md`. --- docs/.vitepress/markdown-it-mk-admonitions.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/.vitepress/markdown-it-mk-admonitions.ts b/docs/.vitepress/markdown-it-mk-admonitions.ts index 2a5707269..32fcf5ddb 100644 --- a/docs/.vitepress/markdown-it-mk-admonitions.ts +++ b/docs/.vitepress/markdown-it-mk-admonitions.ts @@ -10,10 +10,10 @@ export default function markdownItMkAdmonition(md) { // Regex to find the start of an MKDocs admonition // ^(\s*)!!! - Start of line, optional leading whitespace (capture 1), then !!! // \s+ - One or more spaces - // (\w+) - The admonition type (e.g., note, warning) (capture 2) + // (\S+) - The admonition type (non-whitespace characters) (capture 2) // (?:\s+"([^"]*)")? - Optional: space, then a quoted title (capture 3 is the title content) // \s*$ - Optional trailing whitespace, end of line - const admonitionStartRegex = /^(\s*)!!!\s+(\w+)(?:\s+"([^"]*)")?\s*$/; + const admonitionStartRegex = /^(\s*)!!!\s+(\S+)(?:\s+"([^"]*)")?\s*$/; while (i < lines.length) { const currentLine = lines[i]; @@ -21,8 +21,18 @@ export default function markdownItMkAdmonition(md) { if (match) { const leadingWhitespace = match[1] || ''; // Whitespace before !!! - const type = match[2].toLowerCase(); - const title = match[3] || ''; // Title content, or empty string if not present + let type = match[2]; + let title = match[3] || ''; // Title content, or empty string if not present + + // Handle Chinese '注意' mapping + if (type === '注意') { + type = 'note'; + if (!title) { + title = '注意'; + } + } else { + type = type.toLowerCase(); + } const content = []; let admonitionContentStartIndex = i + 1; From 44f5a45fcc952156d2311f1b706620135a2d098b Mon Sep 17 00:00:00 2001 From: boboqun Date: Tue, 10 Feb 2026 10:27:29 +0800 Subject: [PATCH 3/5] feat: improve MkDocs tabs support in VitePress - Refactor `markdown-it-mk-code-tabs` plugin to generate direct `` and `` HTML tags instead of `::: tabs` containers, aligning with the manual syntax used in other documentation files. - Fix nested tabs support by flattening indentation of generated HTML tags, preventing `markdown-it` from parsing them as code blocks. - Fix fenced code block rendering (e.g., `bash`) inside tabs by correctly calculating and applying output indentation relative to the parent container. - Fix parsing of subsequent markdown blocks (e.g., `!!! note`) by ensuring a blank line is inserted after closing a `` group. - Enhance [Tabs.vue](cci:7://file:///Users/bobo/Documents/GitHub/Open-Docs-fork/docs/.vitepress/component/Tabs.vue:0:0-0:0) component robustness: - Update child filtering logic to explicitly exclude Text, Comment, and Fragment nodes, ensuring all valid tab components are rendered. - Add safe navigation for tab titles to prevent runtime errors. --- docs/.vitepress/component/Tabs.vue | 8 +- docs/.vitepress/config/markdown.config.ts | 22 ++ docs/.vitepress/markdown-it-mk-code-tabs.ts | 272 ++++++++++++-------- 3 files changed, 186 insertions(+), 116 deletions(-) diff --git a/docs/.vitepress/component/Tabs.vue b/docs/.vitepress/component/Tabs.vue index 44e6acfb5..845c935a6 100644 --- a/docs/.vitepress/component/Tabs.vue +++ b/docs/.vitepress/component/Tabs.vue @@ -1,10 +1,12 @@