Module:Module introspection: Difference between revisions
rollback for now Tag: Manual revert |
bugfix offset line numbers |
||
| Line 11: | Line 11: | ||
if not content then return "" end | if not content then return "" end | ||
-- | -- 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) | end) | ||