Skip to content

Add test cases for list markers and tightness - #154

Open
karlb wants to merge 2 commits into
jgm:mainfrom
karlb:test-list-markers-tightness
Open

karlb wants to merge 2 commits into
jgm:mainfrom
karlb:test-list-markers-tightness

Conversation

@karlb

@karlb karlb commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

task_lists.test separates lists by bullet character but never mixes a task marker with a plain one, and writes every box lower-case. lists.test ends a list at a bullet of another kind but not at an ordered marker of another kind, so the blank line after that marker is never asked whether it loosens the list. Its ambiguous-marker cases resolve on the second item or stay ambiguous, so neither a one-item i. list nor an item after the second deciding is covered.

The tightness cases pin two sentences of the spec -- blank lines at the end of a nested list do not count, and tightness is per list -- and that a tight item is still a container of blocks.


As with most of my test cases, these are cases an LLM got wrong when implementing a djot->HTML converter. Just let me know when you think the cases get too niche and bloat the test suite. I have a backlog of potentially upstreamable cases and only collect a few of them for a PR from time to time.

task_lists.test separates lists by bullet character but never mixes a
task marker with a plain one, and writes every box lower-case.
lists.test ends a list at a bullet of another kind but not at an
ordered marker of another kind, so the blank line after that marker is
never asked whether it loosens the list. Its ambiguous-marker cases
resolve on the second item or stay ambiguous, so neither a one-item
`i.` list nor an item after the second deciding is covered.

The tightness cases pin two sentences of the spec -- blank lines at the
end of a nested list do not count, and tightness is per list -- and
that a tight item is still a container of blocks.

All eight pass on main.
Comment thread test/lists.test
Comment on lines +171 to +177
```
- one

- sub
more

- two

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit awkward, huh? What if you want the outer list to be loose; is there any way to force that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the tight/loose list distinction at the syntax level in general, since I don't really think about that when writing lists. For me it would probably be fine to just switch to loose lists when one item contains more than one paragraph. But I didn't think much about it.

So to answer your question, no I don't see a way to force a loose list here.

If you don't count the blank lines as belonging to the sublist, the current behavior contradicts the spec, which counts blank lines "between blocks inside an item" against tightness. Here the blank line between one and the sublist is exactly that. Then again, the spec's own tight example (- two / blank / - sub) has the same shape, so the spec may need clarifying either way.

Comment thread test/lists.test Outdated
Comment on lines +218 to +219
A tight item still holds blocks, so one that opens with a fence is
not a paragraph of literal text:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand what was meant here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It came from a regression where a fenced block in a tight item was parsed as paragraph text. Without that context this reads strangely. Changed to

Items in a tight list can contain non-paragraph blocks:

Comment thread test/lists.test Outdated
Comment on lines +274 to +275
The same for an ordered list, where the blank line after `a.` is not
between two of the first list's items and does not loosen it:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit mysterious: since a. starts a second list, why is the first list being mentioned?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, not sure how I got there. Changed to

A blank line between two lists doesn't make either of them loose:

Comment thread test/lists.test Outdated
</ol>
```

That holds for a list of one item too:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What holds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cut a less relevant test case before and forgot to update the description in this one that referred to it. Changed to

A lone i. could be roman 1 or alphabetic 9. Roman wins:

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.

2 participants