diff --git a/frontmatter.lua b/frontmatter.lua index ca9d9ac..bed2710 100644 --- a/frontmatter.lua +++ b/frontmatter.lua @@ -37,6 +37,11 @@ local function split_at_separator(content) for i = 2, sep_idx - 1 do json_lines[#json_lines + 1] = lines[i] end local body_lines = {} for i = sep_idx + 1, #lines do body_lines[#body_lines + 1] = lines[i] end + -- Drop the trailing empty entry produced by the final LF appended above, + -- so the body matches user expectation ('body text' rather than 'body text\n'). + if #body_lines > 0 and body_lines[#body_lines] == "" then + body_lines[#body_lines] = nil + end return table.concat(json_lines, "\n"), table.concat(body_lines, "\n") end