Improve description formatting

This commit is contained in:
Jean-Patrick Guerrero 2020-07-22 17:06:11 +02:00
parent 9412ac740a
commit 96f9c85c77

@ -792,7 +792,7 @@ local function is_fav(favs, query_item)
end end
local function weird_desc(str) local function weird_desc(str)
return not true_str(str) or find(str, "\n") or not find(str, "%u") return not true_str(str) or find(str, "[\\]*") or not find(str, "%u")
end end
local function toupper(str) local function toupper(str)
@ -803,6 +803,10 @@ local function strip_newline(str)
return match(str, "[^\n]*") return match(str, "[^\n]*")
end end
local function strip_prefix(str)
return match(str, ".*@.*%)(.*)()") or str
end
local function get_desc(item, lang_code) local function get_desc(item, lang_code)
if sub(item, 1, 1) == "_" then if sub(item, 1, 1) == "_" then
item = sub(item, 2) item = sub(item, 2)
@ -813,10 +817,16 @@ local function get_desc(item, lang_code)
if def then if def then
local desc = def.description local desc = def.description
if true_str(desc) then if true_str(desc) then
desc = translate(lang_code, desc)
desc = desc:trim()
desc = strip_newline(desc)
desc = strip_prefix(desc)
if not find(desc, "%u") then if not find(desc, "%u") then
return strip_newline(toupper(desc)) desc = toupper(desc)
end end
return strip_newline(translate(lang_code, desc))
return desc
elseif true_str(item) then elseif true_str(item) then
return toupper(match(item, ":(.*)")) return toupper(match(item, ":(.*)"))