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

Make list tightness match the reference implementation closer #150

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

notriddle
Copy link
Contributor

Fixes #144

This solves the problem where blank lines in the middle of a list are attributed to the list itself instead of the item, making its parent list become spurriously loose.

Given this reduced example, which helps understand the problem but not reproduce it:

 * -

   -

test

Consider this subset of the test case:

 1 | * -
   |     ^ first blank line of ListItem
 2 |
   |     ^ second blank line of ListItem
 3 |
   |     ^ the is what the commit changes:
   |       it used to be considered a blank in the List,
   |       but is now also considered part of the ListItem
 4 |   -
   |     ^ second ListItem takes its first blank, just like before
 5 |
   |  ^ as part of finalization, this second blank goes three two ownership changes:
   |    first, the `-` List takes it from its ListItem, because it's the last ListItem,
   |    and, second, the `*` List takes it from its child, because it's at the end
   |
 6 | test
   | ^ lists end here

The change in this commit changes the List to take ownership of a blank line only if its a trailing blank line at the end of a list item (like line 5) and never from the middle (like lines 3 and 2).

This solves the problem where blank lines in the middle of a list
are attributed to the list itself instead of the item, making
its parent list become spurriously loose.

Given this reduced example, which helps understand the problem
but not reproduce it:

```markdown
 * -

   -

test
```

Consider this subset of the test case:

 1 | * -
   |     ^ first blank line of ListItem
 2 |
   |     ^ second blank line of ListItem
 3 |
   |     ^ the is what the commit changes:
   |       it used to be considered a blank in the List,
   |       but is now also considered part of the ListItem
 4 |   -
   |     ^ second ListItem takes its first blank, just like before
 5 |
   |  ^ as part of finalization, this second blank goes three two ownership changes:
   |    first, the `-` List takes it from its ListItem, because it's the last ListItem,
   |    and, second, the `*` List takes it from its child, because it's at the end
   |
 6 | test
   | ^ lists end here

The change in this commit changes the List to take ownership
of a blank line only if its a trailing blank line at the end
of a list item (like line 5) and never from the middle
(like lines 3 and 2).
@jgm jgm merged commit 1ec2293 into jgm:master Mar 8, 2024
6 checks passed
@jgm
Copy link
Owner

jgm commented Mar 8, 2024

thanks!

@notriddle notriddle deleted the notriddle/blanks branch March 8, 2024 04:15
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.

[fuzz result] counterintuitive list tightness
2 participants