Add captions to images with inline Markdown and link support. The caption format is compatible with the CommonMark spec and other Markdown applications.
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:
renderMarkdown requires sourcePath to correctly process links, but I'm not aware how we can get sourcePath in the callback function passed to MutationObserver. This can affect how other link-related plugins (e.g. MathLinks, Strange New Worlds) work. Maybe we can address it by using MarkdownRenderChild, and trigger reloading every time a mutation occurs (but I've had no luck so far)
As for internal images, it cannot deal with caption text that contains internal links like ![[Pasted image 20230918180409.png|Compatible with [[MathLinks]]]]. So I had to make up a original notation << >> to avoid this: ![[Pasted image 20230918180409.png|Compatible with <<MathLinks>>]]. Obviously this isn't cool.
## 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>>]]
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
toMarkdownRenderer.renderMarkdown
.The current approach has at least two limitations:
renderMarkdown
requiressourcePath
to correctly process links, but I'm not aware how we can getsourcePath
in the callback function passed toMutationObserver
. This can affect how other link-related plugins (e.g. MathLinks, Strange New Worlds) work. Maybe we can address it by usingMarkdownRenderChild
, and trigger reloading every time a mutation occurs (but I've had no luck so far)![[Pasted image 20230918180409.png|Compatible with [[MathLinks]]]]
. So I had to make up a original notation<< >>
to avoid this:![[Pasted image 20230918180409.png|Compatible with <<MathLinks>>]]
. Obviously this isn't cool.(Also, I'm currently passing the plugin instance to
renderMarkdown
's last parametercomponent
, 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:
Source: