pub-dev icon indicating copy to clipboard operation
pub-dev copied to clipboard

Markdown parser for table of contents

Open Levi-Lesches opened this issue 10 months ago • 1 comments

Continuing the conversation from #4371, the goal is to create a parser that accepts markdown as input as spits out a list of headings that can be easily formatted into a table of contents or similar.

@isoos From the other thread:

The TocNode is an incomplete API for this use case: it doesn't hold the content, it was created for a different reason, and while it could be simple to reuse it, it may be better to just have a clean start. As we really want to use this for changelog parsing too, it could be a better starting point to collect different kind of requirements for that and how it would look in a parsed form.

For reference, here is the TocNode class:

https://github.com/dart-lang/pub-dev/blob/4acdc2bdc3dce95832ad9171f2f2fef4f04a5fad/app/lib/frontend/templates/views/shared/toc.dart#L35-L51

Can you elaborate here:

  • Why is the content needed? For either the changelog or details page, isn't it enough to just have the title be a clickable link? Right now it is a string, I can definitely change it to be a markdown Node, but I don't see where we'd want the content to be
  • What exactly do we want for the Changelog page? A similar ToC of all releases? Should we nest for major/minor/patches? That would be tricky if the author did not use nested headers. I went through some older issues and PRs and couldn't really find a clear description of exactly what's wanted here
  • Should I make my new API be the new TocNode and refactor the admin page to use that?

Levi-Lesches avatar Dec 02 '24 11:12 Levi-Lesches