alangrainger / obsidian-image-captions

Add captions to images with inline Markdown and link support. The caption format is compatible with the CommonMark spec and other Markdown applications.
GNU General Public License v3.0
95 stars 7 forks source link

Incompatibility with ITS Image Adjustments snippet #24

Closed FellowEsin closed 1 month ago

FellowEsin commented 5 months ago

Hello!

I'd like to use this plugin with the ITS image adjustment snippet, but there are some issues. The thing is, when I set the image parameters like this (caption + adjustment), for example image

It does align the image, and shows the caption, but like this.

image

I want to display "Amogus" only, not "Amogus | right".

Any solutions or suggestions? Thank you.

FellowEsin commented 5 months ago

Addendum: Apparently, someone has suggested before that a caption perimeter was added to avoid conflicts with this very snippet. I guess this could be a solution?

FellowEsin commented 5 months ago

Addendum No. 2: Oddly, the center alignment doesn't work when this plugin is enabled. But when I disable the plugin, it works. So there's this incompatibility as well.

alangrainger commented 1 month ago

That's really an issue with that theme. In the Commonmark spec, the image description is the part of markdown between the square brackets on an image link.

![Image description](file.jpg)

So that theme putting image location commands in that place doesn't seem like a great idea.

However I can see that there is the probability of this theme and other themes/plugins in the future adding all sorts of data into that same image description field.

What I'll do is add a setting where you can add a custom regex to filter the final caption. That should cover all possible use cases into the future, regardless of what plugins or image caption formats people are using.

FellowEsin commented 1 month ago

Looking forward for it! Also I'd really like a manual on how to use the custom regex once the feature comes out. Thank you!

TDSrock commented 1 month ago

Oh awesome! I completly forgot about this until I got the emails for activity on my original issue. Looming forward to the release!

alangrainger commented 1 month ago

@TDSrock @FellowEsin This has been added in 1.1.2

I have added a setting where you can add a custom regex to determine exactly what to parse for the caption, depending on your own preference and vault setup.

In the case of using ITS, the regex should be:

^([^|]+)
FellowEsin commented 1 month ago

YEAAAAH LET'S GOOO! Though how do we use the regex? Can I have an example?

alangrainger commented 1 month ago

I literally put the exact example you need in my comment above :grimacing:

FellowEsin commented 1 month ago

So it's just surrounding the |? I see. Sorry.

alangrainger commented 1 month ago

Just copy and paste exactly this into the settings box, and the caption will ignore anything following a pipe | character (which is what ITS uses):

^([^|]+)
FellowEsin commented 1 month ago

Stupid question but, which settings box exactly?

alangrainger commented 1 month ago

Did you update the plugin?

FellowEsin commented 1 month ago

Yes I have! You were talking about the plugin configs! Sorry. resim

FellowEsin commented 1 month ago

Thank you soooo much!

resim resim

alangrainger commented 1 month ago

No problem, glad it's all working! :)

FellowEsin commented 1 month ago

Sorry to say this, but there is some sort of new problem: It causes problems with links.

resim resim

And when you want to actually use | in your caption, it's another problem. resim resim

Is there a workaround to this or anything?

alangrainger commented 1 month ago

Firstly, that would never work. You can't specify a link like that as the first set of ]] would close the outer link.

You need to follow the documentation and use << >> for wikilinks:

To use Wikilinks, you'll need to swap your square brackets [[]] for angle brackets <<>>:

![[image.jpg|This is a caption with <<a Wikilink>>]]

Secondly, the reason for using the regex is so that you can customise it for your exact use case, since I couldn't possibly cover all plugins/themes/usecases myself.

Just change the regex to allow an escaped pipe:

^((\\\||[^|])+)

For any other cases you come across, please research on Google how to write the correct regex expression. You don't need to post any other questions here - you can customise the regex yourself to handle any custom cases in your own unique vault setup.

FellowEsin commented 1 month ago

So cool! Thank you so much!

alangrainger commented 1 month ago

@FellowEsin Please update to 1.1.3 - I had forgotten to include the theme's CSS file in the 1.1.2 release :grimacing:

FellowEsin commented 1 month ago

What do you mean by the theme's CSS file?

alangrainger commented 1 month ago

This file. Just update to 1.1.3 and it will be fixed.

image

FellowEsin commented 1 month ago

Ohhh okay! Updated! Thanks a lot!

FellowEsin commented 3 weeks ago

Hey, I'm wondering, how can I align the image and not set a caption?