experimental sections support #51
Loading…
Reference in a new issue
No description provided.
Delete branch "sections"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds experimental support for "section matter", this is for discussion only at this point. I'm not even sure if we should do this. There are some questions that need to answered before this can really work in a practical way.
What is "section matter"?
Section matter is like front-matter, but can be used to create multiple "front-matter" delimited sections in the same document. There have been a number of requests for this over the past few years, the most common use case I've seen is for creating slide decks, but I'm sure there are other uses (and I'd love to hear about them!).
What does it look like?
This is up in the air, but in principle it works something like this (although
---won't be good enough, this is just for the sake of discussion):Which would yield an object like this:
Assumptions
options.sectionsmust be defined as true (example:matter(string, { sections: true }))file.sectionswill be an array or object of "section" objects. Each section object will have adataandcontentproperty.file.contentswill contain the text preceding the first sectionDelimiters
I'd love some feedback on this.
Delimiters must be more than just
---, since that would easily conflict with normal markdown horizontal rules.If we need to keep it extremely simple, I propose that we at least use
----(4 instead of 3), but ideally we can use some kind of marker or label after the first delimiter, maybe even the second one as well.Ideas
Or, I could easily support all of the above formats with very little code, but we at least need some kind of marker and/or label to make sure we avoid false positives from collisions with markdown horizontal rules.
I like option 7 where it's the delimiter + the section name:
---Foo. Then the sections are returned as an object. This will allow other tools to use the sections in different ways.Also, with this pattern, I think we need to say that the front matter parser is what determines the parser for the section matter. If we want to support different parsers for section matter, then the delimiter would need to change.
I like this idea a lot and I can see tools using sections in many different ways.
Section matter is interesting, but I'd really love back-matter. Get that metadata off the top of the file: it's distracting when writing in version control and isn't meant for humans :)
Pull request closed