1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-27 09:59:29 +00:00

don't add line mappin comments ad infinitum

This commit is contained in:
Étienne Fildadut 2017-08-23 19:22:18 +02:00
parent c0f7934d92
commit 9b809fc8a4
2 changed files with 11 additions and 5 deletions

View file

@ -38,10 +38,13 @@ function candran.preprocess(input, options={})
i += 1
if line:match("^%s*#") and not line:match("^#!") then -- exclude shebang
preprocessor ..= line:gsub("^%s*#", "")
elseif options.mapLines then
preprocessor ..= ("write(%q)"):format(line:sub(1, -2) .. " -- "..options.chunkname..":" .. i) .. "\n"
else
preprocessor ..= ("write(%q)"):format(line:sub(1, -2)) .. "\n"
local l = line:sub(1, -2)
if options.mapLines and not l:match("%-%- (.-)%:(%d+)$") then
preprocessor ..= ("write(%q)"):format(l .. " -- "..options.chunkname..":" .. i) .. "\n"
else
preprocessor ..= ("write(%q)"):format(line:sub(1, -2)) .. "\n"
end
end
end
preprocessor ..= "return output"