-
Notifications
You must be signed in to change notification settings - Fork 898
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
Handling of numbered markdown lists. #5423
Handling of numbered markdown lists. #5423
Conversation
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.
Thanks for your first contribution 🎉!
When you have a moment could you leave a comment referencing issue #5416 above these test cases so we can tie them back to the original issue. Something like:
//! This is a numbered list (see issue #5416):
//! 1. Long long long long long long long long long long long long long long long long long line
//! 2. Another very long long long long long long long long long long long long long long long line
//! 3. Nested list
//! A. foo
//! B. bar
//! 4. Last item
Overall I think these test cases are good. I would like to add a few more. When you have a chance could you add the following test cases:
- Use
)
instead of.
since you also added that functionality. - Can we also add a really deeply nested list (3 or 4 levels deep)
- Can we also have the deeply nested lists have enough content that they would wrap when
wrap_comments=true
is set. - It think it would be interesting to have a test case where we use both numbered and non numbered lists.
If you can think of any other test cases feel free to add them, but I think those additions would give us better test coverage!
@ytmimi - could you PTAL again? FWIW I don't use github daily, so please point out if there are some technical issues with how I addressed the feedback and/or how I attempted to rebase the PR on top of the tip of the tree. In particular, I am not sure if there are supposed to be 3 separate commits here: master...anforowicz:rustfmt:handling-numbered-lists (maybe I should instead amend the original commit used for the PR? or squash the 3 commits into one using some other mechanism...).
Done
Done (see the test that starts with: "Using the ')' instead of '.' character after the number")
Done (tweaked the original test - the one that now is called: "This is a numbered markdown list").
Done (the last test - "Deep list that mixes various bullet and number formats"). Sigils at the start of a line
I was wondering about sigils appearing at the start of a line in the middle of a paragraph. Some notes:
Maybe this should not be a list: The Captain died in
1868. He was buried in... But this should start a list (making a special case for 1 vs non-1; bullet items are a bit unclear): Our top priorities are
1. fix ordered lists But then in a follow-up discussion it was pointed out that it is not clear if 1 vs non-1 should be special-cased - wouldn't we need to require a blank like before each and every item: https://talk.commonmark.org/t/blank-lines-before-lists-revisited/1990/16 So, I think I don't want to make any changes in this direction in this PR, but maybe there are some notes / questions to consider:
|
First off, thanks for the thoughtful questions and all the linked discussion!
Understood! I do appreciate you taking the time to make those updates when you logged back on and saw the notification. Everyone's go their own way of responding to feedback and in this particular case I think just responding with "Done" is totally fine. I think had the ask been more involved than updating tests some additional discussion / clarification might have been needed, but we're good here!
Just a little bit of background before directly answering your question. We follow the rust compilers no-merge policy. I've updated my git config to always rebase instead of merge using You can look into interactive rebasing to squash your commits, but we can also just squash and merge the commits if you don't want to squash them yourself. In this case I think these changes make more sense as a single commit, but again don't feel obligated to squash them yourself.
It's an interesting thought. Given that the main goal of rustfmt is to format rust code I don't see the need to dive too deeply into those details, especially if it complicates the implementation. rustdoc using
Definitely something we'd be open to considering! This is also something I've thought about since we've got a few open issues related to markdown formatting. I briefly looked at pulldown-cmark-to-cmark, but haven't played around with trying to integrate it. I think the challenge with introducing a library to handle the markdown formatting is that we need to ensure that we don't introduce breaking formatting changes.
Feel free to open an issue if you'd like. As I mentioned, the main goal for rustfmt is to format rust code so markdown formatting is pretty low on the priority list and likely won't get much attention from the team any time soon as there's plenty on the backlog. That said, we'll certainly review PRs if there's anyone motivated enough to work on something like this. |
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.
Thanks for your work on this!
@ytmimi - what are the next steps here? Are there any actions that I need to take at this point (maybe somehow unmerging/rebasing the commits in my fork)? |
Again, thanks for your work on this. I'm still thinking through a few things. The examples you listed in #5423 (comment) has got me thinking and I'd like to play around with some inputs. Specifically referring to The Captain died in
1868. He was buried in... The issue you outlined there would also apply to the end of sentences since after this change we allow Testing the following (curtesy of wikipedia) with your branch I get: intput //! Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air
//! moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), Fe(OH)3), and is typically associated with the corrosion of refined iron.
output //! Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction
//! of iron and oxygen in the catalytic presence of water or air
//! moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and
//! iron(III) oxide-hydroxide (FeO(OH), Fe(OH)3), and is typically
//! associated with the corrosion of refined iron
|
After thinking on it a bit more I found an edge case that would ned to be addressed before we could move forward
Some random notes:
|
Lots of good dialog here, thank you both! IIRC, rustdoc is using cmark or some form of it anyway, and I'm not inherently opposed to us trying a radically different approach as instead of the current strategy of continuing to bolt things on to support additional cases as they arise. However, any such radically different approach would need to be accompanied by some exhaustive tests (far more than what we have today) to avoid, or at least minimize, the amount of churn we would inflict on our users. To be clear, I think this testing would need to entail running rustfmt with new approach over various projects that are currently utilizing the feature. The associated config options that hit this in the first place are still unstable, but it's still incumbent upon us to be cautious given the potential impact. Additionally, we'd also need to ensure continued interop with other relevant options and behavior, potential future behavior, and be mindful about any extra dependency bloat considering it's an opt-in feature. |
@ytmimi, could you please share more details about the edge case that needs to be addressed to unblock this PR? (I might not reply for a while - I'll be away from a computer for a bit of summer vacation :-) |
@anforowicz apologies for the delay. I have some reservations based on the case you outlined in
I like this as a workaroud to limiting the issue. Erring on the side of caution I'd also like to limit it to just numeric values, instead of also trying to support upper and lowercase ascii letters. I feel like that's a good compromise that will address the issue you ran into in #5416 |
Thanks @ytmimi! Can you PTAL again? (Again - my apologies for the hap-hazardous git and github - hopefully the separate commits in my fork can be merged as a single commit?) |
@anforowicz no worries. I should have some time in the coming week to review this again. |
@ytmimi - gentle ping? Maybe this got missed because this PR is incorrectly marked as pr-waiting-on-author. |
r? @cynecx |
@rustbot label -pr-waiting-on-author +pr-follow-up-review-pending |
e88c3d1
to
db64c83
Compare
db64c83
to
6bbbe5c
Compare
@ytmimi - this PR should be ready for another review pass please. In addition to resolving the PR feedback above I also did some other minor changes:
|
@anforowicz thanks for turning around the feedback so quickly. I haven't looked at the changes yet, but from your description above they seem reasonable. I also wanted to let you know that I approved #5560. We haven't merged it yet, but I think it makes sense to merge that PR before this one. There will likely be some merge conflicts once that PR is merged so I wanted to give you a heads up. It might make sense to subscribe to that PR so you know when it's merged. |
As anticipated the merging of #5560 has introduced some merge conflicts, but I gather we should be ready to go with this once those conflicts are resolved. |
9de7121
to
16bbdeb
Compare
Thanks for the quick resolution @anforowicz! @ytmimi - do you think this needs another quick pass, and then do you think this should be included in the next release or are shall we hold it till the following? |
@calebcartwright I took another look and I think this is good to go 👍🏼 and could be included in the next release, but I don't mind if we want to hold off until the following. |
16bbdeb
to
4f856ac
Compare
4f856ac
to
7c6dd82
Compare
@ytmimi - This seems like a worthwhile add to me, so more a question of when as opposed to if. Suppose the options are to merge it now/tomorrow and pull it into the next release (pre let-else support), or wait and then do it in the release that follows let-else. I'll defer to you on whether you think we should go ahead with this now based on your confidence level in the implementation and adherence to formatting stability guarantee. |
haven't looked at this one personally but per team meeting in discussion on zulip earlier Yacin's comfortable with this, so going to pull it in as the last addition in the next release |
Fixes issue #5416