From c9b6483d6dc4f09cd9110e5b84f56f24e6a9f669 Mon Sep 17 00:00:00 2001 From: Steve Donovan Date: Mon, 27 Jun 2016 15:27:15 +0200 Subject: [PATCH] issue #240 blank line after comment at end of code block. Crash with fenced block at end of document fixed --- ldoc/markup.lua | 1 + ldoc/prettify.lua | 5 +++++ 2 files changed, 6 insertions(+) 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+','')