New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🗳 Add new table-of-contents validator #1151
Conversation
Looking good, some thoughts below as I go through this. Some of the things we can maybe choose to add:
Options like Is there some way to apply default classes? i.e. a top-level |
Notes from a meeting on this:
|
@rowanc1 I've updated this PR to add |
@rowanc1 the schema generator has a dependency on NodeJS>=18 due to |
I think class makes sense on every node? Thinking about that |
26ab792
to
d0414f9
Compare
@rowanc1 is this good to go in your view? If so, feel free to merge! The plan is that another PR will hook this into the config side of MyST-MD |
I will take it for a spin this afternoon and get it in and released! |
1681244
to
1828e6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types look good here. I think things will change a bit when we integrate it with myst-frontmatter
, but that can happen in the next iteration.
content: | ||
- file: foo.md | ||
hidden: "yes" | ||
throws: 'The given contents do not form a valid TOC' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to get nicer errors here to show to users. I suspect when we integrate this into myst-frontmatter, we will use the simple-validators
as that does now, which will allow us to have coercion and better validation messages that work with where we are at now.
In #1102, we identified the need for a new table of contents format.
This format must satisfy the following goals:
This PR is a WIP in that direction. The TOC schema can be build using
and then used with https://www.jsonschemavalidator.net/ (or the CLI equivalent) to verify a TOC JSON blob.
Here's an example "complex" TOC:
There are notably two kinds of "subtrees" in MyST:
This TOC supports both; a bare
children
entry requires atitle
, whereas a file/URL entry does not.@rowanc1 also mentioned the ability to choose between drop-downs and fixed-headings. This TOC format has a
class
string field that we could use to support that.We should iterate on this as necessary!
Closes #1102