Ability to use images with captions in Markdown #1319
Closed
arun-mani-j
started this conversation in
Proposal
Replies: 1 comment 1 reply
|
Hi @arun-mani-j! I think it’s unlikely we’d add this is a built-in option. Especially given solutions like |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Body
Summary
The images in Markdown
are converted to<img>in HTML. However, converting them to<figure>with<figcaption>without manually setting up plugins pipeline would be useful.Background & Motivation
I'm migrating my website from Hugo to Astro thanks to Astro's simplicity and web native ecosystem. Hugo has a shortcode called figure.
As an example, with this in Markdown:
{{< figure src="/images/examples/zion-national-park.jpg" alt="A photograph of Zion National Park" link="https://www.nps.gov/zion/index.htm" caption="Zion National Park" class="ma0 w-75" >}}Hugo renders this HTML:
Though I do not like using framework specific workarounds, this feature was indeed useful.
To achieve a similar result in Astro, we have to use either MDX with a custom
Figurecomponent or modify the AST through plugins or use surrounding text.figureelement.Providing a built-in feature in Astro to convert Markdown images to figure could provide a middle ground for users who don't want to move to MDX or tweak AST.
Goals
tofigurethanimg.Problems
The solution is obviously not straight forward. We need to choose which property (alt or title) would be used as caption. The
rehype-figure(which also acknowledges this escape-hatch) uses alt as caption.May be, with such problems, it may not be easy for Astro to provide a clean solution. In that case, I think the RFC discussion can be used to provide workarounds and make it easy for others in future to learn why this request was turned down.
Thanks for Astro.
All reactions