Skip to content

Commit

Permalink
refactor: widow words default attribute name
Browse files Browse the repository at this point in the history
no-widows is just shorter to write than prevent-widows
  • Loading branch information
cossssmin committed Nov 4, 2024
1 parent 6a5249b commit 01623cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/transformers/preventWidows.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { removeWidows } from 'string-remove-widows'
const posthtmlPlugin = (options = {}) => tree => {
options = merge(options, {
minWordCount: 3,
attrName: 'prevent-widows'
attrName: 'no-widows'
})

// Ignore defaults
Expand Down
8 changes: 4 additions & 4 deletions test/transformers/widowWords.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe.concurrent('Widow words', () => {
})

test('Ignores strings inside expressions', async () => {
const result = await preventWidows('<div prevent-widows>{{{ one two three }}}</div>', {
const result = await preventWidows('<div no-widows>{{{ one two three }}}</div>', {
ignore: [
{ heads: '{{{', tails: '}}}' }
],
Expand All @@ -19,9 +19,9 @@ describe.concurrent('Widow words', () => {
expect(result).toBe('<div>{{{ one two three }}}</div>')
})

test('Applies only to tags with the `prevent-widows` attribute', async () => {
const result = await preventWidows('<div prevent-widows>one two three</div>', { withAttributes: true })
test('Applies only to tags with the `no-widows` attribute', async () => {
const result = await preventWidows('<p no-widows>one two three</p><p>4 5 6</p>', { withAttributes: true })

expect(result).toBe('<div>one two&nbsp;three</div>')
expect(result).toBe('<p>one two&nbsp;three</p><p>4 5 6</p>')
})
})

0 comments on commit 01623cc

Please sign in to comment.