Comments (4)
The line numbers reported where pointing to the next line instead of the line which was added into matches using matches = append(matches, {begin: begin, end: end}). I had a theory that it could be caused by a presence of a front-mater.
This problem is also caused by the presence of Chinese characters in the frontmatter. Once I removed the Chinese from frontmatter the vale reports correct line numbers.
from vale.
By looking at a code (in core/location.go, check/script.go) I don't see a place where loc
reported from a script is adjusted to account for modifications to the text done inside the script. Which means if script modifies the text (by removing sections or codeblocks or anything else) the script itself is responsible for maintaining the correlation of line numbers in original text with modified text. Am I correct here?
from vale.
Since line numbers are not working and correct matches cause a crash (and I need to validate a big corpus of texts) I was trying to disable the match by providing bogus positions.
matches = append(matches, {begin: 0, end: 0})
I also tried
matches = append(matches, {begin: 1, end: 1})
matches = append(matches, {begin: 1, end: 2})
The result is the same. I observer a crash like the following every time Chinese characters are present.
panic: runtime error: slice bounds out of range [:4709] with capacity 4096
goroutine 7 [running]:
github.com/errata-ai/vale/v2/internal/check.re2Loc(...)
github.com/errata-ai/vale/v2/internal/check/definition.go:129
github.com/errata-ai/vale/v2/internal/check.makeAlert({{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0x0, 0x0}, {0x14002f6d7b8, 0x6}, {0x1010e8966, ...}, ...}, ...)
github.com/errata-ai/vale/v2/internal/check/definition.go:133 +0x19c
github.com/errata-ai/vale/v2/internal/check.Script.Run({{{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0x0, 0x0}, {0x14002f6d7b8, 0x6}, {0x1010e8966, ...}, ...}, ...}, ...)
github.com/errata-ai/vale/v2/internal/check/script.go:61 +0x538
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintBlock(0x14003be5768, 0x14003fd0000, {{0x14005a10000, 0x1bef}, 0xffffffffffffffff, {0x140057ea6e8, 0x7}, {0x14005a10000, 0x1bef}}, 0x100e13bb8?, ...)
github.com/errata-ai/vale/v2/internal/lint/lint.go:229 +0x174
github.com/errata-ai/vale/v2/internal/lint.Linter.lintSizedScopes({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002da9240, 0x14003016d50, 0x101912880, 0x1, ...}, ...)
github.com/errata-ai/vale/v2/internal/lint/ast.go:193 +0x30c
github.com/errata-ai/vale/v2/internal/lint.Linter.lintHTMLTokens({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002da9240, 0x14003016d50, 0x101912880, 0x1, ...}, ...)
github.com/errata-ai/vale/v2/internal/lint/ast.go:147 +0x7e0
github.com/errata-ai/vale/v2/internal/lint.Linter.lintMarkdown({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002da9240, 0x14003016d50, 0x101912880, 0x1, ...}, ...)
github.com/errata-ai/vale/v2/internal/lint/md.go:60 +0x1c0
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFile(0x1400018e140, {0x14002a82360?, 0x0?})
github.com/errata-ai/vale/v2/internal/lint/lint.go:169 +0x26c
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1.1({0x14002a82360?, 0x0?})
github.com/errata-ai/vale/v2/internal/lint/lint.go:114 +0x4c
created by github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1
github.com/errata-ai/vale/v2/internal/lint/lint.go:112 +0x1e8
from vale.
By looking at a code (in core/location.go, check/script.go) I don't see a place where
loc
reported from a script is adjusted to account for modifications to the text done inside the script. Which means if script modifies the text (by removing sections or codeblocks or anything else) the script itself is responsible for maintaining the correlation of line numbers in original text with modified text. Am I correct here?
No, the script just has to report locations accurate to itself. In other words, script_text[start:end]
needs to match what you intend the alert to be about.
Vale handles the location adjustments internally.
from vale.
Related Issues (20)
- Cannot get IgnoredClasses to work HOT 1
- Feature Request: Expand the list of supported scopes
- Existence with tokens seems to fail at catching angle brackets in raw scope HOT 1
- Multiple `raw` Tokens Break Rule HOT 1
- Beginning/End of Line Does Not Work in Regex Patterns HOT 1
- Hyphenated words in exceptions list still being flagged as errors HOT 3
- [Question] Is Vale's scope-awareness able to tell me under which scope a style-check has been found? HOT 1
- Support the Typst typesetting language
- Support for neorg
- Support SARIF output HOT 1
- Pulling `Vocab.zip` using `vale sync` removes all existing folders in my projects `styles/Vocab` HOT 2
- Rule that worked in 2.23 does not work in 2.27 HOT 1
- [Question] Vale Not Detecting Underscores ('_') in Token HOT 2
- Vale incorrectly detects issues inside <pre> tag ONLY if token first appears outside of <pre> tag HOT 3
- Vale counts words per sentence wrong, if one word contains a dot. This triggers 'try to keep sentence short (<30 words)' warning. HOT 5
- Question: how to ignore all words with underscores HOT 1
- Markdown: Link in image markup is linted HOT 3
- "Node.js" should not be rejected HOT 3
- Ignore MyST syntax labels HOT 4
- Release as NPM package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vale.