@link-assistant/web-capture 1.10.7 → 1.10.8

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
@@ -1,5 +1,14 @@
1
1
  # @link-assistant/web-capture
2
2
 
3
+ ## 1.10.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 8cee5e4: Keep JS/Rust kreuzberg parity for the html-to-markdown 3.6 image dimensions
8
+ change (issue #137). Export `normalizeStructuredKeys` and add regression tests
9
+ asserting inline image `dimensions` are exposed as `{ width, height }`, mirroring
10
+ the Rust `inline_image_to_json` fix.
11
+
3
12
  ## 1.10.7
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/web-capture",
3
- "version": "1.10.7",
3
+ "version": "1.10.8",
4
4
  "description": "CLI and microservice to render web pages as HTML, Markdown, or PNG",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/kreuzberg.js CHANGED
@@ -39,7 +39,19 @@ function toSnakeCase(key) {
39
39
  return key.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
40
40
  }
41
41
 
42
- function normalizeStructuredKeys(value) {
42
+ /**
43
+ * Recursively normalize object keys to snake_case.
44
+ *
45
+ * Used to give the structured `metadata`, `tables`, and `images` payloads a
46
+ * stable shape regardless of the casing the native binding emits. In
47
+ * particular, inline image `dimensions` are exposed as `{ width, height }` —
48
+ * mirroring the Rust `inline_image_to_json` mapping after the
49
+ * html-to-markdown 3.6 `ImageDimensions` change (see issue #137).
50
+ *
51
+ * @param {*} value - Value to normalize
52
+ * @returns {*} The value with all object keys converted to snake_case
53
+ */
54
+ export function normalizeStructuredKeys(value) {
43
55
  if (Array.isArray(value)) {
44
56
  return value.map(normalizeStructuredKeys);
45
57
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  convertWithKreuzberg,
3
3
  isKreuzbergAvailable,
4
+ normalizeStructuredKeys,
4
5
  } from '../../src/kreuzberg.js';
5
6
 
6
7
  let available;
@@ -207,3 +208,42 @@ describe('kreuzberg html-to-markdown integration', () => {
207
208
  expect(result.content).toContain('Item 3');
208
209
  });
209
210
  });
211
+
212
+ describe('kreuzberg structured key normalization (issue #137 parity)', () => {
213
+ // Mirrors the Rust `inline_image_to_json` regression tests: after the
214
+ // html-to-markdown 3.6 change, inline image dimensions are a structured
215
+ // `{ width, height }` value rather than a tuple. The normalization pipeline
216
+ // that backs `result.images` must preserve those `width`/`height` keys.
217
+ it('preserves width/height keys on inline image dimensions', () => {
218
+ const images = normalizeStructuredKeys([
219
+ {
220
+ format: 'png',
221
+ filename: 'pixel.png',
222
+ description: 'one pixel',
223
+ dimensions: { width: 800, height: 600 },
224
+ source: 'ImgDataUri',
225
+ },
226
+ ]);
227
+
228
+ expect(images).toHaveLength(1);
229
+ expect(images[0].dimensions).toEqual({ width: 800, height: 600 });
230
+ expect(images[0].format).toBe('png');
231
+ expect(images[0].filename).toBe('pixel.png');
232
+ });
233
+
234
+ it('leaves images without dimensions untouched', () => {
235
+ const images = normalizeStructuredKeys([
236
+ { format: 'svg', source: 'SvgElement', dimensions: null },
237
+ ]);
238
+
239
+ expect(images[0].dimensions).toBeNull();
240
+ });
241
+
242
+ it('snake_cases nested structured keys', () => {
243
+ const normalized = normalizeStructuredKeys({
244
+ openGraph: { siteName: 'Example' },
245
+ });
246
+
247
+ expect(normalized).toEqual({ open_graph: { site_name: 'Example' } });
248
+ });
249
+ });