Giter VIP home page Giter VIP logo

Comments (9)

lukebrowell avatar lukebrowell commented on August 23, 2024 1

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.

from vscode-markdown-paste-image.

telesoho avatar telesoho commented on August 23, 2024

@JeffersonQin
转换HTML tag为Markdown的功能没问题呀,你发的图里也没包含html tag。

from vscode-markdown-paste-image.

JeffersonQin avatar JeffersonQin commented on August 23, 2024

嘶.... 我是复制的浏览器的内容,理论上剪切板中应该包含HTML tag的(Windows下测试的)

from vscode-markdown-paste-image.

JeffersonQin avatar JeffersonQin commented on August 23, 2024

我举个例子:
下图是我复制的内容:

image

下图是剪切板的输出:

image

命令:

Get-Clipboard -TextFormatType Html

from vscode-markdown-paste-image.

telesoho avatar telesoho commented on August 23, 2024

由于我不用Windows和Mac,目前只完成了Linux中把HTML转换为Markdown的功能。我曾经尝试过在Windows中使用powershell去获取剪贴板中的内容,但是当时windows中有一个bug,如果剪贴板内容中有中文或日文字符时,将剪贴板中的文本转换为UTF编码会出现非法字符,导致无法取出正确的剪贴板内容,所以就放弃了。

目前如果在windows下想使用HTML转换为Markdown的功能,可以通过直接拷贝HTML的代码,然后用插件粘贴到markdown里,插件会判断粘贴的文本中是否带有html的tag的标记,如果有它就会尝试转换。

from vscode-markdown-paste-image.

JeffersonQin avatar JeffersonQin commented on August 23, 2024

我找到解决办法了。这两天正好在写WPF,之前也接触过Clipboard类,可以用类似的办法:即,WPF (.NET) 封装好的函数来调Clipboard

代码:

Add-Type -Assembly PresentationCore
[Windows.Clipboard]::GetData([Windows.DataFormats]::Html)

image

Reference:

from vscode-markdown-paste-image.

JeffersonQin avatar JeffersonQin commented on August 23, 2024

您这边不方便用win对吧,这个反正也不急,我过两天有时间研究一下写一下,提个PR上了,到时候麻烦您看一下

from vscode-markdown-paste-image.

telesoho avatar telesoho commented on August 23, 2024

@JeffersonQin
太感谢了!!!

from vscode-markdown-paste-image.

telesoho avatar telesoho commented on August 23, 2024

@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.

from vscode-markdown-paste-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.