Skip to content
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

Header rendering bug #411

Open
rdelepine opened this issue Jul 26, 2016 · 2 comments
Open

Header rendering bug #411

rdelepine opened this issue Jul 26, 2016 · 2 comments
Labels

Comments

@rdelepine
Copy link

| Test \| | Test |
||
| Test    | Test |
| Test \| | Test |

3 columns instead of 2 in the header

In blockTable method.
Change

$dividerCells = explode('|', $divider);

foreach ($dividerCells as $dividerCell) {

To

preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $divider, $matches);

foreach ($matches[0] as $dividerCell) {

And

$headerCells = explode('|', $header);

foreach ($headerCells as $index => $headerCell) {

To

preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $header, $matches);

foreach ($matches[0] as $index => $headerCell) {
@douglasawh
Copy link

@rdelepine I don't understand the issue. I think it might be related to an issue I am seeing, but I am not sure. What are the columns you speak of? Are you saying you get

Test Test Test
Test Test Test

instead of what you have in your example? I left out the |\ characters, but I hope my question still makes sense.

@aidantwoods It looks like a fix was provided. Is there a reason the fix was not included? Maybe I'm misreading it. I'm just curious if this is something we could implement on our end, or if there are known issues.

@richardkmichael
Copy link

I encountered this today too. Perhaps a rare case, but since this parser is used by the popular MediaWiki, it would be helpful to have fixed.

@douglasawh

The bug is that in header field content, the parser is not interpreting (and consuming) the backslash \ as an escape-prefix for the column divider |. Instead, the backslash is output and then | is interpreted as a column divider.

The header therefore contains three columns (the second empty), while the data rows have only two columns. Easily seen by pasting the OP's provided bug reproducing markdown in the Parsedown demo.

Notice the backslash-escaped vertical divider in the second data row is correctly consumed, and escapes the divider, so it appears in the cell output. This is what should happen in the header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants