Skip to content

Add tightness and marker type to Tag::List - #1083

Open
SabrinaJewson wants to merge 1 commit into
pulldown-cmark:mainfrom
SabrinaJewson:list-tightness
Open

Add tightness and marker type to Tag::List#1083
SabrinaJewson wants to merge 1 commit into
pulldown-cmark:mainfrom
SabrinaJewson:list-tightness

Conversation

@SabrinaJewson

Copy link
Copy Markdown
Contributor

Add fields tight and marker_type to Tag::List to allow inspecting these two properties of the list. This is a breaking change.

These bits of information cannot otherwise be derived from the Markdown source. In particular, pulldown-cmark generates the same sequence of events for "- > first\n- > second" and "- > first\n\n- > second", even though the former is tight and the latter is loose.

My use case is for cmarker.typ, which converts Markdown into Typst, and currently does not account for the tightness or looseness of lists for this reason.

The variants of ListType were named after the Unicode names of the characters.

There is currently a logical invariant that start is Some if and only if marker_type.is_ordered(). It would be possible to redesign the library such that the type system forbids this; for example:

enum Tag<'a> {
    // …
    UnorderedList { tight: bool, marker_type: UnorderedListMarkerType },
    OrderedList { start: u64, tight: bool, marker_type: OrderedListMarkerType },
}
enum UnorderedListMarkerType { HyphenMinus, PlusSign, Asterisk }
enum OrderedListMarkerType { FullStop, RightParenthesis }

However, in favour of making the change minimally intrusive, I did not use this design.

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.

1 participant