Commit e64713b578

e64713b57884b1270caf68db2ea771e5901e0858

parent: 947b36e062

Unsigned

taskylizard <75871323+taskylizard@users.noreply.github.com> · 2026-05-29 13:18 UTC

add invisible headings for search

Layout: unified · split

docs/.vitepress/configs/markdown/index.ts +54 −8
@@ -18,8 +18,8 @@ import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
18import { getTooltip } from '../../utils/tooltips' 18import { getTooltip } from '../../utils/tooltips'
19import { headersPlugin } from '../markdown/headers' 19import { headersPlugin } from '../markdown/headers'
20import { emojiRender } from './emoji' 20import { emojiRender } from './emoji'
21import markdownSteps from './steps'
22import { scrapeTablePlugin } from './scrapeTablePlugin' 21import { scrapeTablePlugin } from './scrapeTablePlugin'
22import markdownSteps from './steps'
23 23
24export function configureMarkdown(md: MarkdownRenderer) { 24export function configureMarkdown(md: MarkdownRenderer) {
25 md.use(emojiRender) 25 md.use(emojiRender)
@@ -98,17 +98,63 @@ function span(
98function renderHighlight(md: MarkdownRenderer) { 98function renderHighlight(md: MarkdownRenderer) {
99 const original = md.render.bind(md) 99 const original = md.render.bind(md)
100 md.render = (src, env) => { 100 md.render = (src, env) => {
101 const withCollapsibleHeadings = injectCollapsibleSearchHeadings(src)
102
101 // Replace [||text||](url) — linked pill 103 // Replace [||text||](url) — linked pill
102 let replaced = src.replace(/\[([!x]?)\|\|(.+?)\|\|\]\((.+?)\)/g, (_, prefix, cont, url) => { 104 let replaced = withCollapsibleHeadings.replace(
103 const variant = prefix === '!' ? 'warning' : prefix === 'x' ? 'danger' : 'default' 105 /\[([!x]?)\|\|(.+?)\|\|\]\((.+?)\)/g,
104 const inner = md.renderInline(cont, env) 106 (_, prefix, cont, url) => {
105 return `<a href="${url}" target="_blank" rel="noopener noreferrer"><hl variant="${variant}" linked="true">${inner}</hl></a>` 107 const variant = prefix === '!'
106 }) 108 ? 'warning'
109 : prefix === 'x'
110 ? 'danger'
111 : 'default'
112 const inner = md.renderInline(cont, env)
113 return `<a href="${url}" target="_blank" rel="noopener noreferrer"><hl variant="${variant}" linked="true">${inner}</hl></a>`
114 }
115 )
107 // Replace standalone ||text|| 116 // Replace standalone ||text||
108 replaced = replaced.replace(/([!x]?)\|\|(.+?)\|\|/g, (_, prefix, cont) => { 117 replaced = replaced.replace(/([!x]?)\|\|(.+?)\|\|/g, (_, prefix, cont) => {
109 const variant = prefix === '!' ? 'warning' : prefix === 'x' ? 'danger' : 'default' 118 const variant = prefix === '!'
119 ? 'warning'
120 : prefix === 'x'
121 ? 'danger'
122 : 'default'
110 return `<hl variant="${variant}">${md.renderInline(cont, env)}</hl>` 123 return `<hl variant="${variant}">${md.renderInline(cont, env)}</hl>`
111 }) 124 })
112 return original(replaced, env) 125 return original(replaced, env)
113 } 126 }
114}\ No newline at end of file 127}
128
129function injectCollapsibleSearchHeadings(src: string) {
130 const lines = src.split('\n')
131
132 for (let i = 0; i < lines.length; i++) {
133 const match = lines[i].match(
134 /^(\s*)<Collapsible\b(?=[^>]*\btitle=(['"])(.*?)\2)[^>]*>\s*$/i
135 )
136 if (!match) continue
137
138 let nextLine = i + 1
139 while (nextLine < lines.length && lines[nextLine].trim() === '') {
140 nextLine++
141 }
142
143 if (/^#{1,6}\s+/.test(lines[nextLine]?.trim() ?? '')) continue
144
145 const [, indent, , title] = match
146 const headingTitle = title.trim()
147 if (!headingTitle) continue
148
149 lines.splice(
150 i + 1,
151 0,
152 '',
153 `${indent}### ${headingTitle} {.collapsible-search-heading}`,
154 ''
155 )
156 i += 3
157 }
158
159 return lines.join('\n')
160}
docs/.vitepress/theme/constants.ts −1
@@ -5,7 +5,6 @@ import type { Options } from './types'
5import _VPFlyout from 'vitepress/dist/client/theme-default/components/VPFlyout.vue' 5import _VPFlyout from 'vitepress/dist/client/theme-default/components/VPFlyout.vue'
6// @ts-ignore - VitePress doesn't have types for its internal components 6// @ts-ignore - VitePress doesn't have types for its internal components
7import _VPLocalNavOutlineDropdown from 'vitepress/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue' 7import _VPLocalNavOutlineDropdown from 'vitepress/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue'
8// Isolate the types of Vitepress internal components to avoid typecheck errors
9export const VPFlyout: any = _VPFlyout 8export const VPFlyout: any = _VPFlyout
10export const VPLocalNavOutlineDropdown: any = _VPLocalNavOutlineDropdown 9export const VPLocalNavOutlineDropdown: any = _VPLocalNavOutlineDropdown
11 10
docs/.vitepress/theme/styles/style.scss +12 −1
@@ -1648,6 +1648,17 @@ html.reduce-blur-effects {
1648 border-top: none !important; 1648 border-top: none !important;
1649} 1649}
1650 1650
1651.vp-doc .collapsible-search-heading {
1652 position: absolute;
1653 width: 1px;
1654 height: 1px;
1655 padding: 0;
1656 margin: -1px;
1657 overflow: hidden;
1658 clip: rect(0, 0, 0, 0);
1659 white-space: nowrap;
1660 border: 0;
1661}
1651 1662
1652/* noteblock icon shrinking and top-bottom padding fix */ 1663/* noteblock icon shrinking and top-bottom padding fix */
1653.vp-doc .custom-block-title { 1664.vp-doc .custom-block-title {
@@ -1663,4 +1674,4 @@ html.reduce-blur-effects {
1663 1674
1664.vp-doc .custom-block { 1675.vp-doc .custom-block {
1665 padding-bottom: 16px; 1676 padding-bottom: 16px;
1666}\ No newline at end of file 1677}
package.json −2
@@ -3,7 +3,6 @@
3 "version": "0", 3 "version": "0",
4 "type": "module", 4 "type": "module",
5 "scripts": { 5 "scripts": {
6 "typecheck": "vue-tsc --noEmit",
7 "format": "dprint fmt", 6 "format": "dprint fmt",
8 "docs:dev": "vitepress dev docs", 7 "docs:dev": "vitepress dev docs",
9 "docs:build": "NODE_OPTIONS='--max-old-space-size=8192' vitepress build docs", 8 "docs:build": "NODE_OPTIONS='--max-old-space-size=8192' vitepress build docs",
@@ -53,7 +52,6 @@
53 "vitepress": "2.0.0-alpha.12", 52 "vitepress": "2.0.0-alpha.12",
54 "vitepress-plugin-tabs": "^0.7.3", 53 "vitepress-plugin-tabs": "^0.7.3",
55 "vue": "^3.5.24", 54 "vue": "^3.5.24",
56 "vue-tsc": "^3.1.3",
57 "zod": "^4.1.11" 55 "zod": "^4.1.11"
58 }, 56 },
59 "devDependencies": { 57 "devDependencies": {
pnpm-lock.yaml −71
@@ -125,9 +125,6 @@ importers:
125 vue: 125 vue:
126 specifier: ^3.5.24 126 specifier: ^3.5.24
127 version: 3.5.24(typescript@5.6.3) 127 version: 3.5.24(typescript@5.6.3)
128 vue-tsc:
129 specifier: ^3.1.3
130 version: 3.1.3(typescript@5.6.3)
131 zod: 128 zod:
132 specifier: ^4.1.11 129 specifier: ^4.1.11
133 version: 4.1.12 130 version: 4.1.12
@@ -1542,15 +1539,6 @@ packages:
1542 vite: ^5.0.0 || ^6.0.0 || ^7.0.0 1539 vite: ^5.0.0 || ^6.0.0 || ^7.0.0
1543 vue: ^3.2.25 1540 vue: ^3.2.25
1544 1541
1545 '@volar/language-core@2.4.23':
1546 resolution: {integrity: sha512-hEEd5ET/oSmBC6pi1j6NaNYRWoAiDhINbT8rmwtINugR39loROSlufGdYMF9TaKGfz+ViGs1Idi3mAhnuPcoGQ==}
1547
1548 '@volar/source-map@2.4.23':
1549 resolution: {integrity: sha512-Z1Uc8IB57Lm6k7q6KIDu/p+JWtf3xsXJqAX/5r18hYOTpJyBn0KXUR8oTJ4WFYOcDzWC9n3IflGgHowx6U6z9Q==}
1550
1551 '@volar/typescript@2.4.23':
1552 resolution: {integrity: sha512-lAB5zJghWxVPqfcStmAP1ZqQacMpe90UrP5RJ3arDyrhy4aCUQqmxPPLB2PWDKugvylmO41ljK7vZ+t6INMTag==}
1553
1554 '@vue/babel-helper-vue-transform-on@1.5.0': 1542 '@vue/babel-helper-vue-transform-on@1.5.0':
1555 resolution: {integrity: sha512-0dAYkerNhhHutHZ34JtTl2czVQHUNWv6xEbkdF5W+Yrv5pCWsqjeORdOgbtW2I9gWlt+wBmVn+ttqN9ZxR5tzA==} 1543 resolution: {integrity: sha512-0dAYkerNhhHutHZ34JtTl2czVQHUNWv6xEbkdF5W+Yrv5pCWsqjeORdOgbtW2I9gWlt+wBmVn+ttqN9ZxR5tzA==}
1556 1544
@@ -1605,14 +1593,6 @@ packages:
1605 '@vue/devtools-shared@8.0.3': 1593 '@vue/devtools-shared@8.0.3':
1606 resolution: {integrity: sha512-s/QNll7TlpbADFZrPVsaUNPCOF8NvQgtgmmB7Tip6pLf/HcOvBTly0lfLQ0Eylu9FQ4OqBhFpLyBgwykiSf8zw==} 1594 resolution: {integrity: sha512-s/QNll7TlpbADFZrPVsaUNPCOF8NvQgtgmmB7Tip6pLf/HcOvBTly0lfLQ0Eylu9FQ4OqBhFpLyBgwykiSf8zw==}
1607 1595
1608 '@vue/language-core@3.1.3':
1609 resolution: {integrity: sha512-KpR1F/eGAG9D1RZ0/T6zWJs6dh/pRLfY5WupecyYKJ1fjVmDMgTPw9wXmKv2rBjo4zCJiOSiyB8BDP1OUwpMEA==}
1610 peerDependencies:
1611 typescript: '*'
1612 peerDependenciesMeta:
1613 typescript:
1614 optional: true
1615
1616 '@vue/reactivity@3.5.24': 1596 '@vue/reactivity@3.5.24':
1617 resolution: {integrity: sha512-BM8kBhtlkkbnyl4q+HiF5R5BL0ycDPfihowulm02q3WYp2vxgPcJuZO866qa/0u3idbMntKEtVNuAUp5bw4teg==} 1597 resolution: {integrity: sha512-BM8kBhtlkkbnyl4q+HiF5R5BL0ycDPfihowulm02q3WYp2vxgPcJuZO866qa/0u3idbMntKEtVNuAUp5bw4teg==}
1618 1598
@@ -1774,9 +1754,6 @@ packages:
1774 resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} 1754 resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
1775 engines: {node: '>= 14'} 1755 engines: {node: '>= 14'}
1776 1756
1777 alien-signals@3.1.0:
1778 resolution: {integrity: sha512-yufC6VpSy8tK3I0lO67pjumo5JvDQVQyr38+3OHqe6CHl1t2VZekKZ7EKKZSqk0cRmE7U7tfZbpXiKNzuc+ckg==}
1779
1780 ansi-regex@5.0.1: 1757 ansi-regex@5.0.1:
1781 resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} 1758 resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
1782 engines: {node: '>=8'} 1759 engines: {node: '>=8'}
@@ -2779,9 +2756,6 @@ packages:
2779 ms@2.1.3: 2756 ms@2.1.3:
2780 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} 2757 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
2781 2758
2782 muggle-string@0.4.1:
2783 resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==}
2784
2785 nanoid@3.3.11: 2759 nanoid@3.3.11:
2786 resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} 2760 resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
2787 engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} 2761 engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@@ -2903,9 +2877,6 @@ packages:
2903 resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} 2877 resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
2904 engines: {node: '>= 0.8'} 2878 engines: {node: '>= 0.8'}
2905 2879
2906 path-browserify@1.0.1:
2907 resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
2908
2909 path-key@3.1.1: 2880 path-key@3.1.1:
2910 resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 2881 resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
2911 engines: {node: '>=8'} 2882 engines: {node: '>=8'}
@@ -3654,12 +3625,6 @@ packages:
3654 peerDependencies: 3625 peerDependencies:
3655 vue: ^3.0.0 3626 vue: ^3.0.0
3656 3627
3657 vue-tsc@3.1.3:
3658 resolution: {integrity: sha512-StMNfZHwPIXQgY3KxPKM0Jsoc8b46mDV3Fn2UlHCBIwRJApjqrSwqeMYgWf0zpN+g857y74pv7GWuBm+UqQe1w==}
3659 hasBin: true
3660 peerDependencies:
3661 typescript: '>=5.0.0'
3662
3663 vue@3.5.24: 3628 vue@3.5.24:
3664 resolution: {integrity: sha512-uTHDOpVQTMjcGgrqFPSb8iO2m1DUvo+WbGqoXQz8Y1CeBYQ0FXf2z1gLRaBtHjlRz7zZUBHxjVB5VTLzYkvftg==} 3629 resolution: {integrity: sha512-uTHDOpVQTMjcGgrqFPSb8iO2m1DUvo+WbGqoXQz8Y1CeBYQ0FXf2z1gLRaBtHjlRz7zZUBHxjVB5VTLzYkvftg==}
3665 peerDependencies: 3630 peerDependencies:
@@ -4996,18 +4961,6 @@ snapshots:
4996 vite: rolldown-vite@7.2.1(@types/node@22.19.0)(esbuild@0.25.12)(jiti@2.6.1)(less@4.4.2)(sass@1.93.3)(terser@5.44.1) 4961 vite: rolldown-vite@7.2.1(@types/node@22.19.0)(esbuild@0.25.12)(jiti@2.6.1)(less@4.4.2)(sass@1.93.3)(terser@5.44.1)
4997 vue: 3.5.24(typescript@5.6.3) 4962 vue: 3.5.24(typescript@5.6.3)
4998 4963
4999 '@volar/language-core@2.4.23':
5000 dependencies:
5001 '@volar/source-map': 2.4.23
5002
5003 '@volar/source-map@2.4.23': {}
5004
5005 '@volar/typescript@2.4.23':
5006 dependencies:
5007 '@volar/language-core': 2.4.23
5008 path-browserify: 1.0.1
5009 vscode-uri: 3.1.0
5010
5011 '@vue/babel-helper-vue-transform-on@1.5.0': {} 4964 '@vue/babel-helper-vue-transform-on@1.5.0': {}
5012 4965
5013 '@vue/babel-plugin-jsx@1.5.0(@babel/core@7.28.5)': 4966 '@vue/babel-plugin-jsx@1.5.0(@babel/core@7.28.5)':
@@ -5127,18 +5080,6 @@ snapshots:
5127 dependencies: 5080 dependencies:
5128 rfdc: 1.4.1 5081 rfdc: 1.4.1
5129 5082
5130 '@vue/language-core@3.1.3(typescript@5.6.3)':
5131 dependencies:
5132 '@volar/language-core': 2.4.23
5133 '@vue/compiler-dom': 3.5.24
5134 '@vue/shared': 3.5.24
5135 alien-signals: 3.1.0
5136 muggle-string: 0.4.1
5137 path-browserify: 1.0.1
5138 picomatch: 4.0.3
5139 optionalDependencies:
5140 typescript: 5.6.3
5141
5142 '@vue/reactivity@3.5.24': 5083 '@vue/reactivity@3.5.24':
5143 dependencies: 5084 dependencies:
5144 '@vue/shared': 3.5.24 5085 '@vue/shared': 3.5.24
@@ -5240,8 +5181,6 @@ snapshots:
5240 5181
5241 agent-base@7.1.4: {} 5182 agent-base@7.1.4: {}
5242 5183
5243 alien-signals@3.1.0: {}
5244
5245 ansi-regex@5.0.1: {} 5184 ansi-regex@5.0.1: {}
5246 5185
5247 ansi-regex@6.2.2: {} 5186 ansi-regex@6.2.2: {}
@@ -6189,8 +6128,6 @@ snapshots:
6189 6128
6190 ms@2.1.3: {} 6129 ms@2.1.3: {}
6191 6130
6192 muggle-string@0.4.1: {}
6193
6194 nanoid@3.3.11: {} 6131 nanoid@3.3.11: {}
6195 6132
6196 nanoid@5.1.6: {} 6133 nanoid@5.1.6: {}
@@ -6405,8 +6342,6 @@ snapshots:
6405 6342
6406 parseurl@1.3.3: {} 6343 parseurl@1.3.3: {}
6407 6344
6408 path-browserify@1.0.1: {}
6409
6410 path-key@3.1.1: {} 6345 path-key@3.1.1: {}
6411 6346
6412 path-key@4.0.0: {} 6347 path-key@4.0.0: {}
@@ -7203,12 +7138,6 @@ snapshots:
7203 dependencies: 7138 dependencies:
7204 vue: 3.5.24(typescript@5.6.3) 7139 vue: 3.5.24(typescript@5.6.3)
7205 7140
7206 vue-tsc@3.1.3(typescript@5.6.3):
7207 dependencies:
7208 '@volar/typescript': 2.4.23
7209 '@vue/language-core': 3.1.3(typescript@5.6.3)
7210 typescript: 5.6.3
7211
7212 vue@3.5.24(typescript@5.6.3): 7141 vue@3.5.24(typescript@5.6.3):
7213 dependencies: 7142 dependencies:
7214 '@vue/compiler-dom': 3.5.24 7143 '@vue/compiler-dom': 3.5.24