Module:Module introspection: Difference between revisions

Ganaram inukshuk (talk | contribs)
rollback for now
Tag: Manual revert
Ganaram inukshuk (talk | contribs)
bugfix offset line numbers
Line 11: Line 11:
if not content then return "" end
if not content then return "" end


-- Blank single-line comments
-- Preserve line breaks inside comments
 
-- Handle multi-line comments with optional equals (e.g. --[[ ... ]] or --[=[ ... ]=])
content = content:gsub("%-%-%[(=*)%[.-%]%1%]", function(s)
-- Replace all non-newline characters with spaces to preserve line numbers
return (s:gsub("[^\n]", " "))
end)
 
-- Handle single-line comments
content = content:gsub("%-%-[^\n]*", function(s)
content = content:gsub("%-%-[^\n]*", function(s)
return string.rep(" ", #s)
return string.rep(" ", #s)
end)
-- Blank multi-line comments (handles --[[...]] and --[=[...]=])
content = content:gsub("%-%-%[%[.-%]%]", function(s)
local blank = s:gsub("[^\n]", " ")
return blank
end)
content = content:gsub("%-%-%[%=[=]*%[.-%][=]*%]", function(s)
local blank = s:gsub("[^\n]", " ")
return blank
end)
end)