@uniweb/content-reader 1.0.5 → 1.0.6
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 +1 -1
- package/src/parser/inline.js +19 -3
package/package.json
CHANGED
package/src/parser/inline.js
CHANGED
|
@@ -146,10 +146,19 @@ function parseInline(token, schema, removeNewLine = false) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
if (token.type === "image") {
|
|
149
|
-
let role, src;
|
|
150
|
-
|
|
149
|
+
let role, src, iconLibrary, iconName;
|
|
150
|
+
|
|
151
|
+
// Check for icon protocol prefixes (lucide:, heroicons:, etc.)
|
|
152
|
+
const iconMatch = token.href.match(/^(lucide|heroicons|phosphor|tabler|feather|icon):(.+)$/);
|
|
153
|
+
if (iconMatch) {
|
|
154
|
+
iconLibrary = iconMatch[1];
|
|
155
|
+
iconName = iconMatch[2];
|
|
156
|
+
role = "icon";
|
|
157
|
+
// For known icon libraries, use the name; for generic 'icon:', use as URL
|
|
158
|
+
src = iconLibrary === "icon" ? iconName : null;
|
|
159
|
+
}
|
|
151
160
|
// Find the first colon to handle role:url format correctly (legacy syntax)
|
|
152
|
-
if (token.href.includes(":") && !token.href.startsWith("http")) {
|
|
161
|
+
else if (token.href.includes(":") && !token.href.startsWith("http")) {
|
|
153
162
|
const colonIndex = token.href.indexOf(":");
|
|
154
163
|
role = token.href.substring(0, colonIndex);
|
|
155
164
|
src = token.href.substring(colonIndex + 1);
|
|
@@ -162,6 +171,7 @@ function parseInline(token, schema, removeNewLine = false) {
|
|
|
162
171
|
role: attrRole,
|
|
163
172
|
width,
|
|
164
173
|
height,
|
|
174
|
+
size, // Icon size (shorthand for width=height)
|
|
165
175
|
loading,
|
|
166
176
|
poster, // For videos: explicit poster image
|
|
167
177
|
preview, // For PDFs/documents: preview image
|
|
@@ -171,6 +181,7 @@ function parseInline(token, schema, removeNewLine = false) {
|
|
|
171
181
|
controls,
|
|
172
182
|
fit, // object-fit: cover, contain, etc.
|
|
173
183
|
position, // object-position
|
|
184
|
+
color, // Icon color
|
|
174
185
|
...otherAttrs
|
|
175
186
|
} = token.attrs || {};
|
|
176
187
|
|
|
@@ -185,6 +196,11 @@ function parseInline(token, schema, removeNewLine = false) {
|
|
|
185
196
|
caption: token.title || null,
|
|
186
197
|
alt: text || null,
|
|
187
198
|
role: finalRole,
|
|
199
|
+
// Icon-specific attributes
|
|
200
|
+
...(iconLibrary && iconLibrary !== "icon" && { library: iconLibrary }),
|
|
201
|
+
...(iconName && { name: iconName }),
|
|
202
|
+
...(size && { size }),
|
|
203
|
+
...(color && { color }),
|
|
188
204
|
// Dimension attributes
|
|
189
205
|
...(width && { width: parseInt(width, 10) || width }),
|
|
190
206
|
...(height && { height: parseInt(height, 10) || height }),
|