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

Improve Markdown syntax highlighting #25330

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

chbk
Copy link
Contributor

@chbk chbk commented Feb 21, 2025

Release Notes:

  • Improved Markdown syntax highlighting
  • Added syntax scopes to themes

Changes to highlights:

Zed 0.174.6 With this PR
Image Image

Changes to include the markup scope, conforming to Neovim, VS Code, Atom, and Zed itself.

  • paragraph, indented_code_block, pipe_table: text
  • # Heading: title -> heading.markup
  • -, 1., >, |: punctuation.markup
  • ```: punctuation.embedded.markup
  • [1]: url.com, [link](url.com): link.markup
  • url.com: link_uri -> link.uri.markup
  • *italic*: emphasis -> emphasis.markup
  • **bold**: emphasis.strong -> markup.emphasis.strong.markup
  • `raw`: text.literal -> raw.markup
  • ~~strikethrough~~: strikethrough.markup
# Heading

Some stylized text:
- `raw`
- *italic*
- ~strike~
- **strong**

> quoted

```python
print("some code")
```

1. Here is an ![image](image.jpg)
2. A [link](https://github.com/zed-industries)
3. And even a [referenced link][1]

[1]: https://zed.dev

| tables | are |
| --- | --- |
| properly | scoped |

Changes to themes:

  • Add highlighting rules for the following new scopes, using theme colors:

    • heading
    • strikethrough
  • Rename scopes that are no longer used in zed/crates/languages/src or zed/extensions to their new names:

    • punctuation.list_marker -> punctuation.markup
    • link_text -> link
    • link_uri, link.url -> link.uri
    • text.literal -> raw

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 21, 2025
@chbk chbk marked this pull request as ready for review February 21, 2025 13:32
iamnbutler pushed a commit that referenced this pull request Feb 21, 2025
Release Notes:

  - Added syntax scopes to themes

Supports:

- [Improve CSS syntax
highlighting](#25326)
- [Improve Go syntax
highlighting](#25327)
- [Improve Markdown syntax
highlighting](#25330)

Changes:

- Adds highlighting rules for the following new scopes, using theme
colors:
    - `heading`
    - `namespace`
    - `selector`
    - `strikethrough`
    - `unit`

- Renames scopes that are no longer used in `zed/crates/languages/src`
or `zed/extensions` to their new names:
    - `punctuation.list_marker` -> `punctuation.markup`
    - `link_text` -> `link`
- `link_uri` -> `link.url`, as defined in the [gitcommit
grammar](https://github.com/zed-industries/zed/blob/dff47a843695d03160680502e6d94634e376698e/crates/languages/src/gitcommit/highlights.scm#L5)
    - `text.literal` -> `raw`
(link_text) @link_text
(link_label) @link_text
(link_destination) @link_uri
(emphasis) @markup.emphasis
Copy link
Member

Choose a reason for hiding this comment

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

These selectors aren't going in the right direction.

We do partial matching on selectors, so we want them to go from less specific -> more specific.

So for this one it should be @emphasis.markup.

This would allow for it to be styled just by emphasis, but overridden by emphasis.markup.

@maxdeviant maxdeviant self-assigned this Feb 21, 2025
@chbk chbk marked this pull request as draft February 21, 2025 18:18
@chbk chbk marked this pull request as ready for review February 21, 2025 18:52
Copy link
Member

@maxdeviant maxdeviant left a comment

Choose a reason for hiding this comment

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

I have some reservations about the breaking changes (the selector renames) to the themes in this PR, as it will break downstream user themes.

It would be great it if we could make the improvements without including the breaking changes so that we can deal with them separately.

@chbk
Copy link
Contributor Author

chbk commented Feb 21, 2025

Should I prepend original selectors, and create a new PR to deprecate them in the future?

In this PR we'd have:
@title.heading.markup
@text.literal.raw.markup
@link_text.link.label.markup
@link_uri.link.uri.markup
@punctuation.list_marker.markup

@maxdeviant
Copy link
Member

Should I prepend original selectors, and create a new PR to deprecate them in the future?

In this PR we'd have: @title.heading.markup @text.literal.raw.markup @link_text.link.label.markup @link_uri.link.uri.markup @punctuation.list_marker.markup

I have some ideas for how we can handle the breaking change, but for now I would just like for this PR to make the improvements that don't require renaming the selectors. Once those are in place then we can merge the additive/backwards-compatible changes and deal with the breaking changes separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants