Skip to content

Conversation

@RemcoSmitsDev
Copy link
Contributor

@RemcoSmitsDev RemcoSmitsDev commented Sep 8, 2025

Follow-up: #37264

This PR adds support for all the common HTML styling elements (b, strong, em, i, ins, del).
It also fixes an issue where we would insert an extra paragraph for new line text that resulted in adding a new line inside the markdown.

Before

Screenshot 2025-08-31 at 18 11 03

After

Screenshot 2025-09-01 at 04 05 21

Code example:

<p>some text <b>bold text</b></p>
<p>some text <strong>strong text</strong></p>
<p>some text <i>italic text</i></p>
<p>some text <em>emphasized text</em></p>
<p>some text <del>delete text</del></p>
<p>some text <ins>insert text</ins></p>

<p>Some text <strong>strong text</strong> more text <b>bold text</b> more text <i>italic text</i> more text <em>emphasized text</em> more text <del>deleted text</del> more text <ins>inserted text</ins></p>

<p>some inline text <img src="https://picsum.photos/200/300" alt="Description of image" style="height: 100px" /> asdjkflsadjfl</p>

# Html Tag
<img src="https://picsum.photos/200/300" alt="Description of image" />

# Html Tag with width and height
<img src="https://picsum.photos/200/300" alt="Description of image" width="100" height="200" />

# Html Tag with style attribute with width and height
<img src="https://picsum.photos/200/300" alt="Description of image" style="width: 100px; height: 200px" />

# Normal Tag
![alt text](https://picsum.photos/200/300)

cc @SomeoneToIgnore

Release Notes:

  • Markdown: Added support for HTML styling elements

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 8, 2025
@maxdeviant maxdeviant changed the title Markdown: Add support for HTML styling elements markdown: Add support for HTML styling elements Sep 8, 2025
@RemcoSmitsDev RemcoSmitsDev marked this pull request as draft September 8, 2025 12:50
@RemcoSmitsDev RemcoSmitsDev marked this pull request as ready for review September 8, 2025 13:31
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

I'm quite out of the context here, and decided to check on how images are rendered.

It also fixes an issue where we would insert an extra paragraph for new line text that resulted in adding a new line inside the markdown.

  1. Here, it seems that all the padding (?) around the images and items is gone.

https://github.com/rust-lang/rust-analyzer/blob/master/docs/book/src/contributing/debugging.md

image

Current Zed shows it a bit better?

image
  1. Here, there's a large spacing between images compared to what GH renders:

https://github.com/rust-lang/rust-analyzer/blob/master/docs/book/src/contributing/guide.md

image

Current Zed seems to do the same.

  1. As very well noted in #37264 (comment) seems like there's a regression:
image

Should we, instead of piling more changes, fix this trash first?
This got reverted in #37893, but overall was right, it seems, so if we get this back, let's ensure Zed's markdowns are rendered normally.

  1. and 2. would be nice to improve too, but this is was a straight regression.

@Angelk90
Copy link
Contributor

@RemcoSmitsDev :

You can also adjust the style of the tag usage `

Add some side padding, and rounding, see table images.

Code:

We use [`cargo-about`](https://github.com/EmbarkStudios/cargo-about) to 
Github Vscode Zed
Screenshot 2025-09-11 alle 10 27 49 Screenshot 2025-09-11 alle 10 30 03 Screenshot 2025-09-11 alle 10 27 42

@RemcoSmitsDev
Copy link
Contributor Author

@Angelk90 i think that is more a ui/ux issue. This pr just adds basic support for styling attributes. We can extend this in the future with more css properties. So its a bit out of scope for what i wanted to add/fix

@Angelk90
Copy link
Contributor

@RemcoSmitsDev : I understand, you might consider fixing it in the future.
I don't like seeing it like this.

@RemcoSmitsDev
Copy link
Contributor Author

RemcoSmitsDev commented Sep 12, 2025

Yeah for sure!

@RemcoSmitsDev RemcoSmitsDev marked this pull request as draft September 13, 2025 11:44
@RemcoSmitsDev
Copy link
Contributor Author

This PR is depending/waiting on inline elements support, to correctly show all the cases you could use style tags.
Right now, added style tag inside a p tag, will break the text inside it to the next line because the element is a block element, as we disabled the flex & flex wrap.

See screenshot impl without showing the style tags inline with the flex & flex-wrap
Screenshot 2025-09-20 at 16 46 05

@SomeoneToIgnore Do you have time to brainstorm about how we could support inline elements. I already did some digging in how we could support this, and I tried to implement this inside taffy, but it seems there is a limitation because you can't wrap a part of the text to parent block start position if it's inline displayed.

See current impl for inline support with taffy

Screen.Recording.2025-09-20.at.17.09.07.mov

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Sep 20, 2025

Sorry, I have no good clues on this and improving markdown rendering is not in any of the company's intermediate plans: from my side, I'm mainly concentrating on rainbow brackets, LSP features like inlays/semantic highlights and community work (PR reviews alone is huge).

I'm happy to help to do a basic review and testing, but not sure can handle anything more intelligent on top.

@SomeoneToIgnore
Copy link
Contributor

I've actually agreed with @bennetbo to get the related PRs over to him, as he has definitely more context than me on what's going on and could suggest something (❤️ )

@bennetbo
Copy link
Member

bennetbo commented Nov 6, 2025

Sorry for taking so long to review. I'll close this for now as there are conflicts. If you'd like to fix the conflicts & re-open I'm happy to review (Feel free to ping me, and I'll make sure to review it quickly)

@bennetbo bennetbo closed this Nov 6, 2025
@RemcoSmitsDev
Copy link
Contributor Author

Happy to fix the conflicts but don't think the PR good enough to merge as it does not support showing the text inline for these HTML elements. I have an idea how we could get around it, will try that out soon, but need's some refactoring I think.

bennetbo added a commit that referenced this pull request Nov 7, 2025
Second take on #37765.

This PR adds support for styling elements (**b**, **strong**, **em**,
**i**, **ins**, **del**), but also allow you to show the styling text
inline with the current text.
This is done by appending all the up-following text into one text chunk
and merge the highlights from both of them into the already existing
chunk. If there does not exist a text chunk, we will create one and the
next iteration we will use that one to store all the information on.

**Before**
<img width="483" height="692" alt="Screenshot 2025-11-06 at 22 08 09"
src="https://github.com/user-attachments/assets/6158fd3b-066c-4abe-9f8e-bcafae85392e"
/>

**After**
<img width="868" height="300" alt="Screenshot 2025-11-06 at 22 08 21"
src="https://github.com/user-attachments/assets/4d5a7a33-d31c-4514-91c8-2b2a2ff43e0e"
/>

**Code example**
```html
<p>some text <b>bold text</b></p>
<p>some text <strong>strong text</strong></p>
<p>some text <i>italic text</i></p>
<p>some text <em>emphasized text</em></p>
<p>some text <del>delete text</del></p>
<p>some text <ins>insert text</ins></p>

<p>Some text <strong>strong text</strong> more text <b>bold text</b> more text <i>italic text</i> more text <em>emphasized text</em> more text <del>deleted text</del> more text <ins>inserted text</ins></p>

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

<p style="text-decoration: underline;">text styled from style attribute</p>
```

cc @bennetbo 

**TODO**
- [x] add tests for styling nested text that should result in one merge

Release Notes:

- Markdown Preview: Added support for `HTML` styling elements

---------

Co-authored-by: Bennet Bo Fenner <[email protected]>
tomatitito pushed a commit to tomatitito/zed that referenced this pull request Nov 7, 2025
…2143)

Second take on zed-industries#37765.

This PR adds support for styling elements (**b**, **strong**, **em**,
**i**, **ins**, **del**), but also allow you to show the styling text
inline with the current text.
This is done by appending all the up-following text into one text chunk
and merge the highlights from both of them into the already existing
chunk. If there does not exist a text chunk, we will create one and the
next iteration we will use that one to store all the information on.

**Before**
<img width="483" height="692" alt="Screenshot 2025-11-06 at 22 08 09"
src="https://github.com/user-attachments/assets/6158fd3b-066c-4abe-9f8e-bcafae85392e"
/>

**After**
<img width="868" height="300" alt="Screenshot 2025-11-06 at 22 08 21"
src="https://github.com/user-attachments/assets/4d5a7a33-d31c-4514-91c8-2b2a2ff43e0e"
/>

**Code example**
```html
<p>some text <b>bold text</b></p>
<p>some text <strong>strong text</strong></p>
<p>some text <i>italic text</i></p>
<p>some text <em>emphasized text</em></p>
<p>some text <del>delete text</del></p>
<p>some text <ins>insert text</ins></p>

<p>Some text <strong>strong text</strong> more text <b>bold text</b> more text <i>italic text</i> more text <em>emphasized text</em> more text <del>deleted text</del> more text <ins>inserted text</ins></p>

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

<p style="text-decoration: underline;">text styled from style attribute</p>
```

cc @bennetbo 

**TODO**
- [x] add tests for styling nested text that should result in one merge

Release Notes:

- Markdown Preview: Added support for `HTML` styling elements

---------

Co-authored-by: Bennet Bo Fenner <[email protected]>
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.

4 participants