This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
Ignore all descriptions for rendered images #287
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thanks for creating and maintaining this awesome tool! It is incredibly handy and useful to me.
Back to the PR. I was bitten by #285 as well so I decided to have a look at it.
According to the CommonMark Spec, all inline elements are allowed in the image description part. However, previously we only handled plain text elements (by ignoring them). So in this PR we change to ignore all elements other than image elements.
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, and the more correct version is a bit tedious to implement because we have to list all inline tags ourselves.
By the way, this issue should be already covered in the 'commonmark-spec' test cases (e.g., 573-images.md). However, because the image files for those fixtures are missing, the images are never rendered as images but links (golden/iterm2/commonmark-spec/573-images). So those problems are not detected in testing. I think we perhaps need to address this as well, but I do not have a good solution. What do you think?
Re: #285, #194.