telesoho / vscode-markdown-paste-image

Smartly paste for Markdown.
MIT License
135 stars 41 forks source link

Question: how to config "MarkdownPaste.rules" when there is a absolute path of one image file on my clipboard. #14

Open taoluo opened 6 years ago

taoluo commented 6 years ago

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.

telesoho commented 6 years ago

If your workspace folder is '"\/your\/workspace\/", then you can add an rules to your workspace settings like this:

"MarkdownPaste.rules": [
        {
          "regex": "^\/your\/workspace\/(([a-zA-Z0-9_\/\\-]+)\/([a-zA-Z0-9_\\-]+[\\.]{1}(jpg|jpeg|png|gif)))$",
          "options": "i",
          "replace": "![]($1)"
        }
 ] 

Then use Ctrl+Alt+V to paste /your/workspace/images/2018-05-11-18-51-14.png, you will get ![](images/2018-05-11-18-51-14.png)

Please replace \/your\/workspace\/ in regex to real workspace folder. @mickeydonkey