telesoho / vscode-markdown-paste-image Goto Github PK
View Code? Open in Web Editor NEWSmartly paste for Markdown.
License: MIT License
Smartly paste for Markdown.
License: MIT License
I've just installed the extension in VS Code. It doesn't seem to work at all on my system. I'm using Fedora 35.
paste auto -->
"regex": "^(pics/*)",
"options": "ig",
"replace": "https://raw.githubusercontent.com/wiki/myname/wiki/$1"
}
thank you!
i push github wiki. then all ok.
According to xclip's information, there is more than one clipboard, but multiple:
primary
secondary
clipboard
buffer-cut
vscode editor using 1. markdown paste using 3.
So, not working
Hello!
This extension doesn't work out of the box with the Windows Subsystem for Linux extension suite.
I am using VScode 1.48, windows 10, WSL & the Remote - WSL extension.
I believe the issue is that this extension, by default, tries to force you to run it on the wsl-remote side which does not have access to the windows clipboard.
I was able to fix the issue by adding this to settings.json:
"remote.extensionKind": {
"telesoho.vscode-markdown-paste-image": ["ui"],
}
This forces the extension to run on the UI/Windows side where it has access to the windows clipboard.
This could be fixed by setting vscode-markdown-paste-image to run on the ui/windows side by default when remote extensions are installed.
In the meantime, the above local fix works for wsl if anyone else is having the same issue.
[EDIT: after experimenting with it a bit more, it doesn't actually work, even with this fix. Changing the settings.json so it runs on the ui side lets you access the clipboard. But it does not actually save the image file that you create.]
whether only support ${workspaceRoot}.
usually need same folder and same article name as folder name.
I know this extension has 'markdown' in the name, but I got notified that the other main 'Image Pasting' extension for vscode is not being maintained anymore. See: mushanshitiancai/vscode-paste-image#100
I would love to be able to use the regex framework of this extension to cater to 'other language' documents (lie Asciidoc) as well. Maybe it is do-able without making a great fuss.
Something like this in settings:
"[asciidoc]": {
"MarkdownPaste.rules": [
{
"regex": "^(?:https?://)?(?:(?:(?:www\\.?)?youtube\\.com(?:/(?:(?:watch\\?.*?v=([^&\\s]+).*)|))?))",
"options": "g",
"replace": "image::https://img.youtube.com/vi/$1/0.jpg[link=https://www.youtube.com/watch?v=$1]",
},
{
"regex": "^(https?://.*)",
"options": "ig",
"replace": "image::$1",
}
]
}
Since I want to totally replace the default paste command, I removed all rules, but it still try to convert it.
One case is when I copy & paste multiple lines, it will wrap the text.
Another case is copying url from chrome, it will convert to <some url>.
I hope it can provide an option to disable these features.
Thanks!
When for example ${fileBasenameNoExtension} is used for 'Path' building and file name contains spaces these spaces are placed directly to the link in markdown and as result the link is invalid.
When pasting an image in, it uses "" backslash characters for the file path. This breaks the HTML rendering of the Markdown text in Github.
Broken:
![](folder\image.png)
Expected:
![](folder/image.png)
By correcting the tool to use forward slashes "/" in the image url it will fix the markdown to be compatible with Github.
A little more information about this bug:
The reason paths can be broken if a backslash "" is used is because certain web servers (like Github) are very strict with slashes. All URL paths need to use forward slashes "/" on Github and other server; primarily Linux servers. Windows servers are generally friendly to using either type of slash.
If try to save captured image into a first level sub folder(like c:/test), the plugin cannot create sub folder correctly.
Paste command just paste text but not markdown markup on Mac. MacOS version: 12.0
I'm using your extension, which has saved me much time.
Everything is fine before I tried to use it when the Markdown file was in a folder with Chinese letter in its name, which means the imagePath
below may contain Chinese letter.
private static saveClipboardImageToFileAndGetPath(imagePath, cb: (imagePath: string) => void)
I traced the execution of your extension and found the Chinese part of imagePath
became a mess in the callback function of saveClipboardImageToFileAndGetPath
:
According to your code, when plplatform === 'win32'
, it will run the /res/pc.ps1
file with PowerShell
.
And in the file pc.ps1
, the output is exactly the input, without any modification.
param($imagePath)
......
$imagePath
After some search I found this article, which says
When we pipe output data from PowerShell cmdlets into native applications, the output encoding from PowerShell cmdlets is controlled by the $OutputEncoding variable, which is by default set to ASCII
And that's the problem, Chinese letters(and also letters in many other languages) can't be represented in ASCII encoding, so the data.toString()
in following code can't get the correct imagePath
.
powershell.stdout.on('data', function (data: Buffer) {
cb(data.toString().trim());
});
AFAIK there's two way to fix the problem:
imagePath
in file pc.ps1
, the code can be rewritten like this:powershell.on('exit', function (code, signal) {
cb(imagePath)
});
powershell.stdout.on('data', function (data: Buffer) {
// do nothing
});
pc.ps1
to UTF-8, which can represent many letters in various language.param($imagePath)
......
[System.Console]::OutputEncoding=[System.Text.Encoding]::GetEncoding(65001)
$imagePath
Thanks for your work!
Since the last update I cannot paste images into markdown anymore on macOS Monterey.
I see the following logs:
[12-26 17:27:01] Cannot found script for darwin
[12-26 17:27:01] getClipboardContentType
[12-26 17:27:01] null
A couple days ago it worked perfectly fine.
It would be nice if I could choose another shortcut to paste my image when working with markdown files. Currently cmd + shift + v is a shortcut for my clipboard manager so it is conflicting with this extension.
I understand why is it so, but...
It can easily happen that I override existing image unintentionally - so my markdown file will be broken on some place... And it does not notify me about overriding ):
(btw - great extension, thanks for it...)
Dear author,
OS: macOS
Plugin version: 0.13.4
VSCode: 1.58.2
After I installed this plugin and tried, just show the error command 'telesoho.MarkdownPaste' not found
.
So I tried to downgrade to 0.13.3, works well.
Tried to upgrade to 0.13.4 again, the same issue happened.
我希望仅在编写md文件时能够启用您的插件,在编写其他格式比如代码时仅粘贴raw text
I want only to write the md files can enable your plug-in, in other formats such as code only paste raw text
(我已经将插件的快捷键改为了cmd+v,以便于统一按键)
First, I want to thank you for taking on this wonderful little extension - it's superbly useful and the small changes you've made are really well done.
One issue/request, though - not sure what the criteria for a valid filename are, but it seems to be all lower caps, which seems a bit too strict. I currently have to manually input the name due to this restriction, and it'd be great if it could be optional.
While we're at it, having a default storage instead of prompting for a path each time would also be a nice option to opt-in to, but it's a minor thing.
Once again, thanks!
使用ctrl+alt+v
快捷键出现了题目的错误信息!
尝试了command 'extension.MarkdownPaste' not found #9的步骤:
ctrl+shift+P
Markdown Paste
,发现能成功执行。There are times when you need to paste the path with ./
.To change it with ./
.
The file name may be in Chinese at some point.It is recommended that you change the regular expression that determines the file name's legitimacy.
if (selectText && !/^[^\\/:\*\?""<>|]{1,120}$/.test(selectText)) {
vscode.window.showInformationMessage('Your selection is not a valid file name!');
return;
}
I've just installed the vscode markdown paste image plugin. Whenever I try to use it I get an error:
Make folder failed:c:/test/2017-05-21-00-25-39.png
Scrrenshot of the error below:
My trouble shoothing steps:
ctrl-alt-v
Markdown Paste Image
from the command bar (ctrl-p
)I am using win 7, VSCode 1.23.1 zip. I've read #6, I've added powershell to my PATH.
When I copy a image file in my explorer, then press Ctrl + Alt + V
in a .md
file in VSCode, nothing happens. If I Ctrl + Shift + P
, choose markdown paste
, Code says There is not a image in clipboard
.
When pasting a file, if the path is set to F:/foo/img/my_image.png
, the image is instead saved to C:/foo/img/my_image.png
, and the path is also changed to C:/foo/img/my_image.png
.
Bug occurs a windows 10 machine, using a fresh install (as of 2021-07-29) of the extension from marketplace.
The image does in fact get saved to the given location.
I think a useful feature for your extension would be to be able to rename the pasted image by editing in markdown. It will paste in with date/time file name and then be able to rename the image file and link in one go.
Hi,
Thanks for the great vscode extension!
I find a strange issue in Window 10 vscode.
I copied 2 lines of python code from VSCode
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
After calling "Markdown Paste Code", it automatically insert one additional newline between each line of code.
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
I debug the pasteCode()
and if I print the content returned by var content = clipboard.readSync();
with console.log(JSON.stringify(content))
, the result is
" screen_width = self.winfo_screenwidth()\r\r\n screen_height = self.winfo_screenheight()"
I installed latest "clipboardy" and run following code in node.js, the result is correct
> const clipboard = await import("clipboardy")
> clipboard.default.readSync()
' screen_width = self.winfo_screenwidth()\r\n' +
' screen_height = self.winfo_screenheight()'
So I guess this is a bug of old clipboardy.
I am not able to fix the bug because master branch doesn't contain Markdown Paste Code
.
May I know if you can check in the latest code? I can help to fix the bug.
Thanks,
anselmwang
i downloaded a Visual Studio Code 1.14.1 and installed this extension, when i paste an image, it shows the path select text box, but when i press the enter key , no picture was pasted in the markdown file, neither any image was found in the file path.
It would be nice to support pasting multiple images at once, similar to web clipper, where one can paste part of a page, containing multiple images and images would be downloaded and saved locally. Looks like right now only links to images are saved.
Previously, it still working fine but not today. In particular, the cmd + alt + v keybinding is not working. while it is registered at default_keybindings.json
, see below
Version: 1.57.1
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:28:32.912Z
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin x64 20.6.0
Can you add the ability to copy gif. Now when I copy .gif, it will be save as png.
And How to save a picture with the original filename on the internet?
Bear note has this awesome feature.
It will be automatic get page title for link.
Dear author,
OS: macOS
Plugin version: 0.13.7
VSCode: 1.58.2
When set Path to "${workspaceRoot}/ABC", the actual path is not the workspace root, but still the same level folder with "[object Object]/ABC/"
Please help to take a look
We first need to figure out how to get the file path on Windows and Linux.
I have the Windows one already:
> [System.Windows.Forms.Clipboard]::GetFileDropList()
C:\Users\slava\Pictures\0.jfif
I want all the pasted images to go into "C:\Users\KWUIUN\Pictures\Img-repo" without any prompt.
I changed the settings on vscode and added this:
"MarkdownPaste.path": "C:/Users/KWUIUN/Pictures/Img-repo/",
"MarkdownPaste.silence": true,
But still asks for the filename of the picture and points to the current relative path of the working space.
How can i do this?
I try to copy&paste a local image file and hope the link code would point to the existed local file, but it still asked me to create a new file.
I'd like to ask for the mentioned feature, it'll be really great to embed the image in the markdown file!
we can do
... contents
![My Image][my_img]
...contents
[my_img]: data:image/png;base64,blahblahblahblah
By attaching the base64 on the end of file instead of inline it, it won't be ugly but still embed in file.
I really hopy this feature is supported, thank you.
Paste code fences with language (can be infer from code)
Hi, When I use sublimetext, there is also a similar plugin like markdown-past.
When I press ctrl+alt+V, it will auto save my image such as
./myfilename/myfilename01.png.
I try to do the same thing like this:
./${fileBasenameNoExtension}/ ${fileBasenameNoExtension}"
But here comes an error that path is invalid.
It seems not able to create folder automatically, and I have to create manually.
May I ask if it's possible create folder automatically??
具体实现可以看我的这个PR
(是在PicGo
的项目):PicGo/PicGo-Core#87
I'd like to be able to paste rich text content and have it converted to md. Ulysses does this with a 'paste from' command.
My workflow with Ulysses: I copy text from powerpoint containing bold, italic, emphasis, and lists and paste it into Ulysses using the 'paste from' feature. Ulysses converts the rich text to MD. I can then copy the MD formatted text to the clipboard as HTML to be pasted into an SQL document.
It would be great to have option to change default filename of image.
Now I have to change it for every image...
I see that support base64 image, so I do that embed base64 image gif do, but I just get:
![]([object%20Object]/assets)
My use case: I get the image file path on the clickboard by right click on the file and click "Copy Path". Then I want to insert that image into the markdown file.
better to have this config included in addition to the default one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.