Documentation for this module may be created at Module:Quote/doc
local p = {}
-- Main function for processing quote text
function p.process(frame)
local raw = frame.args.text or frame.args[1] or ""
if raw == "" then return "" end
-- Optional: restore pipes/equals if you replace them earlier in template
-- raw = raw:gsub("__EQUALS__", "=")
-- Step 1: Remove continuation hyphens ( - at end of line, possibly with spaces)
-- Matches: optional spaces, then -, then optional spaces, then newline
local text = raw:gsub("%s*%-+%s*\n", " ")
-- Step 2: Replace any remaining single newlines with space (join lines into paragraph)
text = text:gsub("\n", " ")
-- Step 3: Collapse multiple spaces into one
text = text:gsub("%s+", " ")
-- Step 4: Trim leading/trailing space
text = text:match("^%s*(.-)%s*$")
return text
end
-- Alternative function if you want to PRESERVE deliberate line breaks (e.g. for poetry)
-- Use this if you want newlines → <br />, but still remove continuation hyphens
function p.processWithBreaks(frame)
local raw = frame.args.text or frame.args[1] or ""
if raw == "" then return "" end
-- Remove continuation hyphens, join those lines seamlessly
local text = raw:gsub("%s*%-+%s*\r?\n", "")
-- Convert remaining newlines to <br /> for use inside <poem> or directly
text = text:gsub("\r?\n", "<br />")
return text
end
return p