@uniweb/semantic-parser 1.0.13 → 1.0.14

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/README.md CHANGED
@@ -322,10 +322,30 @@ Inline formatting is preserved as HTML tags:
322
322
  // Input: Text with bold mark
323
323
  // Output: "Text with <strong>bold</strong>"
324
324
 
325
+ // Input: Text with italic mark
326
+ // Output: "Text with <em>emphasis</em>"
327
+
325
328
  // Input: Link mark
326
329
  // Output: "Click <a href=\"/docs\">here</a>"
330
+
331
+ // Input: Span mark (bracketed spans)
332
+ // Output: "This is <span class=\"highlight\">highlighted</span> text"
327
333
  ```
328
334
 
335
+ ### Span Marks
336
+
337
+ Bracketed spans (`[text]{.class}`) are converted to `<span>` elements with their attributes:
338
+
339
+ ```js
340
+ // Input mark
341
+ { type: "span", attrs: { class: "highlight", id: "note-1" } }
342
+
343
+ // Output HTML
344
+ '<span class="highlight" id="note-1">text</span>'
345
+ ```
346
+
347
+ Spans can have classes, IDs, and custom attributes. They combine with other marks—a span with bold becomes `<strong><span class="...">text</span></strong>`.
348
+
329
349
  ## Documentation
330
350
 
331
351
  - **[Content Writing Guide](./docs/guide.md)**: Learn how to structure content for optimal parsing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/semantic-parser",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Semantic parser for ProseMirror/TipTap content structures",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -282,6 +282,26 @@ function getTextContent(content, options = {}) {
282
282
  styledText = `<span style="background-color: var(--highlight)">${styledText}</span>`;
283
283
  }
284
284
 
285
+ // span (bracketed spans with class/id/attributes)
286
+ if (marks.some((mark) => mark.type === "span")) {
287
+ const spanMark = marks.find((mark) => mark.type === "span");
288
+ const attrs = spanMark?.attrs || {};
289
+ const attrParts = [];
290
+
291
+ if (attrs.class) attrParts.push(`class="${attrs.class}"`);
292
+ if (attrs.id) attrParts.push(`id="${attrs.id}"`);
293
+
294
+ // Add any other custom attributes (data-*, etc.)
295
+ for (const [key, value] of Object.entries(attrs)) {
296
+ if (key !== 'class' && key !== 'id') {
297
+ attrParts.push(`${key}="${value}"`);
298
+ }
299
+ }
300
+
301
+ const attrString = attrParts.length > 0 ? ` ${attrParts.join(' ')}` : '';
302
+ styledText = `<span${attrString}>${styledText}</span>`;
303
+ }
304
+
285
305
  // bold
286
306
  if (marks.some((mark) => mark.type === "bold")) {
287
307
  styledText = `<strong>${styledText}</strong>`;