Affected projects
DocSharp.Docx
Description
When converting a .docx document to Markdown using DocSharp, URLs that contain parentheses (e.g., Wikipedia URLs) are not properly escaped or URL-encoded. This causes the resulting Markdown link syntax to break because the closing parenthesis of the URL prematurely terminates the Markdown link syntax [text](url).
To reproduce
- Create a Word document (
.docx) containing a hyperlink with parentheses, such as https://en.wikipedia.org/wiki/Mole_(unit) (or download docsharp-link-bug.docx )
- Convert the file using the following C# snippet:
using DocSharp.Docx;
using System;
using System.IO;
using System.Text;
namespace DocSharpExample
{
internal class Program
{
static void Main(string[] args)
{
string inputPath = "docsharp-link-bug.docx"; // Path to test file
var converter = new DocxToMarkdownConverter();
string markdown = converter.ConvertToString(inputPath);
Console.WriteLine(markdown);
}
}
}
Expected Behavior:
The URL should have its parentheses URL-encoded (( to %28 and ) to %29) so it doesn't break the Markdown syntax.
(For comparison, Python's markitdown handles this correctly):
35.45g/[mol](https://en.wikipedia.org/wiki/Mole_%28unit%29)
Actual Behavior (Bug):
The raw parentheses are preserved inside the link destination, which causes markdown parsers to fail at rendering the link properly:
35.45g/[<u>mol</u>](https://en.wikipedia.org/wiki/Mole_(unit))
Screenshot
No response
Version
0.20.0
.NET version
.NET framework 4.7.2
OS
Windows 11 26100
Affected projects
DocSharp.Docx
Description
When converting a
.docxdocument to Markdown usingDocSharp, URLs that contain parentheses (e.g., Wikipedia URLs) are not properly escaped or URL-encoded. This causes the resulting Markdown link syntax to break because the closing parenthesis of the URL prematurely terminates the Markdown link syntax[text](url).To reproduce
.docx) containing a hyperlink with parentheses, such ashttps://en.wikipedia.org/wiki/Mole_(unit)(or download docsharp-link-bug.docx )Expected Behavior:
The URL should have its parentheses URL-encoded (
(to%28and)to%29) so it doesn't break the Markdown syntax.(For comparison, Python's
markitdownhandles this correctly):Actual Behavior (Bug):
The raw parentheses are preserved inside the link destination, which causes markdown parsers to fail at rendering the link properly:
Screenshot
No response
Version
0.20.0
.NET version
.NET framework 4.7.2
OS
Windows 11 26100