redpen-cc / redpen

RedPen is an open source proofreading tool to check if your technical documents meet the writing standard. RedPen supports various markup text formats (Markdown, Textile, AsciiDoc, Re:VIEW, reStructuredText and LaTeX).
https://redpen.cc
Apache License 2.0
569 stars 74 forks source link

Added the error level threshold feature to redpen-server #879

Closed norm-ideal closed 4 years ago

norm-ideal commented 4 years ago

redpen-server was not working correctly with the new feature of "error threshold" that there was no way to specify to get info or warn.

With this commit they can request an error level by sending errorLevel within the POST form such as:

  var formData = {
    'document': body.getText(),
    'lang' : 'ja',
    'format' : 'json2',
    'documentParser' : 'plain',
    'config' : configs,
    'errorLevel' : 'warn'
  };
coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.004%) to 91.411% when pulling 2832c977be7d144c3549b11c20b73f3b64626319 on norm-ideal:errorlevel into 4ea76e6c1364d6c3236a3b17662c48ae9e3a55d1 on redpen-cc:master.

takahi-i commented 4 years ago

@norm-ideal Thank you very much for the valuable contribution as always. I agree that RedPen servers should support settings of error level as a parameter.

As for the implementation, I think RedPen should not provide setter methods to reduce the states of the objects (kind of a functional programming style) . Adding the threshold parameter to public List validate(Document document) or create another interface public List<ValidationError> validate(Document document, String threshold) and apply it in RedPenResource would be simple.

nits. we cannot change the default behavior changing the default threshold.

norm-ideal commented 4 years ago

Thank you for your advice. I should have realised the solution, because it is much cleaner. How about like this?

Update: I found I cannot set the threshold now. Something went wrong.

norm-ideal commented 4 years ago

Now it works.

image

takahi-i commented 4 years ago

LGTM. Thank you for your contribution!