enarratio-astro 0.4.3 → 0.4.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/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ every such change is listed here.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.5] - 2026-11-07
11
+
12
+ ### Changed
13
+
14
+ - Draws with Enarratio 0.9.2, whose "Show data" table scrolls in a keyboard-focusable region on narrow screens (WCAG 2.1.1, 1.4.10).
15
+
16
+ ## [0.4.4] - 2026-11-07
17
+
18
+ ### Changed
19
+
20
+ - Escapes the "could not be drawn" note itself instead of using Enarratio's `escapeHtml`, which Enarratio 0.9.0 stops exporting.
21
+ Output is unchanged, and the package works with Enarratio 0.7.3 and 0.9.0 alike.
22
+
10
23
  ## [0.4.3] - 2026-11-07
11
24
 
12
25
  ### Changed
package/dist/figure.js CHANGED
@@ -1,11 +1,21 @@
1
- import { escapeHtml } from "enarratio";
1
+ const ESCAPES = {
2
+ "&": "&",
3
+ "<": "&lt;",
4
+ ">": "&gt;",
5
+ '"': "&quot;",
6
+ "'": "&#39;",
7
+ };
8
+ /** Escapes text for HTML. Local because Enarratio no longer exports its own (0.9.0). */
9
+ function escapeText(value) {
10
+ return value.replace(/[&<>"']/g, (ch) => ESCAPES[ch] ?? ch);
11
+ }
2
12
  /**
3
13
  * The markup that goes on the page for a drawn chart, or for one that could not be drawn: the
4
14
  * chart in a wrapper (marked when it is interactive), or a note saying why.
5
15
  */
6
16
  export function chartMarkup(result, interactive) {
7
17
  if (!result.ok) {
8
- return `<p class="enarratio-chart-error" role="note">This chart could not be drawn. ${escapeHtml(result.error)}</p>`;
18
+ return `<p class="enarratio-chart-error" role="note">This chart could not be drawn. ${escapeText(result.error)}</p>`;
9
19
  }
10
20
  const mark = interactive ? " data-enarratio-interactive-chart" : "";
11
21
  return `<div class="enarratio-chart"${mark}>${result.html}</div>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enarratio-astro",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Accessible charts for Astro: a Chart component and charts in Markdown, drawn on the server by Enarratio",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@observablehq/plot": "0.6.17",
57
- "enarratio": "0.7.3",
57
+ "enarratio": "0.9.2",
58
58
  "linkedom": "0.18.14"
59
59
  },
60
60
  "peerDependencies": {
package/src/figure.ts CHANGED
@@ -1,13 +1,25 @@
1
- import { escapeHtml } from "enarratio";
2
1
  import type { ChartResult } from "./chart.js";
3
2
 
3
+ const ESCAPES: Readonly<Record<string, string>> = {
4
+ "&": "&amp;",
5
+ "<": "&lt;",
6
+ ">": "&gt;",
7
+ '"': "&quot;",
8
+ "'": "&#39;",
9
+ };
10
+
11
+ /** Escapes text for HTML. Local because Enarratio no longer exports its own (0.9.0). */
12
+ function escapeText(value: string): string {
13
+ return value.replace(/[&<>"']/g, (ch) => ESCAPES[ch] ?? ch);
14
+ }
15
+
4
16
  /**
5
17
  * The markup that goes on the page for a drawn chart, or for one that could not be drawn: the
6
18
  * chart in a wrapper (marked when it is interactive), or a note saying why.
7
19
  */
8
20
  export function chartMarkup(result: ChartResult, interactive: boolean): string {
9
21
  if (!result.ok) {
10
- return `<p class="enarratio-chart-error" role="note">This chart could not be drawn. ${escapeHtml(result.error)}</p>`;
22
+ return `<p class="enarratio-chart-error" role="note">This chart could not be drawn. ${escapeText(result.error)}</p>`;
11
23
  }
12
24
  const mark = interactive ? " data-enarratio-interactive-chart" : "";
13
25
  return `<div class="enarratio-chart"${mark}>${result.html}</div>`;