Skip to content

Markdown parser for table of contents #8347

Open
@Levi-Lesches

Description

@Levi-Lesches

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:

/// Describes a tree node in the table of contents hierarchy.
class TocNode {
/// The text label to be display.
final String label;
/// The link href to use, if omitted, only a regular text is displayed.
final String? href;
/// Children nodes of this node.
List<TocNode>? children;
TocNode(
this.label, {
this.href,
this.children,
});
}

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions