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

Fix render of literal to be rendered in codeblock #18795

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

dfireBird
Copy link
Contributor

Fixes #18765.

Chose this approach to simplify finding the needed n back ticks, instead of finding the consecutive back ticks.
Tested for about 100 consecutive back ticks, it was working fine.

Regarding tests, I'll add some soon. Just wanted to review the implementation.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 30, 2024
@dfireBird
Copy link
Contributor Author

Added tests as part of same commit, they basically test the number of back ticks that is before and after. Nothing much can be done apart from that I guess.

@Veykril Veykril enabled auto-merge December 30, 2024 14:44
@Veykril Veykril added this pull request to the merge queue Dec 30, 2024
Merged via the queue into rust-lang:master with commit 1c6b838 Dec 30, 2024
9 checks passed
@dfireBird dfireBird deleted the fix-hover-render branch December 31, 2024 02:25
@Jisu-Woniu
Copy link

What if the string consists entirely of space characters?

If the resulting string both begins and ends with a space character, but does not consist entirely of space characters, a single space character is removed from the front and back.

e.g.

`  `   (the rendered form of an empty string)
`   `  (the rendered form of string " ", or 1 space)

will become

(2 spaces) and (3 spaces)

@Veykril
Copy link
Member

Veykril commented Dec 31, 2024

Ah indeed, fully whitespace strings we need to special case thats a good point!

@dfireBird
Copy link
Contributor Author

We should do that, but fun thing in vscode hover renderer trims all leading and trailing spaces inside codeblock. Like even with current implementation hovering over something like r" hello " will only render hello

@Veykril
Copy link
Member

Veykril commented Dec 31, 2024

That is unfortunate but not much we can do about then I think, ultimately markdown rendering differs from implementation to implementation. We could note down the number of leading / trailing whitespace in parenthesis after I suppose (if there are any)

@Jisu-Woniu
Copy link

Is it possible to use <code> </code> to wrap the values instead?

@dfireBird
Copy link
Contributor Author

From my research about it, VSC only allows <span></span by default and others are sanitized. There is user config that can control it, but I'm not sure if that can be used here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quote or escape the raw string correctly in popup
4 participants