[PR #61] Fixes issue where LiteralInlineParser calls PostMatch while processor.Inline is type other than LiteralInline #802

Closed
opened 2026-01-29 14:45:42 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/xoofx/markdig/pull/61

State: closed
Merged: Yes


I've found an odd situation where the AbbreviationParser throws a cast exception when processor.Inline is not of type LiteralInline. See lines 69-90 of LiteralInlineParser. In my case the type was EmphasisDelimiterInline and the current StringSlice was empty.

There are 2 ways I could have gone about this. I have chosen to assume that it is valid to expect the LiteralInlineParser to only call the PostMatch event when the processor.Inline type is LiteralInline so have changed the event raising code accordingly.

The alternative is that the consuming code should not make assumptions about the type of inline that the processor is handling and should handle it accordingly. Let me know if you'd rather I went down this route.

**Original Pull Request:** https://github.com/xoofx/markdig/pull/61 **State:** closed **Merged:** Yes --- I've found an odd situation where the `AbbreviationParser` throws a cast exception when `processor.Inline` is not of type `LiteralInline`. See lines 69-90 of `LiteralInlineParser`. In my case the type was `EmphasisDelimiterInline` and the current `StringSlice` was empty. There are 2 ways I could have gone about this. I have chosen to _assume_ that it is valid to expect the `LiteralInlineParser` to only call the `PostMatch` event when the `processor.Inline` type is `LiteralInline` so have changed the event raising code accordingly. The alternative is that the consuming code should not make assumptions about the type of inline that the processor is handling and should handle it accordingly. Let me know if you'd rather I went down this route.
claunia added the pull-request label 2026-01-29 14:45:42 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#802