Skip to content

Commit

Permalink
feat: Support imageRules configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
telesoho committed Feb 12, 2025
1 parent 6a90aa9 commit 5578acc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.4.0 (2025/02/12)

- feat: Support imageRules configuration

## 1.3.1 (2024.11.21)

- feat: Support the OpenAI-compatible interface, customize the baseurl
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Smartly paste for Markdown.
**(New Feature)** Define custom rules to modify the target image path and Markdown link pattern based on the current Markdown file's path. Each rule is an object with the following properties:
- `match`: A regex pattern (as a string) to test against the current Markdown file’s full path.
- `targetPath`: A string pattern (supports predefined variables) that specifies where the image should be saved.
- `linkPattern`: A string pattern (supports predefined variables) that specifies how the Markdown link for the image should be formatted.
- `linkPattern`: A string pattern (supports predefined variables) that specifies how the Markdown link for the image should be formatted. You can use `${altText}` as selected text,`${imageFilePath}` as image saved path in the setting.
- `options` (optional): Regex options (e.g., `"i"`) for the matching pattern.

**Example:**
Expand Down
40 changes: 39 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-markdown-paste-image",
"displayName": "Markdown Paste",
"description": "A smartly paste for markdown.",
"version": "1.3.1",
"version": "1.4.0",
"publisher": "telesoho",
"author": {
"name": "telesoho",
Expand Down Expand Up @@ -176,6 +176,44 @@
"default": true,
"description": "Enable/Disable using img tag with width and height for pasting image."
},
"MarkdownPaste.imageRules": {
"type": "array",
"scope": "resource",
"items": {
"type": "object",
"title": "Image Link Regex rule",
"properties": {
"match": {
"type": "string",
"description": "regex string."
},
"options": {
"type": "string",
"description": "Regex options."
},
"targetPath": {
"type": "string",
"description": "Target path."
},
"linkPattern": {
"type": "string",
"description": "link pattern. ${altText} and ${imageFilePath} predefine variables supported"
}
}
},
"examples": [
[{
"match": "courses.*cysec",
"targetPath": "${workspaceFolder}/labs/public/images/cysec/${fileBasenameNoExtension}_${datetime|yyyy-MM-DD_HH-mm-ss}",
"linkPattern": "![${altText}](/images/cysec/${fileBasenameNoExtension}_${datetime|yyyy-MM-DD_HH-mm-ss}.png)"
},
{
"match": "courses.*wired",
"targetPath": "${workspaceFolder}/labs/public/images/wired/${fileBasenameNoExtension}_${datetime|yyyy-MM-DD_HH-mm-ss}",
"linkPattern": "<img src='/images/wired/${fileBasenameNoExtension}_${datetime|yyyy-MM-DD_HH-mm-ss}.png' alt='${altText}'/>"
}]
]
},
"MarkdownPaste.rules": {
"type": "array",
"scope": "resource",
Expand Down

0 comments on commit 5578acc

Please sign in to comment.