Skip to content

Commit

Permalink
Merge pull request #12 from nicojeske/feature/caption
Browse files Browse the repository at this point in the history
Add support for image captions (or in general support for more attributes before the image size)
  • Loading branch information
nicojeske committed Mar 2, 2022
2 parents 72b89e4 + bd9dcb4 commit 987c749
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions main.ts
Expand Up @@ -258,10 +258,15 @@ export default class MouseWheelZoomPlugin extends Plugin {
// If after the imageName in filetext follows a "|" then it means that the image is already zoomed
const imageNamePosition = fileText.indexOf(imageName);

const stringAfterFileName = fileText.substring(imageNamePosition + imageName.length)
// Handle the case where behind the imageName there are more attributes like |ctr for ITS Theme by attaching them to the imageName
const regExpMatchArray = fileText.substring(imageNamePosition + imageName.length).match(/^((\\?\|[a-zA-Z]+)+)/);
const regExpMatchArray = stringAfterFileName.match(/([^\]]*?)\\?\|\d+]]|([^\]]*?)]]|/);
if (regExpMatchArray) {
imageName += regExpMatchArray[1];
if (!!regExpMatchArray[1]) {
imageName += regExpMatchArray[1]
} else if (!!regExpMatchArray[2]) {
imageName += regExpMatchArray[2]
}
}

const sizeMatchRegExp = new RegExp(`${escapeRegex(imageName)}${regexSeparator}(\\d+)`);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
@@ -1,7 +1,7 @@
{
"id": "mousewheel-image-zoom",
"name": "Mousewheel Image zoom",
"version": "1.0.12",
"version": "1.0.13",
"minAppVersion": "0.9.12",
"description": "This plugin enables you to increase/decrease the size of an image by scrolling",
"author": "Nico Jeske",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mousewheel-image-zoom",
"version": "1.0.9",
"version": "1.0.13",
"description": "This plugin enables you to increase/decrease the size of an image by scrolling",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 987c749

Please sign in to comment.