diff --git a/ldoc/markup.lua b/ldoc/markup.lua index 9b7fab8..1b25ef2 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -171,6 +171,7 @@ local function process_multiline_markdown(ldoc, txt, F, filename, deflang) end pretty_code (code,fence) line = getline() -- skip fence + if not line then break end end indent, line = indent_line(line) if indent >= 4 then -- indented code block diff --git a/ldoc/prettify.lua b/ldoc/prettify.lua index 06727e5..a57eddc 100644 --- a/ldoc/prettify.lua +++ b/ldoc/prettify.lua @@ -50,6 +50,7 @@ function prettify.lua (lang, fname, code, initial_lineno, pre, linenos) io.stderr:write(fname..':'..tok:lineno()+initial_lineno..': '..msg,'\n') end } + local last_t, last_val local t,val = tok() if not t then return nil,"empty file" end while t do @@ -71,8 +72,12 @@ function prettify.lua (lang, fname, code, initial_lineno, pre, linenos) else res:append(val) end + last_t, last_val = t,val t,val = tok() end + if last_t == 'comment' then + res[#res] = span('comment',last_val:gsub('\r*\n$','')) + end local last = res[#res] if last:match '\n$' then res[#res] = last:gsub('\n+','')