mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
don't add line mappin comments ad infinitum
This commit is contained in:
parent
c0f7934d92
commit
9b809fc8a4
2 changed files with 11 additions and 5 deletions
|
|
@ -38,10 +38,13 @@ function candran.preprocess(input, options={})
|
||||||
i += 1
|
i += 1
|
||||||
if line:match("^%s*#") and not line:match("^#!") then -- exclude shebang
|
if line:match("^%s*#") and not line:match("^#!") then -- exclude shebang
|
||||||
preprocessor ..= line:gsub("^%s*#", "")
|
preprocessor ..= line:gsub("^%s*#", "")
|
||||||
elseif options.mapLines then
|
|
||||||
preprocessor ..= ("write(%q)"):format(line:sub(1, -2) .. " -- "..options.chunkname..":" .. i) .. "\n"
|
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
preprocessor ..= "return output"
|
preprocessor ..= "return output"
|
||||||
|
|
|
||||||
|
|
@ -1922,14 +1922,17 @@ for line in (input .. "\
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if line:match("^%s*#") and not line:match("^#!") then
|
if line:match("^%s*#") and not line:match("^#!") then
|
||||||
preprocessor = preprocessor .. line:gsub("^%s*#", "")
|
preprocessor = preprocessor .. line:gsub("^%s*#", "")
|
||||||
elseif options["mapLines"] then
|
else
|
||||||
preprocessor = preprocessor .. ("write(%q)"):format(line:sub(1, - 2) .. " -- " .. options["chunkname"] .. ":" .. i) .. "\
|
local l = line:sub(1, - 2)
|
||||||
|
if options["mapLines"] and not l:match("%-%- (.-)%:(%d+)$") then
|
||||||
|
preprocessor = preprocessor .. ("write(%q)"):format(l .. " -- " .. options["chunkname"] .. ":" .. i) .. "\
|
||||||
"
|
"
|
||||||
else
|
else
|
||||||
preprocessor = preprocessor .. ("write(%q)"):format(line:sub(1, - 2)) .. "\
|
preprocessor = preprocessor .. ("write(%q)"):format(line:sub(1, - 2)) .. "\
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
preprocessor = preprocessor .. "return output"
|
preprocessor = preprocessor .. "return output"
|
||||||
local env = util["merge"](_G, options)
|
local env = util["merge"](_G, options)
|
||||||
env["candran"] = candran
|
env["candran"] = candran
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue