mdld-parse 0.8.4 → 0.9.1

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/src/shared.js CHANGED
@@ -213,7 +213,7 @@ export function calcCarrierRanges(match, baseOffset, matchStart) {
213
213
  const attrsEnd = attrsStart + match[2].length + 2; // +2 for { and }
214
214
  return {
215
215
  valueRange: [valueStart, valueEnd],
216
- attrsRange: [attrsStart + 1, attrsEnd - 1], // Exclude braces
216
+ attrsRange: [attrsStart, attrsEnd], // Include braces
217
217
  range: [baseOffset + matchStart, attrsEnd],
218
218
  pos: matchStart + match[0].length // pos should be relative to current text, not document
219
219
  };
@@ -225,13 +225,27 @@ export function extractCleanText(token) {
225
225
 
226
226
  let text = token.text;
227
227
 
228
- // Remove semantic annotations
228
+ // Remove block-level semantic annotations
229
229
  if (token.attrsRange) {
230
230
  const beforeAttrs = text.substring(0, token.attrsRange[0] - (token.range?.[0] || 0));
231
231
  const afterAttrs = text.substring(token.attrsRange[1] - (token.range?.[0] || 0));
232
232
  text = beforeAttrs + afterAttrs;
233
233
  }
234
234
 
235
+ // Remove inline carrier annotations
236
+ const carriers = token._carriers || [];
237
+ const inlineRanges = carriers
238
+ .filter(carrier => carrier.attrsRange)
239
+ .map(carrier => carrier.attrsRange.map(pos => pos - (token.range?.[0] || 0)))
240
+ .filter(([start, end]) => start >= 0 && end <= text.length)
241
+ .sort((a, b) => b[0] - a[0]);
242
+
243
+ for (const [relativeStart, relativeEnd] of inlineRanges) {
244
+ const before = text.substring(0, relativeStart);
245
+ const after = text.substring(relativeEnd);
246
+ text = before + after;
247
+ }
248
+
235
249
  // Clean based on token type
236
250
  switch (token.type) {
237
251
  case 'heading':
package/src/utils.js CHANGED
@@ -293,8 +293,8 @@ export function shortenIRI(iri, ctx) {
293
293
 
294
294
  // Token pattern definitions for semantic block parsing
295
295
  const TOKEN_PATTERNS = {
296
- '=#': { kind: 'fragment', extract: t => t.substring(2) },
297
- '+#': { kind: 'softFragment', extract: t => t.substring(2) },
296
+ '=#': { kind: 'fragment', extract: t => t.substring(2).replace('}', '') },
297
+ '+#': { kind: 'softFragment', extract: t => t.substring(2).replace('}', '') },
298
298
  '+': { kind: 'object', extract: t => t.substring(1) },
299
299
  '^^': { kind: 'datatype', extract: t => t.substring(2) },
300
300
  '@': { kind: 'language', extract: t => t.substring(1) },