@uniweb/build 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/site/xref-registry.js +40 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@uniweb/theming": "0.1.3"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
+
"@uniweb/runtime": "0.8.7",
|
|
61
62
|
"@uniweb/content-reader": "1.1.7",
|
|
62
|
-
"@uniweb/runtime": "0.8.6",
|
|
63
63
|
"@uniweb/schemas": "0.2.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@tailwindcss/vite": "^4.0.0",
|
|
70
70
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
71
71
|
"vite-plugin-svgr": "^4.0.0",
|
|
72
|
-
"@uniweb/core": "0.7.
|
|
72
|
+
"@uniweb/core": "0.7.6"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
75
75
|
"vite": {
|
|
@@ -33,9 +33,19 @@
|
|
|
33
33
|
* counter, // number for flat kinds, dotted string for hierarchical
|
|
34
34
|
* counterText, // displayable counter ('3', '3.2')
|
|
35
35
|
* sourcePath, // page route the id was declared on (for back-refs)
|
|
36
|
+
* caption, // (figures, tables) caption attr, when set
|
|
37
|
+
* text, // (sections) heading's plain text content
|
|
38
|
+
* latex, // (equations) latex source for the equation
|
|
36
39
|
* },
|
|
37
40
|
* },
|
|
38
41
|
* }
|
|
42
|
+
*
|
|
43
|
+
* `caption`, `text`, and `latex` are populated only for the elements
|
|
44
|
+
* that carry them — they're undefined on other kinds. List sections
|
|
45
|
+
* (ListOfFigures / ListOfTables / TableOfContents) read these to render
|
|
46
|
+
* "Figure 3 — A diagram of mitosis ........ 47" entries without
|
|
47
|
+
* re-walking the document tree. Other consumers (the framework's <Ref>
|
|
48
|
+
* component, Typst / LaTeX cross-reference emitters) ignore them.
|
|
39
49
|
*/
|
|
40
50
|
|
|
41
51
|
const KIND_BY_TYPE = {
|
|
@@ -82,6 +92,19 @@ export function buildXrefRegistry(siteContent, options = {}) {
|
|
|
82
92
|
return sectionStack.slice().join('.')
|
|
83
93
|
}
|
|
84
94
|
|
|
95
|
+
// Collect the plain text content of a node tree — used to capture a
|
|
96
|
+
// heading's displayable text for ListOfSections-style entries. Walks
|
|
97
|
+
// the standard ProseMirror text shape (text nodes carry `.text`;
|
|
98
|
+
// structural nodes recurse via `.content`).
|
|
99
|
+
function collectTextContent(node) {
|
|
100
|
+
if (!node || typeof node !== 'object') return ''
|
|
101
|
+
if (node.type === 'text' && typeof node.text === 'string') return node.text
|
|
102
|
+
if (Array.isArray(node.content)) {
|
|
103
|
+
return node.content.map(collectTextContent).join('')
|
|
104
|
+
}
|
|
105
|
+
return ''
|
|
106
|
+
}
|
|
107
|
+
|
|
85
108
|
function inferKind(node) {
|
|
86
109
|
// 1. Node-type-based: built-ins.
|
|
87
110
|
const builtin = KIND_BY_TYPE[node.type]
|
|
@@ -125,7 +148,23 @@ export function buildXrefRegistry(siteContent, options = {}) {
|
|
|
125
148
|
counter = nextFlat(kind)
|
|
126
149
|
counterText = String(counter)
|
|
127
150
|
}
|
|
128
|
-
|
|
151
|
+
const entry = { id, kind, counter, counterText, sourcePath: sourcePath || '' }
|
|
152
|
+
// Per-kind metadata. List sections (ListOfFigures, ListOfTables,
|
|
153
|
+
// TableOfContents) read these directly so they don't have to
|
|
154
|
+
// re-walk the parsed tree to find captions and headings.
|
|
155
|
+
const captionAttr = node.attrs?.caption
|
|
156
|
+
if (kind === 'figure' || kind === 'table') {
|
|
157
|
+
if (captionAttr) entry.caption = String(captionAttr)
|
|
158
|
+
}
|
|
159
|
+
if (node.type === 'heading') {
|
|
160
|
+
const text = collectTextContent(node)
|
|
161
|
+
if (text) entry.text = text
|
|
162
|
+
}
|
|
163
|
+
if (node.type === 'math_display') {
|
|
164
|
+
const latex = node.attrs?.latex
|
|
165
|
+
if (latex) entry.latex = String(latex)
|
|
166
|
+
}
|
|
167
|
+
entries[id] = entry
|
|
129
168
|
}
|
|
130
169
|
} else if (node.type === 'heading') {
|
|
131
170
|
// Heading without an id still advances the counter — but we don't
|