-
Notifications
You must be signed in to change notification settings - Fork 41
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
Folding Markdown headings #5423
Comments
I'm glad I found this, I just finished leaving a comment on #101 with this same puzzling behavior. The explanation seems to be that the region-end detection has no memory, so when it uses (in my syntax) This looks like a design flaw with the A proposal would be to have a |
Here's another attempt to fold markdown headings per level. Folding a level 2 heading works, if level 3 headings are already folded. Otherwise Fold.tmPreferences<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>text.html.markdown</string>
<key>settings</key>
<dict>
<key>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>markup.heading.1 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>markup.heading.2 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.2 - markup.quote - meta.list,
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>markup.heading.3 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.3 - markup.quote - meta.list,
markup.heading.2 - markup.quote - meta.list,
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>markup.heading.4 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.4 - markup.quote - meta.list,
markup.heading.3 - markup.quote - meta.list,
markup.heading.2 - markup.quote - meta.list,
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>markup.heading.5 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.5 - markup.quote - meta.list,
markup.heading.4 - markup.quote - meta.list,
markup.heading.3 - markup.quote - meta.list,
markup.heading.2 - markup.quote - meta.list,
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>markup.heading.6 meta.whitespace.newline - markup.quote - meta.list</string>
<key>end</key>
<string>
markup.heading.6 - markup.quote - meta.list,
markup.heading.5 - markup.quote - meta.list,
markup.heading.4 - markup.quote - meta.list,
markup.heading.3 - markup.quote - meta.list,
markup.heading.2 - markup.quote - meta.list,
markup.heading.1 - markup.quote - meta.list
</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
<dict>
<key>begin</key>
<string>meta.code-fence.definition.begin</string>
<key>end</key>
<string>meta.code-fence.definition.end</string>
<key>excludeTrailingNewlines</key>
<true/>
</dict>
</array>
</dict>
</dict>
</plist> |
This commit enables scope based folding of headings and fenced code blocks. Note: It does not add folding by heading level due to sublimehq/sublime_text#5423
Description of the bug
A general question about syntax based folding is how to achieve something like folding markdown headings of certain levels via fold buttons.
MarkdownEditing can already fold sections via key bindings. It would be cool to bind those functions to the fold buttons of a heading or achieve same behavior using syntax based folding.
A PoC of a
Fold.tmPreferences
is attached below, but it seems not to work as expected.Steps to reproduce
Expected behavior
Folding a Heading of leval
x
should fold everything until a heading of levelx
orx-n
is found.Seems to work correctly for headings of level 3.
Actual behavior
Behavior fails for heandings of level
x
if followed by headings of levelx+n | n>0
.See how
heading 2
andheading 3
fold as expected, butheading 1
orheading 1.1
don't.Sublime Text build number
4133
Operating system & version
Windows 11
(Linux) Desktop environment and/or window manager
No response
Additional information
Markdown/Fold.tmPreferences
Test File
OpenGL context information
No response
The text was updated successfully, but these errors were encountered: