Skip to content

Commit 9afba59

Browse files
committed
feat(rule): add strict option
1 parent 19e3ed7 commit 9afba59

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/max-ten.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {RuleHelper} from "textlint-rule-helper"
44
import {getTokenizer} from "kuromojin";
55
import splitSentences from "sentence-splitter";
66
import Source from "structured-source";
7-
const defaultOptions = {max: 3};
7+
const defaultOptions = {
8+
max: 3, // 1文に利用できる最大の、の数
9+
strict: false // 例外ルールを適応するかどうか
10+
};
811

912
function isSandwichedMeishi({
1013
before,
@@ -22,6 +25,7 @@ function isSandwichedMeishi({
2225
*/
2326
export default function (context, options = {}) {
2427
const maxLen = options.max || defaultOptions.max;
28+
const isStrict = options.strict || defaultOptions.strict;
2529
let helper = new RuleHelper(context);
2630
let {Syntax, RuleError, report, getSource} = context;
2731
return {
@@ -55,7 +59,8 @@ export default function (context, options = {}) {
5559
token: token,
5660
after: tokens[index + 1]
5761
});
58-
if (isSandwiched) {
62+
// strictなら例外を例外としない
63+
if (!isStrict && isSandwiched) {
5964
return;
6065
}
6166
currentTenCount++;

0 commit comments

Comments
 (0)