-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PipeTableParser strip opening and ending characters #775
Comments
It might be a bug in the position (not all elements, specially the one not CommonMark like table are necessarily tested for their text position) That being said, this
|
@xoofx Yes, you're right. This is so much easier. public static string ExtractText(string text, Block item)
{
return text.Substring(item.Span.Start, item.Span.Length);
} But the Markdig.Extensions.Tables.Table is still missing the first and last characters when parsing syntax. Here is my workaround for this issue: public static string ExtractText(string text, Markdig.Syntax.Block item)
{
var start = item.Span.Start;
var end = item.Span.End;
var len = item.Span.Length;
if (item is Markdig.Extensions.Tables.Table)
{
start--;
end++;
len += 2;
}
// Markdig.Extensions.Tables.Table is missing the first and last characters when parsing syntax
return text.Substring(start, len);
} |
As I know, +-------------+-------------+
| Header 1 | Header 2 |
| ----------- | ----------- |
| Row 1 Col 1 | Row 1 Col 2 |
| Row 1 Col 1 | |
+-------------+-------------+ And the | Header 1 | Header 2 |
| ----------- | ----------- |
| Row 1 Col 1 | Row 1 Col 2 |
| Row 2 Col 1 | Row 2 Col 2 | In the GridTableParser.cs, the But in PipeTableBlockParser.cs, the The PipeTable's codebase is still too complicated to me. I still can't find the bug. |
Because this is coming from https://pandoc.org/MANUAL.html#extension-grid_tables
Because this is coming from GitHub behavior and also https://pandoc.org/MANUAL.html#extension-grid_tables |
Do you mean this format? - | Header 1 | Header 2 |
| ----------- | ----------- |
| Row 1 Col 1 | Row 1 Col 2 |
| Row 2 Col 1 | Row 2 Col 2 |
|
As explained in the comment of PipeTableBlockParser here it is to discard list (that can start with a | b
- | -
0 | 1 which is not supported by GitHub but was supported by pandoc. See the comparison here. The parser for pipe tables is more complicated because we can only detect it after we have processed a paragraph, so that's why it is an inline parser and not a block parser. |
I never know that. I always think it's a block parser. Can you implement another block-based PipeTable parser? I never know there is a scenario for inline usage. At least I have never used it this way. 😅 |
It is not an inline usage. In order to parse a "block" pipe table, we can only use
Is initially parsed as a paragraph because we don't know when parsing That's why the pipetable is so complicated because we are treating A naive implementation could have said: I'm just gonna split the line by |
Can you take a look on why PipeTable missing 2 characters? I'd like to fix the bug but I can't find the entry point of the position info. |
Here is my code that can run under LINQPad:
When running this code, the parsed output will remove the opening and ending characters. It seems a bug.
The text was updated successfully, but these errors were encountered: