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

Change img hrefs in markdown from file to vscode-file #136687

Merged
merged 2 commits into from
Nov 16, 2021

Conversation

RyanAfrish7
Copy link
Contributor

In markdown renderer, hrefs of images in html are transformed from file: to vscode-file: protocol.

This PR fixes #136027

@ghost
Copy link

ghost commented Nov 8, 2021

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

Besides the comment:

  1. Let's see if we can remove the other call to _href so that all images are handled in a consistent way
  2. Make sure to add some test cases for this new logic. Here's the test file:
    suite('MarkdownRenderer', () => {

@@ -100,6 +100,22 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
const withInnerHTML = new Promise<void>(c => signalInnerHTML = c);

const renderer = new marked.Renderer();

const htmlParser = new DOMParser();
renderer.html = (rawHtml: string) => {
Copy link
Collaborator

@mjbvz mjbvz Nov 8, 2021

Choose a reason for hiding this comment

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

This seems to break markdown text such as: text <b>bold</b> as it gets rendered as:

<p>text <b></b>bold</p>

Instead, I think you should move this logic after the full md has been rendered but before sanitization:

let renderedMarkdown = marked.parse(value, markedOptions);

@mjbvz mjbvz added this to the November 2021 milestone Nov 10, 2021
@RyanAfrish7 RyanAfrish7 requested a review from mjbvz November 14, 2021 19:02
@mjbvz mjbvz merged commit e38fbda into microsoft:main Nov 16, 2021
@mjbvz
Copy link
Collaborator

mjbvz commented Nov 16, 2021

Thanks! Should be in the next insiders build and is scheduled to go out with VS Code 1.63

@github-actions github-actions bot locked and limited conversation to collaborators Dec 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With md.supportHtml = true, an img tag on the markdown document cannot load the URI of a local resource
2 participants