@link-assistant/web-capture 1.7.25 → 1.7.26

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,11 @@
1
1
  # @link-assistant/web-capture
2
2
 
3
+ ## 1.7.26
4
+
5
+ ### Patch Changes
6
+
7
+ - 112f2f9: Fix `stripBase64Images` (used by `--keep-original-links`) dropping every base64 image with empty alt text instead of leaving a visible placeholder. Google Docs HTML exports emit `<img alt="" src="data:image/png;base64,...">` for every image, so the previous behaviour silently deleted all images from the rendered markdown. Empty-alt now renders as `![]()` (a valid empty image reference); non-empty alt continues to render as `*[image: <alt>]*`.
8
+
3
9
  ## 1.7.25
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/web-capture",
3
- "version": "1.7.25",
3
+ "version": "1.7.26",
4
4
  "description": "CLI and microservice to render web pages as HTML, Markdown, or PNG",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -95,9 +95,16 @@ export function extractBase64ToBuffers(markdown, imagesDir = 'images') {
95
95
  }
96
96
 
97
97
  /**
98
- * Strip base64 data URI images from markdown, leaving only the alt text
99
- * as a placeholder. Used when keepOriginalLinks is enabled — base64 images
100
- * have no original URL to restore, so we remove the heavy data URI.
98
+ * Strip base64 data URI images from markdown, leaving a visible placeholder.
99
+ * Used when keepOriginalLinks is enabled — base64 images have no original URL
100
+ * to restore, so we remove the heavy data URI but still leave a marker so the
101
+ * reader can see that an image was here.
102
+ *
103
+ * Non-empty alt becomes `*[image: <alt>]*`. Empty alt — common for Google Docs
104
+ * HTML exports, which emit `<img alt="" src="data:...">` for every image —
105
+ * becomes `![]()`, an empty markdown image reference that renderers still
106
+ * surface as a slot. Emitting `''` for empty-alt would silently delete every
107
+ * image in the document (see issue #117).
101
108
  *
102
109
  * @param {string} markdown - Markdown content with data URI images
103
110
  * @returns {{markdown: string, stripped: number}}
@@ -108,7 +115,7 @@ export function stripBase64Images(markdown) {
108
115
  BASE64_IMAGE_REGEX,
109
116
  (_match, altText) => {
110
117
  stripped++;
111
- return altText ? `*[image: ${altText}]*` : '';
118
+ return altText ? `*[image: ${altText}]*` : '![]()';
112
119
  }
113
120
  );
114
121
  return { markdown: updatedMarkdown, stripped };
@@ -204,12 +204,18 @@ describe('extract-images module', () => {
204
204
  expect(result.markdown).not.toContain('data:image');
205
205
  });
206
206
 
207
- it('strips base64 images with empty alt text', () => {
208
- const md = `![](data:image/png;base64,${TINY_PNG})`;
207
+ it('leaves a visible placeholder when stripping a base64 image with empty alt', () => {
208
+ // Google Docs HTML exports emit `<img alt="" src="data:image/png;base64,...">`,
209
+ // which renders as `![](data:...)`. If stripping drops the markdown image
210
+ // entirely, every image in the doc vanishes from the output with no
211
+ // indication that anything was lost. Leave a visible placeholder so the
212
+ // reader can see that an image was here.
213
+ const md = `Hi.\n\n![](data:image/png;base64,${TINY_PNG})\n\nBye.\n`;
209
214
  const result = stripBase64Images(md);
210
215
 
211
216
  expect(result.stripped).toBe(1);
212
- expect(result.markdown).toBe('');
217
+ expect(result.markdown).not.toMatch(/data:image/);
218
+ expect(result.markdown).toMatch(/!\[|\[image/);
213
219
  });
214
220
 
215
221
  it('preserves remote image URLs', () => {