InvalidCastException in SmartyPantsInlineParser #39

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

Originally created by @Jither on GitHub (Jun 28, 2016).

No pull request for this one, sorry ---(*) until Github figures out I'm human. 😈 Besides, I'm not quite sure I follow the reasoning in the SmartyPants parser (I know changes were made to fix the table rendering).

However, test case:

        [Test]
        public void TestInvalidCastBug()
        {
            var pipeline = new MarkdownPipelineBuilder()
                .UseSmartyPants()
                .Build();
            var md = "\"Curly\" quotations and dashes --- like that one.";
            Assert.DoesNotThrow(() => Markdown.Parse(md, pipeline));
        }

Markdig throws an InvalidCastException:
Unable to cast object of type 'System.String' to type 'System.Collections.Generic.List`1[Markdig.Extensions.SmartyPants.SmartyPant]

Seems to be due to the dashes logic writing String.Empty, overwriting the list created by the quotation marks, in ParserState[Index].

(*) Written too many m-dashes today, it seems. ;-)

Originally created by @Jither on GitHub (Jun 28, 2016). No pull request for this one, sorry ---(*) until Github figures out I'm human. :smiling_imp: Besides, I'm not quite sure I follow the reasoning in the SmartyPants parser (I know changes were made to fix the table rendering). However, test case: ``` csharp [Test] public void TestInvalidCastBug() { var pipeline = new MarkdownPipelineBuilder() .UseSmartyPants() .Build(); var md = "\"Curly\" quotations and dashes --- like that one."; Assert.DoesNotThrow(() => Markdown.Parse(md, pipeline)); } ``` Markdig throws an InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.List`1[Markdig.Extensions.SmartyPants.SmartyPant] Seems to be due to the dashes logic writing `String.Empty`, overwriting the list created by the quotation marks, in `ParserState[Index]`. (*) Written too many m-dashes today, it seems. ;-)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#39