Skip to content

grammars: Highlight inline HTML comments in Markdown - #60211

Closed
qrkks wants to merge 1 commit into
zed-industries:mainfrom
qrkks:codex-highlight-inline-markdown-comments
Closed

grammars: Highlight inline HTML comments in Markdown#60211
qrkks wants to merge 1 commit into
zed-industries:mainfrom
qrkks:codex-highlight-inline-markdown-comments

Conversation

@qrkks

@qrkks qrkks commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • highlight inline HTML comments in Markdown with the theme's comment style
  • leave other inline HTML tags unaffected
  • add regression coverage for the Markdown-inline highlight query

Root cause

The Markdown-inline grammar exposes comments and ordinary inline HTML as the same html_tag node. The existing highlight query did not distinguish comments by their source text, so <!-- ... --> received no comment capture inside paragraphs.

This change adds a query predicate that applies @comment only when an html_tag starts with <!--.

Validation

  • rustup run stable rustfmt --edition 2024 --check crates/grammars/src/grammars.rs
  • git diff --check
  • parsed inline Markdown containing both <!-- hidden note --> and <span>after</span> with the updated query and verified that only the comment received the comment capture

Release Notes:

  • Improved Markdown syntax highlighting for inline HTML comments.

@cla-bot

cla-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @qrkks on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jul 1, 2026
@qrkks

qrkks commented Jul 1, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 1, 2026
@cla-bot

cla-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@qrkks

qrkks commented Jul 1, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot

cla-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@qrkks
qrkks marked this pull request as ready for review July 1, 2026 15:43
@smitbarmase smitbarmase added the area:languages/markdown Markdown markup support label Jul 1, 2026

qrkks commented Aug 14, 2026

Copy link
Copy Markdown
Author

Hi! Just checking in on this small Markdown grammar fix. Is this approach still aligned with the current direction for Markdown highlighting in Zed? Happy to adjust anything if needed. Thanks!

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind sharing a before-after, please? I had a look now and highlighting worked as I'd expect it for me, so would like to be sure to not just see the test (thanks for adding that upfront) but also a visual before-after

@qrkks

qrkks commented Aug 24, 2026

Copy link
Copy Markdown
Author

Thanks for checking, and good catch! I took another look and found that #61212, which was merged after this PR was opened, now handles inline HTML tags through HTML grammar injection and includes coverage for inline and multiline HTML comments. I also noticed that it initially used the same direct @comment capture as this PR before switching to the more general injection-based approach.

That explains why highlighting already works on the current main. This PR has therefore been superseded, so I’ll close it. Thanks for the review!

@qrkks qrkks closed this Aug 24, 2026
@MrSubidubi

Copy link
Copy Markdown
Member

No problem, appreciate you checking in on this!

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

Labels

area:languages/markdown Markdown markup support cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants