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
567 stars 74 forks source link

Errors outputted into the wrong line when there are multiple errors in the same line #828

Closed dylan-chong closed 6 years ago

dylan-chong commented 6 years ago

f.md

ABCD Project Project

This is a sentence that is part of a paragraph.

redpen -f markdown f.md -r json outputs:

[
   {
      "document":"f.md",
      "errors":[
         {
            "sentence":"This is a sentence that is part of a paragraph.",
            "level":"Error",
            "validator":"UnexpandedAcronym",
            "lineNum":3,
            "sentenceStartColumnNum":0,
            "message":"The expanded form of the acronym ABCD is not present in the document."
         },
         {
            "sentence":"ABCD Project Project",
            "level":"Error",
            "endPosition":{
               "offset":20,
               "lineNum":1
            },
            "validator":"SuccessiveWord",
            "lineNum":1,
            "sentenceStartColumnNum":0,
            "message":"Found word \"Project\" repeated twice in succession.",
            "startPosition":{
               "offset":13,
               "lineNum":1
            }
         }
      ]
   }
]

The unexpanded acronym warning is clearly pointing to the wrong line - it should point to line one not line three

takahi-i commented 6 years ago

Hello @dylan-chong, thank you very much for the valuable report! I will look into this problem.

takahi-i commented 6 years ago

I fixed this problem with #830. RedPen build with current master outputs the correct line number (though character offset is not correct). Hopefully this fix works for you.