xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.32k stars 448 forks source link

Unable to get original content for LinkReferenceDefinitionGroup #764

Open doggy8088 opened 8 months ago

doggy8088 commented 8 months ago

I'm parsing a Markdown document that contains LinkReferenceDefinitionGroup . When I call ToPositionText() method for that part of the MarkdownDocument, the line and column will be 0 and 0, and the Range is wrong too. I don't know how to fix this. Any hint?

var document = Markdown.Parse(markdownText);
var parts = document.ToList();
for (int i = 0; i < parts.Count; i++)
{
    var item = parts[i];
    if (item is Markdig.Syntax.LinkReferenceDefinitionGroup)
    {
        // item.Line = 0
        // item.Column = 0
        // item.ToPositionText(); // $0, 0, 0-79
    }
}
xoofx commented 8 months ago

LinkReferenceDefinitionGroup has no parsing equivalent so cannot have a representation in text. It is just used internally to group LinkReferenceDefinition and query for links.

doggy8088 commented 7 months ago

It because I use Markdig to traversal the Markdown document for translation purpose. I need to keep all the content as-is. When I parse to the LinkReferenceDefinitionGroup, I don't have the position info. So that I can't get the original content. I need that info the keep my final Markdown document complete.

Can you still provide Position info for this block?