-
Notifications
You must be signed in to change notification settings - Fork 43
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: Add image captions support #586
base: master
Are you sure you want to change the base?
feat: Add image captions support #586
Conversation
|
||
while (j < childrenTokens.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace default token image
with image_with_caption
can be wery destructive for external plugins, which searches for image
token only.
I propose to implement this in other way:
- Check what image token has
caption
attr. - Then generate new token
image_caption
after this one. - Add renderer for
image_caption
which will generate all required a11y compatible html. - Convert
caption
attr on image to some class attrimage.attrSet('class', image.attrGet('class') + ' yfm-image-with-caption')
- Add some styles to main css.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I got rid of image_with_caption
token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @osulyanov, for your contribution. The PR description was great, making it easy to understand all the changes. I've added some comments to help reduce the impact of the change. Check out this comment, where I discuss the issue of backward compatibility. |
Don't use separate image_capture tag that potentially can break other image-related plugings
@3y3 Thanks for the fast review and valuable and well-described comments. I made the changes to align with them, please have a look if it works. |
This looks like approvable PR. I will merge it at the end of week. I'm also not sure what this four lines are required, but I need to test it later |
Renderer rules are not needed because markdown-it already has default HTML renderers for basic HTML tags
You were right, markdown-it already has default HTML renderers for basic HTML tags so these renderer rules were redundant, so I removed them. |
Add support for image captions using
figcaption
tagDescription
Added support for image captions using HTML's semantic
figure
andfigcaption
tags.This enhances image context and improves document accessibility by providing visual relationships between images and their captions.
Features
![Alt text](image.jpg "Caption text" =100x100){ caption }
![Alt text](image.jpg "Title" =100x100){ caption="Custom caption text" }
<figure>
and<figcaption>
tagsExample
Input:
Output:
Documentation
Corresponding documentation PR: diplodoc-platform/docs#80
Technical Changes
Testing
Closes DOCSTOOLS-3428
Related issue: #514