jamalsenouci / sublimetext-syntaxfold

Sublime Text Plugin that provides a configurable command and popup for folding code based on syntax
MIT License
40 stars 6 forks source link

How to set custom syntax #1

Closed stevepowell99 closed 9 years ago

stevepowell99 commented 9 years ago

Not quite clear how to use this. I want to fold knitr markdown code chunks I tried putting this in Packages/User/syntax_fold.sublime_settings but I don't get offered knitr as an option when I press shift F5. What do I need to add?

"knitr":
    {
        "endMarker": "```$",
        "name": "Knitr",
        "startMarker": "```\\{r(.*)\\}"
    }
jamalsenouci commented 9 years ago

The basic structure of the settings should be as in: https://github.com/jamalsenouci/sublimetext-syntaxfold/blob/master/syntax_fold.sublime-settings so if you copy and paste that code and just replace: { "name":"Example", "startMarker": "'#Start", "endMarker":"'#End" }, with: { "name":"Knitr", "startMarker": "\\{r(.*)\\}", "endMarker":"$" },

then it should work, i'm not able to test it at the moment as I'm away from home and only have my chromebook with me so no sublime text. Let me know if that doesn't work and i'll have a look at it when I get back in a couple of days.

stevepowell99 commented 9 years ago

That works, thanks for clarification!

detyro commented 9 years ago

Hi I have been struggling with trying to get this to work with Markdown headers. e.g.

heading

hide when folding

hide this too hide this

hide this

hide this

break here

Next heading

Any help to get the folding t work with # ## style heading tags??

Thanks

stevepowell99 commented 9 years ago

you might want to look at smartmarkdown package - that can do hierarchical folding with ## style markdown.

jamalsenouci commented 9 years ago

Yeah I agree with Steve, it's best to go for a package specifically suited to markdown. This was more designed for folding code blocks which have a start and end marker.

Having said that I will add in the functionality to fold based on a single marker as it might be useful for another case and would only require a few more lines of code.

jamalsenouci commented 9 years ago

Ok so with the latest version you could achieve what you want using the regular expression "^#(?!#)" as your startMarker which is looking for a line starting with only one # so include that in your config like this { "name": "Markdown Headers", "startMarker": "^#(?!#)" }