mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
PipeTableParser strip opening and ending characters #658
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doggy8088 on GitHub (Feb 22, 2024).
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.
@xoofx commented on GitHub (Feb 29, 2024):
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
ExtractTextfunction feels complicated to extract the line/column/span information. Not sure why you are not using the properties behind (Span, Line, Column) here@doggy8088 commented on GitHub (Jul 2, 2024):
@xoofx Yes, you're right. This is so much easier.
But the Markdig.Extensions.Tables.Table is still missing the first and last characters when parsing syntax. Here is my workaround for this issue:
@doggy8088 commented on GitHub (Jul 2, 2024):
As I know,
GridTablelooks like this:And the
PipeTableshould looks like this:In the GridTableParser.cs, the
OpeningCharactersis+.But in PipeTableBlockParser.cs, the
OpeningCharactersis-. Why-?The PipeTable's codebase is still too complicated to me. I still can't find the bug.
@xoofx commented on GitHub (Jul 2, 2024):
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
@doggy8088 commented on GitHub (Jul 2, 2024):
Do you mean this format?
@xoofx commented on GitHub (Jul 2, 2024):
As explained in the comment of PipeTableBlockParser here it is to discard list (that can start with
-).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.
@doggy8088 commented on GitHub (Jul 2, 2024):
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. 😅
@xoofx commented on GitHub (Jul 2, 2024):
It is not an inline usage. In order to parse a "block" pipe table, we can only use
|because we could only detect if a paragraph is actually a table once we have parsed its content. That means that:Is initially parsed as a paragraph because we don't know when parsing
athat it is actually a table after (e.g you could have a backsticka ``|`` bthat is actually escaping the table).That's why the pipetable is so complicated because we are treating
|as a delimiter (similar to*or_or emphasis), and then from there, we are trying to rebuild a table.A naive implementation could have said: I'm just gonna split the line by
|but that's not the solution that was taken.@doggy8088 commented on GitHub (Jul 3, 2024):
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.