-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix line wrapping within inline code #130
base: main
Are you sure you want to change the base?
Conversation
bdbb054
to
47f1af8
Compare
Correctly applies line wrapping to inline code blocks. See [the issue][129] and [fix PR][fix] for more details. [issue]: dprint/dprint-plugin-markdown#129 [fix]: dprint/dprint-plugin-markdown#130
Friendly ping/nudge here @dsherret! I’m sure you’re busy, but would love to see this upstream. |
The behavior at the time of introducing this test is: - An initial line wrap for a too-long line is correct. - When the plugin finds inline code wrapping across a line and decides to rewrap it, it inserts an additional `>` at the end of the leading line. This is a *new* failure mode introduced by the previous change, which added the first support for handling wrapping inline code across lines at all.
!! should rewrap inline code across lines in blockquote !! | ||
> Testing `this | ||
> out`. | ||
|
||
[expect] | ||
> Testing `this out`. | ||
|
||
!! should rewrap inline code across lines which are too long in blockquote !! | ||
> This is some long text, which will have a bit of inline code across the `80 character limit` and then more after that. | ||
|
||
[expect] | ||
> This is some long text, which will have a bit of inline code across the `80 | ||
> character limit` and then more after that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discovered this failure mode while testing this PR against the Rust book, where there are a few of these. Should hopefully have a fix in for this tomorrow morning!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving some breadcrumbs here for myself, given I do not expect to get back to this till January—I spent some time chasing this (after beating my head against the wall that is getting useful debugging set up for Rust 😑) and concluded so far that it is down to something amiss in how dprint-plugin-markdown
is using the result of parsing from pulldown-cmark
, but haven’t gotten further than that.
Specifically, it ends up seeing an inline code snippet that wraps across a line in a blockquote as including the >
character. It will correctly introduce the wrapping for a too-long line, but is not stable because once it has done so, on the next formatting pass it will then interpret it as part of the inline code instead of as a blockquote marker.
A side observation: this is just a challenging issue. Here is a simple sample that I used for testing pulldown-cmark
itself locally:
> This is some `inline
> code`. And it gets
> *rendered* just fine.
> The problem is thus
> not `pulldown-cmark`
> but something in how
> `dprint` uses it.
Notice how GitHub’s (line-wrapping-aware) renderer trips in a different way over the exact same thing, not wrapping when it should:
This is some
inline code
. And it gets
rendered just fine.
The problem is thus
notpulldown-cmark
but something in how
dprint
uses it.
gen_code
callgen_str
with the string it builds, before returning it.Fixes #129.
Note that the failing test results in a timeout after the panic, rather than failing the test suite:
Test output