Change:
Issue Type: <bBug</bHello, Regarding the , in Markdown this: Renders a link. In a VS Code Extension, this is also possible: Creating a link to run a command. One would think creating an actual anchor link like this: Would work but the click does not execute the command. VS Code version: Code 1.63.0 (, 2021-12-07T05:18:59.299Z) OS version: Linux arm64 5.15.7-1-MANJARO-ARM Restricted Mode: No <details<summarySystem Info</summary </details<details<summaryExtensions (4)</summaryExtensionVersion ------ vscode-eslint2.2.2 gitlens11.7.0 vscode-drawio1.6.4 vsliveshare1.0.5242 </details<!-- generated by issue reporter --
can i take this?
I think they'd be happy if you created a PR. For completeness: works: but the cursor does not change to a hand icon like if was populated.
Thanks, will take a look
This is what I found. In markdown links are detected at two places: detects anything starting with http:// or https:// or file:// checks for and returns anything inside () as URI That's why is detected as a link but isn't. I couldn't get to work. I tried holding ctrl while clicking it and tried in preview as well. Can you tell me how to reproduce it?
You'll need to for it to take an action. The example in the link is probably the easiest. After registration create a MarkdownString containing the registered command. In regards to the linked example: You should be able to click on it and see the console log. Note that the cursor doesn't change to a hand icon.
Have you found any solution? For me even doesn't work. :( I've used a registered and available command.
The way I implemented Markdown and executing a registered command (through ) was by adding a . The structure is very particular because it is an implementation of the and is something like this: Make sure you are using the correct VS Code version too.
Command links in should now also work for normal elements included in the markdown (you have to set and on the to enable this)
where should links work? I tried this in a completion item and neither link syntaxes work: !
Sorry for not adding verification details. The markdown string needs to both trusted and have html enabled:

Discussion:
if (href === text) { // raw link case text = removeMarkdownEscapes(text); } <del> href = _href(href, false); if (markdown.baseUri) { href = resolveWithBaseUri(URI.from(markdown.baseUri), href); } </del> title = typeof title === 'string' ? removeMarkdownEscapes(title) : ''; href = removeMarkdownEscapes(href); <del> if ( !href || /^data:|javascript:/i.test(href) || (/^command:/i.test(href) && !markdown.isTrusted) || /^command:(///)?_workbench.downloadResource/i.test(href) ) { // drop the link return text; } else { // HTML Encode href href = href.replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;') .replace(/'/g, '&#39;'); return `<a href="" data-href="${href}" title="${title || href}">${text}</a>`; } </del> <ins> // HTML Encode href href = href.replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;') .replace(/'/g, '&#39;'); return `<a href="${href}" title="${title || href}">${text}</a>`; </ins> }; renderer.paragraph = (text): string => { return `<p>${text}</p>`;

} }); <ins> markdownHtmlDoc.body.querySelectorAll('a') .forEach(a => { const href = a.getAttribute('href'); // Get the raw 'href' attribute value as text, not the resolved 'href' a.setAttribute('href', ''); // Clear out href. We use the `data-href` for handling clicks instead if ( !href || /^data:|javascript:/i.test(href) || (/^command:/i.test(href) && !markdown.isTrusted) || /^command:(///)?_workbench.downloadResource/i.test(href) ) { // drop the link a.replaceWith(a.textContent ?? ''); } else { let resolvedHref = _href(href, false); if (markdown.baseUri) { resolvedHref = resolveWithBaseUri(URI.from(markdown.baseUri), href); } a.dataset.href = resolvedHref; } }); </ins> element.innerHTML = sanitizeRenderedMarkdown(markdown, markdownHtmlDoc.body.innerHTML) as unknown as string; // signal that async code blocks can be now be inserted

mds.appendMarkdown(`[$(zap)-link](#link)`); let result: HTMLElement = renderMarkdown(mds).element; <del> assert.strictEqual(result.innerHTML, `<p><a href="" data-href="#link" title="#link"><span class="codicon codicon-zap"></span>-link</a></p>`); </del> <ins> assert.strictEqual(result.innerHTML, `<p><a data-href="#link" href="" title="#link"><span class="codicon codicon-zap"></span>-link</a></p>`); </ins> }); test('render icon in table', () => {

</thead> <tbody><tr> <td><span class="codicon codicon-zap"></span></td> <del> <td><a href="" data-href="#link" title="#link"><span class="codicon codicon-zap"></span>-link</a></td> </del> <ins> <td><a data-href="#link" href="" title="#link"><span class="codicon codicon-zap"></span>-link</a></td> </ins> </tr> </tbody></table> `);

assert.ok(data.documentUri.toString().startsWith('file:///c%3A/')); }); <ins> test('Should not render command links by default', () => { const md = new MarkdownString(`[command1](command:doFoo) <a href="command:doFoo">command2</a>`, { supportHtml: true }); const result: HTMLElement = renderMarkdown(md).element; assert.strictEqual(result.innerHTML, `<p>command1 command2</p>`); }); test('Should render command links in trusted strings', () => { const md = new MarkdownString(`[command1](command:doFoo) <a href="command:doFoo">command2</a>`, { isTrusted: true, supportHtml: true, }); const result: HTMLElement = renderMarkdown(md).element; assert.strictEqual(result.innerHTML, `<p><a data-href="command:doFoo" href="" title="command:doFoo">command1</a> <a data-href="command:doFoo" href="">command2</a></p>`); }); </ins> suite('PlaintextMarkdownRender', () => { test('test code, blockquote, heading, list, listitem, paragraph, table, tablerow, tablecell, strong, em, br, del, text are rendered plaintext', () => {