More actions
Content deleted Content added
No edit summary |
No edit summary Tag: Reverted |
||
Line 3: | Line 3: | ||
function p.transclude(frame) |
function p.transclude(frame) |
||
-- Get and preprocess the input |
-- Get and preprocess the input |
||
local |
local input = frame:preprocess(frame.args[1] or '') |
||
local |
local output = {} |
||
-- Handle multiple consecutive newlines and spaces |
|||
-- Debug output |
|||
for line in input:gmatch("[^%s]+") do |
|||
return string.format( |
|||
-- Trim any remaining whitespace |
|||
"Raw input:\n<pre>%s</pre>\n\nProcessed input:\n<pre>%s</pre>", |
|||
line = line:match("^%s*(.-)%s*$") |
|||
⚫ | |||
if line ~= "" then |
|||
table.insert(output, string.format("{{%s}}", line)) |
|||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
-- Join with single newlines |
|||
return table.concat(output, "\n") |
|||
end |
end |
||
Revision as of 11:47, 14 January 2025
Documentation for this module may be created at Module:Transclude/doc
local p = {}
function p.transclude(frame)
-- Get and preprocess the input
local input = frame:preprocess(frame.args[1] or '')
local output = {}
-- Handle multiple consecutive newlines and spaces
for line in input:gmatch("[^%s]+") do
-- Trim any remaining whitespace
line = line:match("^%s*(.-)%s*$")
if line ~= "" then
table.insert(output, string.format("{{%s}}", line))
end
end
-- Join with single newlines
return table.concat(output, "\n")
end
return p