-
Notifications
You must be signed in to change notification settings - Fork 67
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
mdcat panics on inline markup in image descriptions #285
Labels
bug
Something isn't working
Comments
Indeed, according to the common mark spec image descriptions follow the same rules as link texts, meaning mdcat definitely shouldn't crash here. That said I don't have much time to fix this currently. I'd appreciate a pull request. The same issue was already reported in #194 |
swsnr
changed the title
mdcat Crash Report
mdcat crashes on inline markup in image descriptions
Jul 26, 2024
swsnr
changed the title
mdcat crashes on inline markup in image descriptions
mdcat panics on inline markup in image descriptions
Jul 26, 2024
pengjiz
added a commit
to pengjiz/mdcat
that referenced
this issue
Aug 2, 2024
CommonMark allows all inline elements in the image description part[1], not only plain text. So in this commit we change to ignore all such elements instead of panicking. To correctly handle nested images inside the image description, here we push dummy 'RenderedImage' states to the stack. An alternative solution would be maintaining a counter for nested image level and checking the counter when dealing with end of image events, but that feels less tasteful to me. Note that this is a bit more lenient than the spec because it allows block elements as well. However, this behaviour aligns with the upstream library[2], and the more correct version is a bit tedious to implement because we have to list all inline tags ourselves. Closes swsnrGH-285. [1] https://spec.commonmark.org/0.31.2/#images [2] https://docs.rs/pulldown-cmark/0.9.6/src/pulldown_cmark/html.rs.html#377-399
pengjiz
added a commit
to pengjiz/mdcat
that referenced
this issue
Aug 3, 2024
Those cases are actually covered in the 'commonmark-spec' test suite. However, those tests use non-existent images so they are not checked for rendered images. As such, in this commit we add a new case in 'samples/images.md', primarily to test markups in descriptions of rendered images. Re: swsnrGH-194, swsnrGH-285.
swsnr
pushed a commit
to pengjiz/mdcat
that referenced
this issue
Aug 4, 2024
CommonMark allows all inline elements in the image description part[1], not only plain text. So in this commit we change to ignore all such elements instead of panicking. To correctly handle nested images inside the image description, here we push dummy 'RenderedImage' states to the stack. An alternative solution would be maintaining a counter for nested image level and checking the counter when dealing with end of image events, but that feels less tasteful to me. Note that this is a bit more lenient than the spec because it allows block elements as well. However, this behaviour aligns with the upstream library[2], and the more correct version is a bit tedious to implement because we have to list all inline tags ourselves. Closes swsnrGH-285. [1] https://spec.commonmark.org/0.31.2/#images [2] https://docs.rs/pulldown-cmark/0.9.6/src/pulldown_cmark/html.rs.html#377-399
swsnr
pushed a commit
to pengjiz/mdcat
that referenced
this issue
Aug 4, 2024
Those cases are actually covered in the 'commonmark-spec' test suite. However, those tests use non-existent images so they are not checked for rendered images. As such, in this commit we add a new case in 'samples/images.md', primarily to test markups in descriptions of rendered images. Re: swsnrGH-194, swsnrGH-285.
swsnr
added a commit
that referenced
this issue
Aug 4, 2024
Ignore all descriptions for rendered images Closes GH-285
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Markdown:
Crash report:
The text was updated successfully, but these errors were encountered: