Skip to content

Stop linting fenced code blocks on Vale 3.20+ - #162

Merged
theletterf merged 2 commits into
mainfrom
fix-code-block-linting
Oct 1, 2026
Merged

theletterf merged 2 commits into
mainfrom
fix-code-block-linting

Conversation

@florent-leborgne

@florent-leborgne florent-leborgne commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #161

Summary

Docs CI installs the latest Vale release (3.22.0 or later). Starting with Vale 3.20.0, an inline element listed in SkippedScopes is masked instead of dropped (33f473d1). Our config lists code there, so fenced code blocks now reach the rules. JSON samples raise QuotesPunctuation on every "value", line, and shell and config samples raise Semicolons, Ellipses, and others.

  • Remove code from SkippedScopes. pre still skips code blocks, and IgnoredScopes still masks inline code.
  • Widen the applies_to entry in BlockIgnores so it also matches option lines with unquoted keys, such as :applies_to: { stack: "ga 9.5+, preview =9.4", serverless: ga }. Without this, the scope change exposes those lines to QuotesPunctuation.
  • Add a code-blocks.md fixture and regression assertions.
  • Run the rule tests on Vale 3.23.0 instead of 3.17.1. The old pin predates the regression, so CI could not catch it. The test helper now strips whitespace from matches because Vale 3.18+ includes trailing whitespace in some reported matches.

Impact on docs-content

Linted all 3,001 Markdown files in docs-content:

Setup Alerts Alerts on fenced code lines
Current config, Vale 3.19.0 (before the regression) 8,821 28
Current config, Vale 3.23.0 22,914 14,219
This PR, Vale 3.23.0 8,340 28

Compared with the 3.19.0 baseline, this PR removes about 470 alerts. Most are Repetition false positives that appeared because dropping inline code joined words, for example "Set to 0 to skip" read as "to to". About 40 are applies_to option lines. It adds 9 alerts, all on prose lines (Wordiness, Clone, PluralAbbreviations, and frontmatter).

Trade-offs

Vale lints the HTML it builds from the Markdown, and it skips text by element. Fenced blocks, and any text that Vale's parser reads as an indented code block, become <pre><code>. The config can't skip fenced blocks without also skipping that text.

Since Vale 3.20, CI has linted all of it. This PR goes back to skipping it, so these alerts stop:

  • Definition-list bodies (about 170 alerts). Vale's parser doesn't support MyST definition lists, so it reads the indented body as code. Example: Options are kprobe, ebpf, quark or auto. (OxfordComma) on defend-advanced-settings.md.
  • Indented paragraphs in a list that contains bold text. The greedy ** patterns in TokenIgnores break the list, so an indented paragraph in it reads as code. Example: migrate the example above (DirectionalLanguage) on change-hardware.md.
  • Comments in code samples. Example: # chcon is only required when running an an SELinux-enabled/OpenShift environment. (Repetition) on two ECK pages.
  • Frontmatter descriptions. Example: a semicolon in description: on both automatic-import.md pages.

Outside fenced blocks, about 360 alerts stop. Most are real issues, but about 45 are false positives on applies_to option lines. CI on Vale 3.19 missed about 320 of the 360 as well.

Possible follow-ups:

  • Narrow the ** patterns in TokenIgnores. IgnoredScopes already masks strong.
  • Remove the leading \s* from the [anchor] pattern in TokenIgnores. It matches the newline after a fence line, which breaks the fence when the block starts with [word].
  • Ask the Vale project to support definition lists.
  • A config that skips only fenced blocks is possible with regex workarounds. A test run recovered about 235 of the 360 alerts, but it changed about 640 others and needs tuning.

Test plan

  • python3 rule-tests/run_rule_tests.py passes on Vale 3.17.1, 3.19.0, 3.20.0, and 3.23.0.
  • With the main version of .vale.ini, the new assertion fails on Vale 3.23.0.
  • docs/reference/connectors-kibana/slack-v2-action-type.md from [One workflow] Add Slack v2 inbound events kibana#293749 no longer raises QuotesPunctuation inside its JSON sample.

After merge

Docs CI downloads the latest release package, so this fix reaches PRs only after a new release.

Vale 3.20.0 masks inline elements listed in SkippedScopes instead of
dropping them. With code in that list, fenced code blocks reach the
rules, so JSON samples raise QuotesPunctuation, Semicolons, and other
warnings in docs PRs.

- Remove code from SkippedScopes. IgnoredScopes still masks inline code.
- Match applies_to option lines with unquoted keys in BlockIgnores.
- Add a code-blocks fixture and regression assertions.
- Run the rule tests on Vale 3.23.0, the version docs CI installs.

Fixes #161

Co-authored-by: Cursor <[email protected]>
@florent-leborgne
florent-leborgne marked this pull request as ready for review October 1, 2026 13:18
@theletterf theletterf self-assigned this Oct 1, 2026
@theletterf theletterf added the enhancement New feature or request label Oct 1, 2026
@theletterf

Copy link
Copy Markdown
Member

Thanks! Checking and merging in a bit

The `\s*\[anchor\]` entry also matched the newline after a fence line.
When a fenced block starts with a bracket token such as `[Service]` or
`[DEBUG]`, that broke the fence: Vale linted the block's content and
treated the prose after it as code until the next fence. The same match
merged a paragraph that opens with a link into the heading before it,
which raised EndPunctuation on normal paragraphs.

Match only the bracket token. Heading anchors are still masked. Extend
the code-blocks fixture with a bracket-leading fence and prose after it,
and assert that the prose is linted and the block is not.

On a 592-file sample of the docs corpus with Vale 3.23.0 this removes 14
alerts, all false positives, and adds none. The rule tests pass on Vale
3.17.1, 3.19.0, 3.22.0, and 3.23.0.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@theletterf

Copy link
Copy Markdown
Member

I reviewed this PR and tested it on Vale 3.17.1, 3.19.0, 3.22.0, and 3.23.0. The fix works on all four versions. I also confirmed the fix through the package path that docs CI uses. Thanks for the clear write-up.

I pushed one commit to this branch: d4d82c9. It applies the first item from your follow-up list. The [anchor] entry in TokenIgnores no longer starts with \s*.

The \s* matched the newline after a fence line. When a fenced block started with a token such as [Service] or [DEBUG], the fence broke. Vale then linted the block and skipped the prose after it until the next fence. The same match merged a paragraph that starts with a link into the heading before it. This caused EndPunctuation alerts on normal paragraphs.

The commit also extends code-blocks.md with a bracket-leading fence and prose after it. The new assertion checks that the prose is linted and the block is not. The suite passes on all four Vale versions. With the old pattern, the new assertion fails on 3.17.1 and 3.23.0. On a 592-file sample of the docs corpus, the change removes 14 alerts. All of them are false positives. It adds none.

I opened the upstream bug report: vale-cli/vale#1198. The cause is in lintHTMLTokens. Since commit 33f473d1, an inline tag no longer enters the block-skip branch. The <code> start tag inside a skipped <pre> then reaches the branch that ends a skipped block. Because code is in SkippedScopes, that branch ends the pre skip too early. Removing code from SkippedScopes is the correct workaround until Vale fixes this.

Two small notes on the description:

  • The anchor change is now done. You can remove it from "Possible follow-ups".
  • Docs CI does not install the latest Vale. The docs-actions v1 workflow pins 3.22.0. I opened Update Vale to 3.23.0 docs-actions#386 to move the pin to 3.23.0. That change is not required for this fix.

After this PR merges, we need a vale-rules release. Docs CI downloads the latest release package.

@theletterf
theletterf merged commit edbc6fa into main Oct 1, 2026
2 checks passed
alexandra5000 pushed a commit to alexandra5000/docs-content that referenced this pull request Oct 2, 2026
…8628)

## Summary

Fixes style issues on lines that Vale stops checking after
[elastic/vale-rules#162](elastic/vale-rules#162).

That PR stops Vale from linting fenced code blocks. Vale can't tell
fenced blocks apart from text it reads as indented code, so it also
stops checking some prose: definition-list bodies, some indented
paragraphs in lists, and comments in code samples. This PR fixes the
real issues on those lines now, so they don't stay hidden.

The fixes come from a Vale run on `main` with the current and the
proposed config. Each lost alert was reviewed by hand in context. Only
alerts that match an Elastic style guide rule in that context are fixed:

- "may" where it means possibility, changed to "might". "May" for
permission is unchanged.
- Directional language ("the example above", "described below").
- Latin abbreviations ("e.g.", "etc."), "and/or", "just", "simply",
"easily", and "execute".
- "or higher", "or newer", and "older version" for versions.
- Filler phrases ("in order to", "whether or not", "all of the", "prior
to", "utilize", "has the ability to").
- A doubled word ("an an") in a comment on two ECK pages.
- British spelling ("acknowledgement"), a comma outside a closing quote,
an exclamation point, and two semicolons that introduce a fragment.

On the remote cluster pages for Elastic Cloud and ECE, the note now
links to the **Using the API** dropdown instead of saying "described
below". The dropdowns get a `:name:` anchor, and the link opens them.

The Vale check on this PR then flagged a few more issues on the changed
lines. These are fixed too: "http" in the SAML troubleshooting page,
"not possible" in the ECE architecture page, eight semicolons that now
split into two sentences, and two uses of "disabled" that now read "off"
and "turned off".

The alerts left unchanged fall into two groups.

False positives:

- Code, placeholders such as `# ...`, and command output.
- `applies_to` lines, URLs, and image paths.
- "May" the month.
- "disable" for turning a setting off. The style guide only restricts it
for something broken.
- "unable" used correctly.
- Product and setting names, such as SASL and
`reindex.remote.whitelist`.
- The italic setting descriptions on the Elastic Defend advanced
settings page. They are verbatim UI text from Kibana's
`advanced_policy_schema.ts`.

Judgment calls:

- Semicolons that join two related clauses correctly, on lines this PR
doesn't otherwise change.
- "In addition", "inform", "drag and drop", and "as a result of".
- "simple" where it means not complex.
- "terminate" for processes.
- Quoted status values such as "down".

Vale with the current config reports 128 fewer alerts on the changed
files, and no new ones. The proposed config reports no new alerts
either. The PR changes 58 files.

The remaining Vale alerts on the changed lines are false positives:
"chcon" (a command name) and "blocklisting" (an Elastic Defend term).

## Generative AI disclosure

1. Did you use a generative AI (GenAI) tool to assist in creating this
contribution?
- [x] Yes
- [ ] No

Tool(s) and model(s) used: Cursor, Claude Opus 5.5. The list of alerts
comes from Vale. Each fix was checked against the style guide and the
page context, and the diff was proofread.

---------

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude some warnings from code blocks

2 participants