telesoho / vscode-markdown-paste-image

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

Variable expansion in rules and Lang-rules #125

Closed KagaJiankui closed 1 year ago

KagaJiankui commented 1 year ago

When pasting images online into files, the rules(including Lang-rules) does not expand the pre-defined variables.

For an example, one of my (personal) rules is

{
  "options": "",
  "regex": "^(?:https?://)?(?:.*/)(.*(?<=png|jpg|svg|webp|jpeg|gif))",
  "replace": "${fileBasenameNoExtension}.assets/$1"
}

and the structure of the working directory(after pasting, two images inside the tree are both pasted with the extension) is

Falken-typst/
├── falken_refined.assets/
│   ├── 20230825215737.png
│   └── 20230910065914.png
├── falken_refined.pdf
└── falken_refined.typ

For the pasted images in falken_refined.assets directory, which is correctly parsed, I expect the text after applying the rules are

falken_refined.assets/20230825215737.png

, however the actual text showed up are

${fileBasenameNoExtension}.assets/20230825215737.png
telesoho commented 1 year ago

@KagaJiankui Thank you for your reporting. Version 1.0.1 has been released to fix it.

KagaJiankui commented 1 year ago

Thanks for your extremely quick action, I'll check this out ASAP.