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

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/61
Author: @christophano
Created: 9/22/2016
Status: Merged
Merged: 9/22/2016
Merged by: @xoofx

Base: masterHead: bugfix/literal-inline-parser


📝 Commits (1)

  • 98ce9b1 Fixes issue where LiteralInlineParser calls PostMatch while processor.Inline is type other than LiteralInline

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 src/Markdig/Parsers/Inlines/LiteralInlineParser.cs (+2 -2)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/61 **Author:** [@christophano](https://github.com/christophano) **Created:** 9/22/2016 **Status:** ✅ Merged **Merged:** 9/22/2016 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `bugfix/literal-inline-parser` --- ### 📝 Commits (1) - [`98ce9b1`](https://github.com/xoofx/markdig/commit/98ce9b1a066f75e2b75edb5c8540589a608ffb18) Fixes issue where LiteralInlineParser calls PostMatch while processor.Inline is type other than LiteralInline ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig/Parsers/Inlines/LiteralInlineParser.cs` (+2 -2) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:45:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#799