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

upgrade to pulldown-cmark 0.4.1 #2

Merged
merged 1 commit into from
Jul 3, 2019
Merged

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Apr 20, 2019

No description provided.

@euclio
Copy link
Contributor Author

euclio commented Apr 20, 2019

Hm, looks like pulldown-cmark 0.4.1 doesn't preserve leading and trailing whitespace in table cells anymore. Not sure if that's a regression or a fix.

@carols10cents
Copy link
Contributor

I tried this upgrade myself, and ran into the same issue :)

It looks like the whitespace stripping started in this PR, according to this comment.

I did some investigating in this commit and it seems like the spaces in the markdown that pulldown-cmark-to-cmark generates don't affect the parsing that pulldown-cmark does at all. That is, the test in that commit does the following:

  • Takes a markdown table
  • Parses it into pulldown-cmark Events
  • Generates markdown with pulldown-cmark-to-cmark
  • Parses the markdown generated by pulldown-cmark-to-cmark into pulldown-cmark Events again
  • Tests that the two lists of Events are identical

The generated markdown tables aren't as pretty as the original, but given that the purpose of pulldown-cmark-to-cmark is to make markdown for further programs to consume rather than people, this might be fine? I'm interested to see what Byron thinks :)

@ehuss
Copy link

ehuss commented Apr 25, 2019

It looks like 0.5 was released today. The main change is that inline code blocks are now Event::Code(str) instead of Event::Start…End. I looked at updating this, but there seems to be some bugs in how tables are handled, so I wasn't sure if that should be fixed. The lines here assume the table header contents only appear as a single event, but there can be multiple events. I think it should accumulate the length of all content between Start(TableCell) and End(TableCell) when inside Start(TableHead), but that didn't seem terribly easy.

@euclio
Copy link
Contributor Author

euclio commented May 16, 2019

Found another bug while trying to update this PR to 0.5.1: pulldown-cmark/pulldown-cmark#327

@ehuss Are the bugs in the table handling you found covered by any existing tests? I didn't see any other failures.

@ehuss
Copy link

ehuss commented May 16, 2019

No, I don't think any of the existing tests caught the issues I saw. Here's an example:

foo f x bar
1 2

In markdown:

`foo` f `x` | bar
------------|-----
1           | 2

The way these lines work probably needs to change. There can be multiple events within a single cell, so it should probably update the last table_alignments value for each event, then flush it when the cell closes. Unfortunately there are a lot of potential events (Text, Code, InlineHtml, etc.), and each one should be handled.

@carols10cents carols10cents mentioned this pull request May 18, 2019
@Byron Byron merged commit 9a87b4e into Byron:master Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants