Skip to content

Commit

Permalink
fix: ignore non-alphabet words
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Nov 2, 2020
1 parent d4c21fa commit eb9d21e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/textlint-rule-en-capitalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const shouldNotCapitalized = (string, allowWords) => {
if (shouldAllowed) {
return true;
}
// Can not capitalize word
if (!/^[a-zA-Z]/.test(string)) {
return true;
}
// A quotation
if (!/^\w/.test(string)) {
return true;
Expand Down
3 changes: 3 additions & 0 deletions test/textlint-rule-en-capitalization-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const rule = require("../src/textlint-rule-en-capitalization");
const tester = new TextLintTester();
tester.run("capitalization", rule, {
valid: [
// Ignore non [a-zA-Z] started word,
// number-started text https://github.com/textlint-rule/textlint-rule-en-capitalization/issues/7
"1st line.",
"In text, follow the standard capitalization rules for American English. Additionally:",
"First, sentence should be capital. Second, sentence should be capital.",
"`Code`, this is ok.",
Expand Down

0 comments on commit eb9d21e

Please sign in to comment.