---@class inbox.Summary ---@field authors string | string[] ---@field date_relative string ---@field matched integer ---@field query string[] ---@field subject string | string[] ---@field tags string[] ---@field thread integer ---@field timestamp integer ---@field total integer ---@class inbox.Email ---@field id string ---@field filename string[] ---@field timestamp integer ---@field date_relative string? ---@field tags string[] ---@field duplicate integer ---@field body inbox.Part[] ---@field crypto table ---@field headers inbox.Headers ---@alias inbox.Headers table ---@alias inbox.Header ---| "Subject" ---| "Date" ---| "To" ---| "From" ---| string ---@class inbox.Part ---@field id integer ---@field content-type inbox.ContentType ---@field content-charset? string ---@field content-length? integer ---@field content-disposition? string ---@field content-transfer-encoding? string ---@field content? string | inbox.Part[] ---@alias inbox.ContentType ---| "text/plain" ---| "text/html" ---| string local M = {} M.summary_widths = { 10, 30, } ---@param summary inbox.Summary ---@return table sanitized sanitized summary function M.sanitize_summary(summary) local date = summary.date_relative:gsub("^([A-Z][a-z][a-z])%w%w+", "%1.") local from if type(summary.authors) == "table" then from = summary.authors[1] --[[@as string]] else from = summary.authors --[[@as string]] end local subject if type(summary.subject) == "table" then subject = summary.subject[1] --[[@as string]] else subject = summary.subject --[[@as string]] end subject = subject:gsub("\r?\n", " ") return { date, from, subject, } end return M