diff --git a/candran.can b/candran.can index 899dd31..27d8c1b 100644 --- a/candran.can +++ b/candran.can @@ -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" diff --git a/candran.lua b/candran.lua index 3704f58..005d070 100644 --- a/candran.lua +++ b/candran.lua @@ -1922,14 +1922,17 @@ for line in (input .. "\ i = i + 1 if line:match("^%s*#") and not line:match("^#!") then preprocessor = preprocessor .. line:gsub("^%s*#", "") -elseif options["mapLines"] then -preprocessor = preprocessor .. ("write(%q)"):format(line:sub(1, - 2) .. " -- " .. options["chunkname"] .. ":" .. i) .. "\ +else +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 preprocessor = preprocessor .. ("write(%q)"):format(line:sub(1, - 2)) .. "\ " end end +end preprocessor = preprocessor .. "return output" local env = util["merge"](_G, options) env["candran"] = candran