Product teasers on the storefront are cut with truncatewords. When the description starts with spaces or a line break, which happens whenever it comes out of an indented block, the teaser has one word fewer than asked fo…
Product teasers on the storefront are cut with truncatewords. When the description starts with spaces or a line break, which happens whenever it comes out of an indented block, the teaser has one word fewer than asked for and starts with a stray space.
{{ " Ground control to Major Tom." | truncatewords: 3 }}.{{ " one two three" | truncatewords: 1 }}.Ground control to...one... Ground control... (note the leading space)...{{ "Ground control to Major Tom." | truncatewords: 3 }} gives Ground control to....{{ " one two" | truncatewords: 5 }} should give one two.Adapted from harttle/liquidjs (MIT).
Visible test command
TZ=UTC npx --no-install jest --ci --coverage=falseThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
truncatewords-counts-leading-whitespace
Changes under src/ are evaluated.