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

Wrap image caption in text object #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function deserialize(node: MdastNode, opts?: OptionType) {
type: types.image,
children: [{ text: '' }],
[imageSourceKey]: node.url,
[imageCaptionKey]: node.alt,
[imageCaptionKey]: [{ text: node.alt }],
Comment on lines 125 to +126
Copy link
Owner

Choose a reason for hiding this comment

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

Personally don't like that these two are diverging, I also wonder if this should be a flag or could be more generic so consumers could configure.

Thoughts?

Copy link

Choose a reason for hiding this comment

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

+1 to making this configurable as per my comment on issue #44, I think that would solve my scenario nicely.

};
case 'blockquote':
return { type: types.block_quote, children };
Expand Down
6 changes: 5 additions & 1 deletion test/deserialize/__snapshots__/image.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

exports[`deserialize image 1`] = `
Object {
"caption": "'Jack's profile picture'",
"caption": Array [
Object {
"text": "'Jack's profile picture'",
},
],
"children": Array [
Object {
"text": "",
Expand Down