microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
161.86k stars 28.45k forks source link

Images in MD strings are not rendered when hovering #174199

Closed MariaSolOs closed 1 year ago

MariaSolOs commented 1 year ago

Type: Bug

Taken from the original issue in rust-analyzer.

VS Code version: Code - Insiders 1.76.0-insider (c7930ca55d072608625ba76c13b5f9baaf9a2136, 2023-02-10T16:22:19.445Z) OS version: Windows_NT x64 10.0.22621 Modes: Sandboxed: Yes

Several popular Rust crates include badges in their library descriptions (e.g. quote):

image

These are used to display hover information. However, these show up as broken links when hovering over the path in VS Code:

image

Note that the Rust client is returning a valid MarkdownString which follows the CommonMark flavor for images. Below is another example of what the LSP hover result looks like.

{
    "contents": {
        "kind": "markdown",
        "value": "\n```rust\nextern crate semver\n```\n\n---\n\n[![github](https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github)](https://github.com/dtolnay/semver) [![crates-io](https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust)](https://crates.io/crates/semver) [![docs-rs](https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K)](https://docs.rs/semver)\n\n<br>\n\nA parser and evaluator for Cargo's flavor of Semantic Versioning.\n\nSemantic Versioning (see <https://semver.org>) is a guideline for how\nversion numbers are assigned and incremented. It is widely followed within\nthe Cargo/crates.io ecosystem for Rust.\n\n<br>\n\n# Example\n\n```rust\nuse semver::{BuildMetadata, Prerelease, Version, VersionReq};\n\nfn main() {\n    let req = VersionReq::parse(\">=1.2.3, <1.8.0\").unwrap();\n\n    // Check whether this requirement matches version 1.2.3-alpha.1 (no)\n    let version = Version {\n        major: 1,\n        minor: 2,\n        patch: 3,\n        pre: Prerelease::new(\"alpha.1\").unwrap(),\n        build: BuildMetadata::EMPTY,\n    };\n    assert!(!req.matches(&version));\n\n    // Check whether it matches 1.3.0 (yes it does)\n    let version = Version::parse(\"1.3.0\").unwrap();\n    assert!(req.matches(&version));\n}\n```\n\n<br><br>\n\n# Scope of this crate\n\nBesides Cargo, several other package ecosystems and package managers for\nother languages also use SemVer: RubyGems/Bundler for Ruby, npm for\nJavaScript, Composer for PHP, CocoaPods for Objective-C...\n\nThe `semver` crate is specifically intended to implement Cargo's\ninterpretation of Semantic Versioning.\n\nWhere the various tools differ in their interpretation or implementation of\nthe spec, this crate follows the implementation choices made by Cargo. If\nyou are operating on version numbers from some other package ecosystem, you\nwill want to use a different semver library which is appropriate to that\necosystem.\n\nThe extent of Cargo's SemVer support is documented in the *[Specifying\nDependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)* chapter of the Cargo reference."
    },
    "range": {
        "start": {
            "line": 0,
            "character": 13
        },
        "end": {
            "line": 0,
            "character": 19
        }
    }
}
System Info |Item|Value| |---|---| |CPUs|Intel(R) Xeon(R) CPU E5-1620 v3 @ 3.50GHz (8 x 3492)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: unavailable_off
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|15.91GB (7.09GB free)| |Process Argv|--crash-reporter-id eb3e61bb-5a35-4917-94b7-be75ff95f116| |Screen Reader|no| |VM|0%|
mjbvz commented 1 year ago

For security reasons, we do not allow rendering arbitrary svgs in the editor. We allow rendering some svg badges inside of readmes, but do not allow them inside of hovers

Try switching to use a png for these badges instead