issue #240 blank line after comment at end of code block. Crash with fenced block at end of document fixed

This commit is contained in:
Steve Donovan 2016-06-27 15:27:15 +02:00
parent 9f259c59be
commit c9b6483d6d
2 changed files with 6 additions and 0 deletions

View File

@ -171,6 +171,7 @@ local function process_multiline_markdown(ldoc, txt, F, filename, deflang)
end end
pretty_code (code,fence) pretty_code (code,fence)
line = getline() -- skip fence line = getline() -- skip fence
if not line then break end
end end
indent, line = indent_line(line) indent, line = indent_line(line)
if indent >= 4 then -- indented code block if indent >= 4 then -- indented code block

View File

@ -50,6 +50,7 @@ function prettify.lua (lang, fname, code, initial_lineno, pre, linenos)
io.stderr:write(fname..':'..tok:lineno()+initial_lineno..': '..msg,'\n') io.stderr:write(fname..':'..tok:lineno()+initial_lineno..': '..msg,'\n')
end end
} }
local last_t, last_val
local t,val = tok() local t,val = tok()
if not t then return nil,"empty file" end if not t then return nil,"empty file" end
while t do while t do
@ -71,8 +72,12 @@ function prettify.lua (lang, fname, code, initial_lineno, pre, linenos)
else else
res:append(val) res:append(val)
end end
last_t, last_val = t,val
t,val = tok() t,val = tok()
end end
if last_t == 'comment' then
res[#res] = span('comment',last_val:gsub('\r*\n$',''))
end
local last = res[#res] local last = res[#res]
if last:match '\n$' then if last:match '\n$' then
res[#res] = last:gsub('\n+','') res[#res] = last:gsub('\n+','')