ToPlainText() removes essential characters from code blocks including quotes and angle brackets #725

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

Originally created by @luomo-pro on GitHub (Feb 28, 2025).

Description

I've discovered that when using Markdown.ToPlainText(info) to convert markdown to plain text, it not only removes markdown syntax (as expected) but also removes certain characters inside code blocks that should be preserved.

Problem

When converting markdown to plain text, essential characters in code blocks such as double quotes ("), greater than (>), and less than (<) symbols are being removed from the output.

Example

Original markdown:

```
Console.WriteLine("Hello, World!");
```

Expected output after ToPlainText():

Console.WriteLine("Hello, World!");

Actual output after ToPlainText():

Console.WriteLine(Hello, World!);

As you can see, the double quotes have been stripped from the code, which significantly changes the meaning of the code and makes it invalid.

Originally created by @luomo-pro on GitHub (Feb 28, 2025). ## Description I've discovered that when using `Markdown.ToPlainText(info)` to convert markdown to plain text, it not only removes markdown syntax (as expected) but also removes certain characters inside code blocks that should be preserved. ## Problem When converting markdown to plain text, essential characters in code blocks such as double quotes (`"`), greater than (`>`), and less than (`<`) symbols are being removed from the output. ### Example **Original markdown:** ```` ``` Console.WriteLine("Hello, World!"); ``` ```` **Expected output after ToPlainText():** ``` Console.WriteLine("Hello, World!"); ``` **Actual output after ToPlainText():** ``` Console.WriteLine(Hello, World!); ``` As you can see, the double quotes have been stripped from the code, which significantly changes the meaning of the code and makes it invalid.
claunia added the bugPR Welcome! labels 2026-01-29 14:43:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#725