Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vale is picking up errors for stuff in code blocks in GitHub markdown #387

Closed
ramyaparimi opened this issue Dec 9, 2021 · 5 comments
Closed

Comments

@ramyaparimi
Copy link

  • OS: macOS
  • Install method: Homebrew
  • vale version 2.11.2

Here is my .vale.ini

StylesPath = vale

# suggestion, warning or error
MinAlertLevel = warning 

Vocab = Docs

IgnoredScopes = code,tt, em

[*.md]
BasedOnStyles = Vale,Vocab

TokenIgnores = \(\/.*?\), \
               {%.*?%}, \
               {{.*?}}, \
               (.|\/|-)?github(\/|-)?, \
               (<http[^\n]+>+?)

There are the types of errors it is picking up:

content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md:152:53:Vale.Terms:Use 'hostname' instead of 'HOSTNAME'.
`
image

content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md:236:21:Vale.Terms:Use 'npm' instead of 'NPM'.

image

Not sure what I am missing.

@jdkato
Copy link
Member

jdkato commented Dec 9, 2021

Assuming that this is the file in question, you're not using a standard flavor of Markdown -- it looks like you're making significant use of Liquid-like template tags along with mixing nested Markdown inside raw HTML.

This means that, as you've seen, there's no guarantee that Vale will be able to correctly parse and lint your content (GitHub itself, as you can see in the file preview I linked above, cannot render it correctly).

It's possible to work around these issues by using a combination of BlockIgnores and TokenIgnores, but it's not necessarily straightforward.

Another option would be to run Vale on your site's generated HTML, which should just work as you'd expect.

@ramyaparimi
Copy link
Author

Thanks so much for answering my question. It all makes sense now. I will try running Vale on site generated HTML.

Considering this scenario, will I be able to use Vale Action to run only on lines modified in a PRs? I am assuming that would work as expected if the modified lines do not have the Liquid like templates 😞

@ramyaparimi
Copy link
Author

ramyaparimi commented Dec 10, 2021

I added a regular expression to BlockIgnores and TokenIgnores to avoid code blocks! Seems like it is not picking up things from code blocks and errors. This is how my .vale.ini looks now.

StylesPath = vale

# suggestion, warning or error
MinAlertLevel = warning 

Vocab = Docs

IgnoredScopes = code,tt, em, link, blockquote

[*.md]
BasedOnStyles = Vale,Vocab

BlockIgnores = ```[a-z]*[\s\S]*?\n```

TokenIgnores = \(\/.*?\), \
               {%.*?%}, \
               {{.*?}}, \
               (.|\/|-)?github(\/|-)?, \
               (<http[^\n]+>+?), \
               (```[a-z]*[\s\S]*?\n```)

@ramyaparimi
Copy link
Author

I used this regex in TokenIgnores to for code blocks so Vale can ignore them. Vale is still picking up terms from code blocks. Not sure if I am missing something. Here is my .vale.ini

[*.md]
BasedOnStyles = Vale,Vocab

BlockIgnores = ```[a-z]*[\s\S]*?\n```

TokenIgnores = \(\/.*?\), \
               {%.*?%}, \
               {{.*?}}, \
               (.|\/|-)?github(\/|-)?, \
               (<http[^\n]+>+?), \
               (```[a-z]*[\s\S]*?\n```), \
               `[a-z]*[\s\S]*?`, \
               \[([^\[]+)\]\((.*)\)

@jdkato
Copy link
Member

jdkato commented Dec 14, 2021

Not sure if I am missing something.

Yes, I'd like to make something clear: the behavior you're experiencing is not a bug with Vale.

I cannot emphasize enough that I think you'd be better off running Vale on the HTML generated by whatever you use to build your site.

The problem, as I mentioned in my previous comment, is that your content is different enough from CommonMark that Markdown assumptions (like ignoring code blocks) no longer apply.


More specifically, your regex doesn't match what you appear to think it matches. If you test against the entire file (or a significant portion) in regex101, you'll quickly see that this is the case.

Additionally, the goal with BlockIgnores and TokenIgnores is to ignore non-standard markup syntax that interferes with Vale's parsing of the file; not known constructs like backtick-delimited code blocks. When you look at a file preview from GitHub (like this), the parts that are rendered incorrectly are what you want to ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants