From dc47af41efeb53da564951028a5ce720efb3a206 Mon Sep 17 00:00:00 2001 From: Lars Winderling Date: Tue, 24 May 2016 10:18:20 +0200 Subject: [PATCH] add non-breaking space to slides containing only a background image in order to prevent errors in displaying the image --- ftplugin/markdown.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 4dd355d..10f70ad 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -90,6 +90,10 @@ if !exists('g:vim_reveal_loaded') || g:vim_reveal_loaded == 0 endif endfunction + function! s:Trim(str) + return substitute(a:str, '^\s*\(.\{-}\)\s*$', '\1', '') + endfunc + function! s:GetContent() let content = [] 1 @@ -124,7 +128,18 @@ if !exists('g:vim_reveal_loaded') || g:vim_reveal_loaded == 0 elseif subsecno != '' let sectail = sectail+sectail endif - let content += sechead+subhead+getline(line('.')+1, endlineno)+subtail+sectail + let lines = getline(line('.')+1, endlineno) + let allEmpty = 1 + for line in lines + if s:Trim(line) != '' + let allEmpty = 0 + endif + endfor + if allEmpty + let content += sechead+subhead+[' ']+subtail+sectail + else + let content += sechead+subhead+lines+subtail+sectail + endif endif if line2 == 0 return content