marp-team / marp-vscode

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode
MIT License
1.55k stars 72 forks source link

Apply VS Code's link renderer when rendering Markdown in preview panel #428

Closed yhatt closed 1 year ago

yhatt commented 1 year ago

VS Code has owned link renderer to add data-href attribute to every hyperlinks. https://github.com/microsoft/vscode/blob/6a025483bda7044f1949ca9ee027969eb917de80/extensions/markdown-language-features/src/markdownEngine.ts#L330-L346

This was not important in not so long ago because the Electron frame could trap every page navigations. But in recent VS Code, it becomes important to trap <a> links because VS Code covers Web now.

We've updated to apply VS Code's link renderer when rendering Marp Markdown in the preview. <a href="https://example.com"> will render as <a href="https://example.com" data-href="https://example.com">, and VS Code built-in preview becomes able to trap links rendered by Marp. https://github.com/microsoft/vscode/blob/6a025483bda7044f1949ca9ee027969eb917de80/extensions/markdown-language-features/preview-src/index.ts#L333-L348

Resolves marp-team/marp#461.