You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// either previous is text and no text attributes or not attached to the previous node
The issue has to do with the comparison between previous.getEndOffset() and attributesNode.getStartOffset(). In image tags, attributesNode.getStartOffset() is always greater than previous.getEndOffset(), which then causes it to always be true.
Here is a fix that I've implemented in my own project in the meantime:
I'm checking if it's an instance of either Image or ResizableImage (to support the Resizable Image extension)
This is also likely an issue with the Media Tags extension, however I have not tested it. If it is, you would fix this by also checking if it's an instance of AbstractMediaLink.
The text was updated successfully, but these errors were encountered:
Describe the Bug
When using the Attributes extension, attributes cannot be applied to an
img
tag, instead they are always applied to the parent tag.Reproducing
Note: code here is in kotlin as that's what my project is in and it's easier to write. It is decently trivial to translate it back to java.
Expected Result
Actual Result
Notice how it still adds the class to the
<a>
tag as expected, however it is not added to the<img>
tag as expected.Additional Context
I have determined exactly what is causing the bug, it is particular piece of code right here in AttributesNodePostProcessor.java:
flexmark-java/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodePostProcessor.java
Lines 90 to 92 in cc3a2f5
The issue has to do with the comparison between
previous.getEndOffset()
andattributesNode.getStartOffset()
. In image tags,attributesNode.getStartOffset()
is always greater thanprevious.getEndOffset()
, which then causes it to always be true.Here is a fix that I've implemented in my own project in the meantime:
in java, you would do
I'm checking if it's an instance of either
Image
orResizableImage
(to support the Resizable Image extension)This is also likely an issue with the Media Tags extension, however I have not tested it. If it is, you would fix this by also checking if it's an instance of
AbstractMediaLink
.The text was updated successfully, but these errors were encountered: