Skip to content

Conversation

@RemcoSmitsDev
Copy link
Contributor

@RemcoSmitsDev RemcoSmitsDev commented Nov 8, 2025

This PR adds support for HTML href elements. It also refactored the way we stored the regions, this was done because otherwise I had to add 2 extra arguments to each HTML parser method. It's now also more inline with how we have done it for the highlights.

Small note: the markdown parser only supports HTML href tags inside a paragraph tag. So adding them as a root node will result in just showing the inner text. This is a limitation of the markdown parser we use itself.

Before
Screenshot 2025-11-08 at 15 40 28

After
Screenshot 2025-11-08 at 15 29 55

Example code

<p>asd <a href="https://example.com">Link Text</a> more text</p>
<p><a href="https://example.com">Link Text</a></p>

[Duck Duck Go](https://duckduckgo.com)

TODO:

  • Add tests

cc @bennetbo

Release Notes:

  • Markdown Preview: Add support for HTML href elements.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 8, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Nov 8, 2025
@RemcoSmitsDev RemcoSmitsDev marked this pull request as ready for review November 8, 2025 16:16
@RemcoSmitsDev
Copy link
Contributor Author

@bennetbo It's ready for your review.

@RemcoSmitsDev RemcoSmitsDev changed the title makrdown: Add support for HTML href elements Nov 8, 2025
@RemcoSmitsDev RemcoSmitsDev force-pushed the add-markdown-href-support branch from f8bb370 to 9031a9d Compare November 11, 2025 18:30
@bennetbo
Copy link
Member

bennetbo commented Nov 12, 2025

Pushed a small change that removes a bunch of Vec and String allocations we did not need. Should be good to merge now.

@bennetbo bennetbo enabled auto-merge (squash) November 13, 2025 14:11
@bennetbo bennetbo disabled auto-merge November 13, 2025 14:12
@bennetbo bennetbo merged commit f318bb5 into zed-industries:main Nov 13, 2025
23 checks passed
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
This PR adds support for `HTML` href elements. It also refactored the
way we stored the regions, this was done because otherwise I had to add
2 extra arguments to each `HTML` parser method. It's now also more
inline with how we have done it for the highlights.

**Small note**: the markdown parser only supports HTML href tags inside
a paragraph tag. So adding them as a root node will result in just
showing the inner text. This is a limitation of the markdown parser we
use itself.

**Before**
<img width="935" height="174" alt="Screenshot 2025-11-08 at 15 40 28"
src="https://github.com/user-attachments/assets/42172222-ed49-4a4b-8957-a46330e54c69"
/>

**After**
<img width="1026" height="180" alt="Screenshot 2025-11-08 at 15 29 55"
src="https://github.com/user-attachments/assets/9e139c2d-d43a-4952-8d1f-15eb92966241"
/>

**Example code**
```markdown
<p>asd <a href="https://example.com">Link Text</a> more text</p>
<p><a href="https://example.com">Link Text</a></p>

[Duck Duck Go](https://duckduckgo.com)
```

**TODO**:
- [x] Add tests

cc @bennetbo

Release Notes:

- Markdown Preview: Add support for `HTML` href elements.

---------

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
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 community champion Issues filed by our amazing community champions! 🫶

2 participants