Closed JeffersonQin closed 2 years ago
@JeffersonQin 转换HTML tag为Markdown的功能没问题呀,你发的图里也没包含html tag。
嘶.... 我是复制的浏览器的内容,理论上剪切板中应该包含HTML tag的(Windows下测试的)
我举个例子: 下图是我复制的内容:
下图是剪切板的输出:
命令:
Get-Clipboard -TextFormatType Html
由于我不用Windows和Mac,目前只完成了Linux中把HTML转换为Markdown的功能。我曾经尝试过在Windows中使用powershell去获取剪贴板中的内容,但是当时windows中有一个bug,如果剪贴板内容中有中文或日文字符时,将剪贴板中的文本转换为UTF编码会出现非法字符,导致无法取出正确的剪贴板内容,所以就放弃了。
目前如果在windows下想使用HTML转换为Markdown的功能,可以通过直接拷贝HTML的
我找到解决办法了。这两天正好在写WPF,之前也接触过Clipboard类,可以用类似的办法:即,WPF (.NET) 封装好的函数来调Clipboard
代码:
Add-Type -Assembly PresentationCore
[Windows.Clipboard]::GetData([Windows.DataFormats]::Html)
Reference:
您这边不方便用win对吧,这个反正也不急,我过两天有时间研究一下写一下,提个PR上了,到时候麻烦您看一下
@JeffersonQin 太感谢了!!!
Would you consider making the extension handle more complex paste-types (regardless of platform/language/localisation), so as to meet with the reporting user's expectations?
Have a look at how clipboard2markdown works.
Complex Clipboard type handling code
A more detailed explanation of how it works
I'd raise a PR with some nice recursion to handle inlining images from within Web-page copies, but I'm maxed-out at work at the moment.
@lukebrowell This extension also use to-markdown lib to convert html to markdown too, but it only work on Linux. Vscode is not a web browser, it seem does not support document.addEventListener API, so it is a troublesome thing to get complex clipboard type in vscode.
插件版本:v0.13.3
复制内容:
输出: