Module:Pretty-pre: Difference between revisions

From The Satanic Wiki
Jump to navigation Jump to search
Mediawiki>DarthKitty
(Make `p._main` and `p.main` one-liners.)
 
m (1 revision imported)
 

Latest revision as of 02:24, 30 April 2021

Documentation for this module may be created at Module:Pretty-pre/doc

-- <nowiki>
--------------------------------------------------------------------------------
-- Automatically adds a space before each line. Like the <pre> tag, but allows
-- markup (e.g. bold or italics), transclusions, etc.
--------------------------------------------------------------------------------
local p = {}

function p._main(s)
    return ' ' .. s:gsub('\n$', ''):gsub('\n', '\n ')
end

function p.main(frame)
    return p._main(frame:getParent().args[1] or frame.args[1] or '{{{1}}}')
end

return p

-- </nowiki>
-- (Add categories here.)