Module:Sandbox: Difference between revisions

No edit summary
No edit summary
Line 27: Line 27:
         return nil
         return nil
     end
     end
end
-- Helper function to handle newline conversion
local function process_newlines(text)
    if not text then return text end
    -- First replace the escaped \"n with actual newline characters
    text = text:gsub('\\"n', '\n')
    -- Then replace newlines with <br> tags
    text = text:gsub('\n', '<br>')
    return text
end
end


Line 78: Line 88:
     end
     end
      
      
     -- Replace \"n with <br> tags using frame:preprocess()
     -- Process newlines and return
     label = label:gsub('\\"n', '<br>')
     return process_newlines(label)
    label = frame:preprocess(label)
   
    return label
end
end


Line 90: Line 97:
     local lang_code_override = frame.args[2]
     local lang_code_override = frame.args[2]


    -- Replace \"n with <br> tags using frame:preprocess()
     local result = p._search_string(label, lang_code_override)
     local result = p._search_string(label, lang_code_override)
    result = result:gsub('\\"n', '<br>')
     return process_newlines(result)
     return frame:preprocess(result)
end
end