errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.52k stars 155 forks source link

Column numbers identified by vale are incorrect for existence rule #791

Open sohailekline opened 8 months ago

sohailekline commented 8 months ago

Check for existing issues

Environment

macOS Direct Download 2.29.7

Describe the bug / provide steps to reproduce it

I have created a rule to ensure all the list items have ending punctuation at the end. Vale is able to run this rule but the output has some discrepancies.

Rule

extends: existence
message: "Must put the ending punctuation at the end of a list item."
link: ''
nonword: true
level: error
scope: list
tokens:
  - '[^.!?]\s*$'

Input .md file

# Complex Markdown Document for Testing

This document includes a variety of Markdown elements to test edge cases in Vale rules, especially for list punctuation.

## Unordered Lists with Different Bullets

- Item with punctuation.
+ Item without punctuation
* Another item with punctuation.

## Nested Lists

- Parent item:
    - Nested item with punctuation.
    - Nested without punctuation
        - Double nested item with punctuation.
        - Double nested without punctuation.

## Ordered Lists Mixed with Unordered

1. First ordered item with punctuation.
2. Second ordered item without punctuation
    - Nested unordered with punctuation.
    + Nested unordered without punctuation

## Inline Formatting within Lists

- **Bold item with punctuation**
- _Italic item without punctuation_
- `Code item with punctuation`

## Links and Images in Lists

- [Link with punctuation](http://example.com).
- ![Image without punctuation](http://example.com/image.jpg)

## Lists with Blockquotes

- > Blockquote with punctuation.
- > Blockquote without punctuation

## Lists with Code Blocks

- Code block with punctuation:
Code snippet with punctuation.
```

Mixed Content Lists

Remember, this text is designed to test the edge cases of your Vale rule for list punctuation. It includes various types of lists, nested lists, and list items with different types of content and formatting.



## Output
<img width="527" alt="image" src="https://github.com/errata-ai/vale/assets/140367733/674cb071-d297-4df9-ad95-6fac0e0c0a6a">

## Issues
- In output, if we see the first error which is `8:18`, the column number is incorrect. It is picking the first `n` character instead of last.
- If we the second error which is `9:1`, this is false positive. It should not through the error on this line because it already has ending punctuation.
puneet-ekline commented 7 months ago

Any update on this?