Exclude frontmatter (yaml or toml) in markdown or html files #3456
-
With static site generators one often has front matter in one's Markdown files (and some, like Hugo, also support 'html' files (that is a chunk of html to go in body), also with front matter). Such front matter is typically yaml, toml, or json, with some type of delimeter ( Is there a reliable way to omit this from spell checking via I'm thinking some kind of multi-line regexp might get the job done (although I find regexp easy to get wrong and overlook some corner case), but a few quick searches (surprisingly) don't turn up results for me (I see results for 'sed' but that is not the right regex format for CSpell). EDIT: I have a regexp, and two replacement questions:
The regexp I came up with: "ignoreRegExpList": [
"/^(\\+\\+\\+|---)(\\s|\\S)*?\\n(\\+\\+\\+|---)\\n/g"
], EDIT: Fixed the regexp to be more reasonable. EDIT: Is there way to |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I'll answer the easy question first. cspell-dicts has a lot of My suggestion would be to define a Once you have that, you can use it wherever "overrides": [{"filename": "website/**/*.md", "ignoreRegExpList": ["PatternFrontMatter"]}] "languageSettings":[{"languageId": "markdown", "ignoreRegExpList": ["PatternFrontMatter"]}] |
Beta Was this translation helpful? Give feedback.
-
I suggest using a site like regex101.com. Here is an example: https://regex101.com/r/PeXKZN/2 Note: detecting front matter is difficult because it only occurs at the beginning of the file. Note: Work is in progress to add parsers to help with the spell checking context: https://github.com/streetsidesoftware/cspell/tree/main/rfc/rfc-0003%20parsing%20files |
Beta Was this translation helpful? Give feedback.
@danielfdickinson,
I'll answer the easy question first.
cspell-dicts has a lot of
cspell-ext.json
examples. Here are a few to take a look at:My suggestion would be to define a
pattern
:PatternFrontMatter
.Once you have that, you can use it wherever
ignoreRegExpList
is allowed: