Created
December 22, 2009 02:12
-
-
Save Shougo/261441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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