Skip to content

Instantly share code, notes, and snippets.

@Shougo
Created December 22, 2009 02:12
Show Gist options
  • Save Shougo/261441 to your computer and use it in GitHub Desktop.
Save Shougo/261441 to your computer and use it in GitHub Desktop.
function! s:ParseMarkdown()
let l:lines = getline(1,line("$"))
let l:pages_lines = []
let s:pages = []
echo "Parsing..."
for l:line in l:lines
if l:line =~ '^#\+'
if !empty(l:pages_lines)
call add(s:pages, join(l:pages_lines, "\r\n"))
endif
let l:pages_lines = [ l:line ]
elseif !empty(l:pages_lines)
call add(l:pages_lines, l:line)
endif
endfor
if !empty(l:pages_lines)
call add(s:pages, join(l:pages_lines, "\r\n"))
endif
let s:max_page_number = len(s:pages)-1
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment