Reindent C.reformat function
@@ -72,9 +72,13 @@ function C.reformat(input)
for line in input:gmatch("([^\n]*)") do
line = line:match("^[ \t]*(.-)[ \t]*$")
- -- Collapse groups of empty lines into a single empty line.
+ -- Collapse toplevel blank lines into a single one
local is_blank = (#line == 0)
- if not (is_blank and previous_is_blank) then
+ local skip = is_blank and previous_is_blank
+ previous_is_blank = is_blank
+ if skip then
+ goto continue
+ end
local nspaces
if line:match("^#") then
@@ -114,8 +118,8 @@ function C.reformat(input)
table.insert(out, string.rep(" ", nspaces))
table.insert(out, line)
table.insert(out, "\n")
- end
- previous_is_blank = is_blank
+
+ ::continue::
end
return table.concat(out)
end
