mushanshitiancai / vscode-paste-image

paste image from clipboard to markdown/asciidoc directly!
MIT License
426 stars 129 forks source link

Support for Regex rules #100

Open SjoerdV opened 3 years ago

SjoerdV commented 3 years ago

Feature Request

It would be very nice if there would be support for a rule engine like the one found in the Markdown Paste extension. This would mean great usability improvement for asciidoc in vscode as well.

Ex.

    "pasteImage.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]",
        "language": [
           { 
              "name": "asciidoc"
           }
        ]
      },
      {
        "regex": "^(?:https?://)?(?:(?:(?:www\\.?)?youtube\\.com(?:/(?:(?:watch\\?.*?v=([^&\\s]+).*)|))?))",
        "options": "g",
        "replace": "[![](https://img.youtube.com/vi/$1/0.jpg)](https://www.youtube.com/watch?v=$1)",
        "language": [
           { 
              "name": "markdown"
           }
        ]
      },
      {
        "regex": "^(https?://.*)",
        "options": "ig",
        "replace": "image::$1",
        "language": [
           { 
              "name": "asciidoc"
           }
        ]
      }
      {
        "regex": "^(https?://.*)",
        "options": "ig",
        "replace": "[]($1)",
        "language": [
           { 
              "name": "markdown"
           }
        ]
      }
    ],
vezaynk commented 2 years ago

This repository has not seen any activity in over 3 years. There is an actively maintained fork here: https://github.com/telesoho/vscode-markdown-paste-image

Your use-case works in the fork.

SjoerdV commented 2 years ago

Thanks for the heads-up @knyzorg. I made a feature request at the mentioned repo. As the 'vscode-markdown-paste-image' extension is specifically targeted to Markdown language files we'll see if the request is deemed suited and do-able.