Skip to content

Commit

Permalink
Add double-space alias for a preferred of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 7, 2019
1 parent 640dccb commit 6ecd0c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function sentenceSpacing(options) {
preferred = 0
}

if (preferred === 'double-space') {
preferred = 2
}

if (typeof preferred !== 'number') {
throw new Error(
"Expected `options.preferred` to be `'space'`, `'newline'`, or a `number`"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Emit warnings when the spacing does not adhere to the preferred style.

* `0` (or `'newline'`) — Disallow spaces between sentences
* `1` (or `'space'`, default) — Allow only one space between sentences
* `2` — Allow only two spaces between sentences
* `2` (or `'double-space'`) — Allow only two spaces between sentences

### Messages

Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var mixed = [
test('sentenceSpacing(value[, size])', function(t) {
var zero = [0, 'newline']
var one = [null, 'space', 1]
var two = [2]
var two = [2, 'double-space']

retext()
.use(spacing, {preferred: 1})
Expand Down

0 comments on commit 6ecd0c8

Please sign in to comment.