masukomi / vim-markdown-folding

Fold markdown documents by section.
248 stars 43 forks source link

ENH: Add foldlevel=7 for horizontal rules. #27

Closed inkarkat closed 5 years ago

inkarkat commented 7 years ago

According to John Gruber's spec and the Stack Overflow implementation, horizontal rules are defined by three or more hyphens, asterisks, or underscores (optionally separated by spaces) on a line.

Since horizontal rules are a (weak kind of) structuring mechanism, include them as foldlevel 7, after all possible headings.

masukomi commented 5 years ago

@inkarkat Thanks for the PR. I'm closing this for the following reasons:

I think we're going to need fold level 7 for lists ( see issue #33 )

I'm not sold on the idea of folding on a horizontal rule. It doesn't make much sense to me. A header is the start of a section. A horizontal rule is a divider between sections. Also, while I hope to eventually have folding an # result in folding up any ## and ### (and so on) that may be below it, I don't know what you'd do with an HR in this world. Assuming a document with 2 HRs in it (separated by text) does folding the first HR result in hiding the second one ? I don't know that yes or no are good answers.

Feel free to open a new issue requesting folding on HRs and if the community seems to want it we can try and find a way to do it that doesn't prevent the future folding of lists.

inkarkat commented 5 years ago

Alright, thank you for explaining your reasoning. I sometimes don't want to apply a header structure to a document, and then use horizontal rules to separate each section. A physical equivalent might be post-its, each posted at the bottom of the previous one. As they are discernible as individual entities, and can be shifted around, it's great (for moving or to obtain an overview) if each section can be folded to a single line. I thought that others do something similar, but it may be just me :-)

I don't get your argument about fold level 7 for lists. Typically, not all heading levels are used, neither, so skipping over fold levels is fine, and we can just assign one or the other to level 8. To me, horizontal rules are higher than list elements — I would never interrupt a list with a rule. That would then be modeled by horizontal rules as level 7, and lists as level 8.