Skip to content

Commit

Permalink
feat(rule): add strict option
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Nov 27, 2015
1 parent 19e3ed7 commit 9afba59
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/max-ten.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {RuleHelper} from "textlint-rule-helper"
import {getTokenizer} from "kuromojin";
import splitSentences from "sentence-splitter";
import Source from "structured-source";
const defaultOptions = {max: 3};
const defaultOptions = {
max: 3, // 1文に利用できる最大の、の数
strict: false // 例外ルールを適応するかどうか
};

function isSandwichedMeishi({
before,
Expand All @@ -22,6 +25,7 @@ function isSandwichedMeishi({
*/
export default function (context, options = {}) {
const maxLen = options.max || defaultOptions.max;
const isStrict = options.strict || defaultOptions.strict;
let helper = new RuleHelper(context);
let {Syntax, RuleError, report, getSource} = context;
return {
Expand Down Expand Up @@ -55,7 +59,8 @@ export default function (context, options = {}) {
token: token,
after: tokens[index + 1]
});
if (isSandwiched) {
// strictなら例外を例外としない
if (!isStrict && isSandwiched) {
return;
}
currentTenCount++;
Expand Down

0 comments on commit 9afba59

Please sign in to comment.