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
98 stars 7 forks source link

Allow arbitrary inline markdown syntax #15

Closed RyotaUshio closed 1 year ago

RyotaUshio commented 1 year ago

Hi, thank you for making this!

I want to propose enabling arbitrary inline markdown syntax in caption text. (Related issue: #12)

I did it by passing captionText to MarkdownRenderer.renderMarkdown.

The current approach has at least two limitations:

(Also, I'm currently passing the plugin instance to renderMarkdown's last parameter component, but it doesn't seem to be a good practice (https://github.com/obsidianmd/obsidian-releases/pull/2263#issuecomment-1711864829). I haven't found a proper way to do it yet.)

How do you like it?

Example:

image image

Source:

## External link example

`![$\mathcal{A}$rb*itrary* **Inline** [[Markdown]] ==Syntax==! Compatible with [[MathLinks]]](https://github.com/RyotaUshio/obsidian-image-captions/raw/main/example.png)`

In this case, it's compatible with MathLinks because I CAN pass `sourcePath` to `renderMarkdown` in `externalImageProcessor`.

![$\mathcal{A}$rb*itrary* **Inline** [[Markdown]] ==Syntax==! Compatible with [[MathLinks]]](https://github.com/RyotaUshio/obsidian-image-captions/raw/main/example.png)

## Internal link example

`![[Pasted image 20230918180409.png|Compatible with <<MathLinks>>]]`

In this case, it's not compatible with MathLinks because I can't pass `sourcePath` to `renderMarkdown` in `MutationObserver`.

![[Pasted image 20230918180409.png|Incompatible with <<MathLinks>>]]
alangrainger commented 1 year ago

Merged and deployed in 1.1.0! That is great stuff, thank you for putting that together 💯