Module:Quote: Difference between revisions
Elena & Fabrice's Web
No edit summary
Fabrice (talk | contribs)
Fabrice changed the content model of the page Module:Quote from "wikitext" to "Scribunto module"
 
(One intermediate revision by the same user not shown)
(No difference)

Latest revision as of 09:05, 4 September 2025

Documentation for this module may be created at Module:Quote/doc

local p = {}

function p.processLineBreaks(frame)
    local text = frame.args.text or frame.args[1] or ""
    if text == "" then
        return text
    end
    -- Step 1: Remove single newlines after a hyphen
    local result = text:gsub("%-([^\n]?)\n([^\n])", "%1%2")
    -- Step 2: Replace other single newlines with a space
    result = result:gsub("\n([^\n])", " %1")
    -- Step 3: Replace multiple consecutive newlines with a single newline
    result = result:gsub("\n+", "\n")
    -- Step 4: Restore equal signs from placeholder
    result = result:gsub("__EQUALS__", "=")
    return result
end

return p