Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Keep track of ordered list indexes and render them#1407

Merged
Kleidukos merged 2 commits into
haskell:ghc-9.2from
simmsb:fix-ordered-list-sequence-numbers
May 3, 2022
Merged

Keep track of ordered list indexes and render them#1407
Kleidukos merged 2 commits into
haskell:ghc-9.2from
simmsb:fix-ordered-list-sequence-numbers

Conversation

@simmsb

@simmsb simmsb commented Jun 9, 2021

Copy link
Copy Markdown
Collaborator

Currently, when ordered lists are parsed the sequence/index numbers of the list
items are discarded at the parser.

This PR changes DocOrderedList to also keep track of the sequence number, and
updates the HTML and JSON (though I'm unsure on how changes to the JSON backend
should be dealt with) backends to include these. The hoogle backend remains
unchanged.

Resolves #1406

@Kleidukos Kleidukos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you very much @simmsb. :) Could you please indicate each time the index appears in a tuple/function parameter that the variable is indeed an index? Such as replacing (x, a) with (index, a)? :)

@mpickering

Copy link
Copy Markdown
Collaborator

Commonmark only pays attention to the first index in the list. So for example:

1. foo
3. foo

Renders as

1. foo
2. foo

https://spec.commonmark.org/dingus/?text=1.%20asdsad%0A3.%20asdasd%0A

@simmsb

simmsb commented Jun 11, 2021

Copy link
Copy Markdown
Collaborator Author

Seems so, would that be the preferred behavior?

@Lysxia

Lysxia commented Jun 11, 2021

Copy link
Copy Markdown
Contributor

I wonder what the reason for that spec is. I once read that it reduces diffs when you remove an element in the middle of a large list, but that seems a rather niche concern. For a tool like haddock it seems preferable to give more control to the user.

@Kleidukos Kleidukos merged commit 35c99f5 into haskell:ghc-9.2 May 3, 2022
Kleidukos pushed a commit to Kleidukos/haddock that referenced this pull request Jan 11, 2023
* Keep track of ordered list indexes and render them

* Rename some identifiers to clarify
Kleidukos pushed a commit to Kleidukos/haddock that referenced this pull request Jan 23, 2023
* Keep track of ordered list indexes and render them

* Rename some identifiers to clarify
@sol

sol commented Jun 19, 2024

Copy link
Copy Markdown
Member
  1. This is a breaking change and this breaks existing documentation!

    Specifically, it is a common pattern to introduce each list item with 1., say:

    1. foo
    1. bar
    1. baz
    
  2. There is prior art for the original behavior. Other formats, like Markdown (CommonMark, GFM, ...), MediaWiki and RST don't require you to micromanage list indices. For a user who is familiar with those formats, the new behavior is surprising.

  3. In software development, if I have two alternative options on how to proceed, if I can make an equally good case for both options, but one of the options is backwards compatible and the other option introduces a breaking change, then I proceeded with the backwards compatible option.

From my perspective it would have been better if this PR would never have landed, but that ship has sailed. I think the best bet for damage control is to do what CommonMark and GFM do and

only pays attention to the first index in the list

as @mpickering pointed out.

As for the motivating example from #1406, I think this is what definition lists are meant for.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ordered lists always start at 1.

5 participants