@cube-drone/marquee-html-renderer 0.3.0 → 0.5.0

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/dist/render.js CHANGED
@@ -323,6 +323,33 @@ function directive(name, attrs, nodes, ctx) {
323
323
  // only inside the other two, which is exactly when you want it).
324
324
  // Physical directions, deliberately: predictable beats logical.
325
325
  return `<div class="mq-${name}">${inner}</div>`;
326
+ case "spoiler":
327
+ // The block form of the [spoiler] span: hide a whole region (an image,
328
+ // a paragraph) behind the same blur, same reveal-on-hover. Reuses the
329
+ // mq-spoiler class - the CSS is element-agnostic.
330
+ return `<div class="mq-spoiler mq-spoiler-block" tabindex="0">${inner}</div>`;
331
+ case "conflict":
332
+ // Versioned-document conflict: a container of two-or-more :::variant
333
+ // alternatives, synthesized by an embedder at read time (never authored
334
+ // by hand, never parsed back). The unknown-container shrug keeps it
335
+ // lossless on a renderer that predates it - the variants' words survive,
336
+ // stacked - so this rendering is pure presentation over that guarantee.
337
+ return `<div class="mq-conflict">${inner}</div>`;
338
+ case "variant": {
339
+ // One alternative. label/when are advisory display text, shown VERBATIM
340
+ // (reformatting a timestamp would make two renderers disagree - the
341
+ // differential-rendering hazard); role=base marks the common ancestor.
342
+ const head = [];
343
+ if (attrs["label"] !== undefined) {
344
+ head.push(`<span class="mq-variant-label">${escapeText(attrs["label"])}</span>`);
345
+ }
346
+ if (attrs["when"] !== undefined) {
347
+ head.push(`<span class="mq-variant-when">${escapeText(attrs["when"])}</span>`);
348
+ }
349
+ const cls = attrs["role"] === "base" ? "mq-variant mq-variant-base" : "mq-variant";
350
+ const headHtml = head.length === 0 ? "" : `<div class="mq-variant-head">${head.join(" ")}</div>`;
351
+ return `<div class="${cls}">${headHtml}${inner}</div>`;
352
+ }
326
353
  }
327
354
  // Unknown vocabulary: a container renders its children with an affordance
328
355
  // that something wrapped them; a leaf renders the inert placeholder.
@@ -397,6 +424,13 @@ function span(name, attrs, nodes, ctx) {
397
424
  return `<small>${inner}</small>`;
398
425
  case "big":
399
426
  return `<big>${inner}</big>`; // obsolete and eternal, like <font>
427
+ case "spoiler":
428
+ // The content is present and never eaten - just blurred, revealed on
429
+ // hover/focus (the static renderer has no JS to gate a click). An
430
+ // interactive renderer turns the same class into click-to-reveal.
431
+ // Degrades, like everything, to readable content: no stylesheet means
432
+ // a visible spoiler, which beats a hidden one.
433
+ return `<span class="mq-spoiler" tabindex="0">${inner}</span>`;
400
434
  case "size": {
401
435
  const value = attrs["size"];
402
436
  if (value !== undefined && /^[1-7]$/.test(value)) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cube-drone/marquee-html-renderer",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Reference static HTML renderer for the Marquee markup language",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/cube-drone/marqueemarkup.git",
9
- "directory": "ts/html_renderer"
9
+ "directory": "ts/marquee-html-renderer"
10
10
  },
11
11
  "type": "module",
12
12
  "engines": {
@@ -35,12 +35,12 @@
35
35
  "prepack": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
- "@cube-drone/marquee-parser": "^0.3.0"
38
+ "@cube-drone/marquee-parser": "^0.5.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@cube-drone/marquee-css": "^0.3.0",
42
- "@cube-drone/marquee-fonts": "^0.3.0",
43
- "@cube-drone/marquee-turbolink": "^0.3.0",
41
+ "@cube-drone/marquee-css": "^0.5.0",
42
+ "@cube-drone/marquee-fonts": "^0.5.0",
43
+ "@cube-drone/marquee-turbolink": "^0.5.0",
44
44
  "@types/node": "^24.0.0",
45
45
  "typescript": "^5.9.0"
46
46
  }
package/src/render.ts CHANGED
@@ -357,6 +357,33 @@ function directive(name: string, attrs: Attrs, nodes: Node[], ctx: Ctx): string
357
357
  // only inside the other two, which is exactly when you want it).
358
358
  // Physical directions, deliberately: predictable beats logical.
359
359
  return `<div class="mq-${name}">${inner}</div>`;
360
+ case "spoiler":
361
+ // The block form of the [spoiler] span: hide a whole region (an image,
362
+ // a paragraph) behind the same blur, same reveal-on-hover. Reuses the
363
+ // mq-spoiler class - the CSS is element-agnostic.
364
+ return `<div class="mq-spoiler mq-spoiler-block" tabindex="0">${inner}</div>`;
365
+ case "conflict":
366
+ // Versioned-document conflict: a container of two-or-more :::variant
367
+ // alternatives, synthesized by an embedder at read time (never authored
368
+ // by hand, never parsed back). The unknown-container shrug keeps it
369
+ // lossless on a renderer that predates it - the variants' words survive,
370
+ // stacked - so this rendering is pure presentation over that guarantee.
371
+ return `<div class="mq-conflict">${inner}</div>`;
372
+ case "variant": {
373
+ // One alternative. label/when are advisory display text, shown VERBATIM
374
+ // (reformatting a timestamp would make two renderers disagree - the
375
+ // differential-rendering hazard); role=base marks the common ancestor.
376
+ const head: string[] = [];
377
+ if (attrs["label"] !== undefined) {
378
+ head.push(`<span class="mq-variant-label">${escapeText(attrs["label"])}</span>`);
379
+ }
380
+ if (attrs["when"] !== undefined) {
381
+ head.push(`<span class="mq-variant-when">${escapeText(attrs["when"])}</span>`);
382
+ }
383
+ const cls = attrs["role"] === "base" ? "mq-variant mq-variant-base" : "mq-variant";
384
+ const headHtml = head.length === 0 ? "" : `<div class="mq-variant-head">${head.join(" ")}</div>`;
385
+ return `<div class="${cls}">${headHtml}${inner}</div>`;
386
+ }
360
387
  }
361
388
  // Unknown vocabulary: a container renders its children with an affordance
362
389
  // that something wrapped them; a leaf renders the inert placeholder.
@@ -433,6 +460,13 @@ function span(name: string, attrs: Attrs, nodes: Node[], ctx: Ctx): string {
433
460
  return `<small>${inner}</small>`;
434
461
  case "big":
435
462
  return `<big>${inner}</big>`; // obsolete and eternal, like <font>
463
+ case "spoiler":
464
+ // The content is present and never eaten - just blurred, revealed on
465
+ // hover/focus (the static renderer has no JS to gate a click). An
466
+ // interactive renderer turns the same class into click-to-reveal.
467
+ // Degrades, like everything, to readable content: no stylesheet means
468
+ // a visible spoiler, which beats a hidden one.
469
+ return `<span class="mq-spoiler" tabindex="0">${inner}</span>`;
436
470
  case "size": {
437
471
  const value = attrs["size"];
438
472
  if (value !== undefined && /^[1-7]$/.test(value)) {