Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-remark-images): Add markdownCaptions option #16574

Merged
merged 2 commits into from
Aug 13, 2019

Conversation

mathieudutour
Copy link
Contributor

Description

This PR adds an option to parse image captions as markdown. To do so, the gatsby remark plugin needs access to the "compiler", eg. parsing a markdown string and generating an html string from it.
So the PR also contains a change to gatsby-remark-transformer to pass that down to plugins.

Related Issues

Fixes #14474

Caveat

gatsby-plugin-mdx doesn't pass down the compiler yet, so the option is going to be ignored when used with the mdx plugin. This will be address in a follow-up PR because there isn't any great way to it yet.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@mathieudutour mathieudutour requested review from a team as code owners August 13, 2019 11:45
@pieh
Copy link
Contributor

pieh commented Aug 13, 2019

I do wonder if there are any instances where user wouldn't want to parse captions as markdown (i.e. if we can get away without adding extra config option, and just parse it every time)?

Question of backward compat here - if raw text (without any markdown formatting) using parsing and generation produces same thing as before?

---edit

I guess parsing+generation do add wrapping <p>, so this is breaking change without plugin option :(

@mathieudutour
Copy link
Contributor Author

Indeed, for backward compatibility we need a new option.

Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you 👍

@sidharthachatterjee sidharthachatterjee changed the title [gatsby-remark-images] Parse the captions as markdown feat(gatsby-remark-images): Add markdownCaptions option Aug 13, 2019
@sidharthachatterjee sidharthachatterjee merged commit a72cbaf into master Aug 13, 2019
@sidharthachatterjee sidharthachatterjee deleted the f/parse-the-caption-as-markdown-14474 branch August 13, 2019 18:58
@CanRau
Copy link
Contributor

CanRau commented Feb 4, 2020

Hey @mathieudutour that's a super useful feature 👏
Any update on gatsby-plugin-mdx support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gatsby-remark-images] When using showCaption, parse the caption as markdown
4 participants