Bug with TableCell Span range #590

Closed
opened 2026-01-29 14:40:30 +00:00 by claunia · 1 comment
Owner

Originally created by @Nintynuts on GitHub (Feb 26, 2023).

I'm parsing files located here: https://github.com/MicrosoftDocs/win32/tree/docs/desktop-src/direct3dhlsl, so I can't modify the source file. I'm using the latest nuget release.

The table is a pipe table, not an HTML one, so I'm using .UseAdvancedExtensions() (and .YamlFrontMatter()) in my pipeline, to parse these markdown documents that contains pipe tables with some HTML in the cells. The problem is that the MarkdownObject span range is 10 characters too short, and doesn't include the entire cell contents.

This is the table row:

| <span id="dest"></span><span id="DEST"></span>*dest*<br/> | \[in\] The address of the result of the operation.<br/> |

I get:

<span id="dest"></span><span id="DEST"></span>*

Instead of:

<span id="dest"></span><span id="DEST"></span>*dest*<br/>

To fix this, I checked the inlines of the paragraph block and found that the 'dest' bit was just '*', and the containing block's span only went up to this inline. To work around I used the last inline's end to determine the span instead of the provided property, which fixed my issue.

Here's the code I used to work around it:

var span = md is ParagraphBlock { Span: var pbSpan, Inline.LastChild.Span.End: var end } && pbSpan.End < end ? new SourceSpan(pbSpan.Start, end) : md.Span;

I suspect that this is a bug, and I would appreciate it if you could investigate further and possibly fix it. Thank you for your help!

Originally created by @Nintynuts on GitHub (Feb 26, 2023). I'm parsing files located here: `https://github.com/MicrosoftDocs/win32/tree/docs/desktop-src/direct3dhlsl`, so I can't modify the source file. I'm using the latest nuget release. The table is a pipe table, not an HTML one, so I'm using `.UseAdvancedExtensions()` (and `.YamlFrontMatter()`) in my pipeline, to parse these markdown documents that contains pipe tables with some HTML in the cells. The problem is that the `MarkdownObject` span range is 10 characters too short, and doesn't include the entire cell contents. This is the table row: ```md | <span id="dest"></span><span id="DEST"></span>*dest*<br/> | \[in\] The address of the result of the operation.<br/> | ``` I get: ```html <span id="dest"></span><span id="DEST"></span>* ``` Instead of: ```html <span id="dest"></span><span id="DEST"></span>*dest*<br/> ``` To fix this, I checked the inlines of the paragraph block and found that the '*dest*' bit was just '*', and the containing block's span only went up to this inline. To work around I used the last inline's end to determine the span instead of the provided property, which fixed my issue. Here's the code I used to work around it: ```csharp var span = md is ParagraphBlock { Span: var pbSpan, Inline.LastChild.Span.End: var end } && pbSpan.End < end ? new SourceSpan(pbSpan.Start, end) : md.Span; ``` I suspect that this is a bug, and I would appreciate it if you could investigate further and possibly fix it. Thank you for your help!
claunia added the bugPR Welcome! labels 2026-01-29 14:40:30 +00:00
Author
Owner

@xoofx commented on GitHub (Feb 27, 2023):

Thanks for the report.

I suspect that this is a bug, and I would appreciate it if you could investigate further and possibly fix it. Thank you for your help!

I have no time these days working on Markdig, so PR welcome.

@xoofx commented on GitHub (Feb 27, 2023): Thanks for the report. > I suspect that this is a bug, and I would appreciate it if you could investigate further and possibly fix it. Thank you for your help! I have no time these days working on Markdig, so PR welcome.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#590