Module:Sandbox: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 32: Line 32:
local function process_newlines(text)
local function process_newlines(text)
     if not text then return text end
     if not text then return text end
     -- First replace the escaped \"n with actual newline characters
     -- First replace the \"n with a special marker
     text = text:gsub('\\"n', '\n')
     text = text:gsub('\\"n', 'NEWLINE_MARKER')
     -- Then replace newlines with <br> tags
     -- Then replace the marker with <br>
     text = text:gsub('\n', '<br>')
     text = text:gsub('NEWLINE_MARKER', '<br>')
     return text
     return text
end
end
Line 89: Line 89:
      
      
     -- Process newlines and return
     -- Process newlines and return
     return process_newlines(label)
     label = process_newlines(label)
    return label
end
end


Line 98: Line 99:


     local result = p._search_string(label, lang_code_override)
     local result = p._search_string(label, lang_code_override)
     return process_newlines(result)
     result = process_newlines(result)
    return result
end
end