diff --git a/README.md b/README.md index 94574e98..4a08a7e7 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na Example -Mask +Mask maskImagelinear-gradient(...), radial-gradient(...), url(...)Example maskPositionSupportedExample maskSizeSupport two-value size i.e. `10px 20%`Example diff --git a/src/text/index.ts b/src/text/index.ts index 9204d787..9eb199c8 100644 --- a/src/text/index.ts +++ b/src/text/index.ts @@ -264,7 +264,6 @@ export default async function* buildTextNodes( } if (forceBreak || willWrap) { // Start a new line, spaces can be ignored. - // @TODO Lack of support for Japanese spacing if (shouldCollapseTabsAndSpaces && word === Space) { w = 0 } diff --git a/src/text/processor.ts b/src/text/processor.ts index 17784155..8260db91 100644 --- a/src/text/processor.ts +++ b/src/text/processor.ts @@ -148,7 +148,7 @@ function processWhiteSpace( } if (shouldCollapseTabsAndSpaces) { - content = content.replace(/([ ]|\t)+/g, Space).trim() + content = content.replace(/([ ]|\t)+/g, Space).replace(/^[ ]|[ ]$/g, '') } return { content, shouldCollapseTabsAndSpaces, allowSoftWrap } diff --git a/test/__image_snapshots__/white-space-test-tsx-test-white-space-test-tsx-white-space-normal-should-not-render-extra-spaces-with-white-space-normal-1-snap.png b/test/__image_snapshots__/white-space-test-tsx-test-white-space-test-tsx-white-space-normal-should-not-render-extra-spaces-with-white-space-normal-1-snap.png index 8cbc235b..920ca0b2 100644 Binary files a/test/__image_snapshots__/white-space-test-tsx-test-white-space-test-tsx-white-space-normal-should-not-render-extra-spaces-with-white-space-normal-1-snap.png and b/test/__image_snapshots__/white-space-test-tsx-test-white-space-test-tsx-white-space-normal-should-not-render-extra-spaces-with-white-space-normal-1-snap.png differ diff --git a/test/white-space.test.tsx b/test/white-space.test.tsx index a53bd6fd..8b2f8250 100644 --- a/test/white-space.test.tsx +++ b/test/white-space.test.tsx @@ -9,13 +9,19 @@ describe('white-space', () => { describe('normal', () => { it('should not render extra spaces with `white-space: normal`', async () => { + const EnSpace = String.fromCodePoint(Number('0x2002')) + const svg = await satori(
- {' hello '} +
{'hello'}
+
{' hello '}
+
{EnSpace + 'hello'}
, { width: 100,