masukomi / vim-markdown-folding

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

Option to turn of folding for headline tags mark with --- #3

Open wikimatze opened 11 years ago

wikimatze commented 11 years ago

Hi Drew I really love your plugin and I'm using it on my daily basis for writing articles in markdown. Since I'm using Jekyll for running my blog, I'm also using the YAML settings at the beginning of each markdown file.


---
layout: post
title: here goes the article of a new post
meta-description: <---- Here begins the first fold level because of the special headline marks 

---

## The kitchen timer <-- here should be the first level of the folding level

...

If you have problems with following the example above, please consult the example below:

  1 ---
  2 layout: post
  3 title: On My Way On Becoming a Self-Certified Pomodoro Master
  4 ## meta-description: Motivation for the ongoing series of becoming a Self-Certiefied Pomodoro Master [12 lines]-----------
 17 ## Why? [22 lines]--------------------------------------------------------------------------------------------------------
 40 ## The First Pomodoro [36 lines]------------------------------------------------------------------------------------------
 77 ## Following the six objectives [17 lines]--------------------------------------------------------------------------------
 95 ## Conclusion [9 lines]---------------------------------------------------------------------------------------------------

Cheers

Matthias

nelstrom commented 11 years ago

If the vim-markdown syntax highlighting could identify the YAML front matter, then this problem would be easy to fix. It doesn't just now, but @PProvost's vim-markdown-jekyll plugin adds this functionality.

nelstrom commented 11 years ago

So, I just tried installing vim-markdown-jekyll, and it doesn't play nicely with some features in vim-markdown. Specifically, the jekyll plugin overrides the handling of fenced code blocks in markdown. The vim-markdown-folding plugin dependes on recognising fenced code blocks to solve issue 1.

wikimatze commented 11 years ago

I see. I watched into the jekyll file https://github.com/PProvost/vim-markdown-jekyll/blob/master/after/syntax/markdown.vim and found this:

" YAML front matter
syntax match Comment /\%^---\_.\{-}---$/ contains=@Spell

" My unfinished attempt at getting YAML syntax in the front matter
" NOT WORKING
" syntax include @yaml $VIMRUNTIME/syntax/yaml.vim
" syntax region jekyllFrontMatter start=/\%^---/ end=/^---/ contains=@yaml

What we need is a function like checkJekyllFrontMatter() which does the job in your script. Since you have tests, I may try to build it as a training for myself. What do you think?

nelstrom commented 11 years ago

Knock yourself out! I wrote a test already. Check out the jekyll-front-matter branch.

wikimatze commented 11 years ago

Wow, very fast indeed.

greduan commented 11 years ago

So to fix this issue I should switch to the jekyll-front-matter branch?

wikimatze commented 10 years ago

Hi Drew, I have thought about the problem and it isn't a problem anymore. Every time I'm editing a blog post with a YAML front matter I am unfolding the whole markdown file to have an overall feeling of the document.

What help me more was detecting the YAML front matter information at the beginning of a document as a comment with the following line in my vimrc:

autocmd BufNewFile,BufRead */_posts/*.md syntax match Comment /\%^---\_.\{-}---$/

If you agree with me, I will close this issue.

Thanks for your help so far.

nelstrom commented 10 years ago

That's an interesting workaround!

Leave the issue open for now. You're not the only person who wants this, so it makes sense to provide some solution in this plugin.

wikimatze commented 10 years ago

I will track this issue further on.

greduan commented 10 years ago

Cool workaround @matthias-guenther! I'll be using it. :)