Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Improve description formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbith committed Jul 22, 2020
1 parent 9412ac7 commit 96f9c85
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ local function is_fav(favs, query_item)
end

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

local function toupper(str)
Expand All @@ -803,6 +803,10 @@ local function strip_newline(str)
return match(str, "[^\n]*")
end

local function strip_prefix(str)
return match(str, ".*@.*%)(.*)()") or str
end

local function get_desc(item, lang_code)
if sub(item, 1, 1) == "_" then
item = sub(item, 2)
Expand All @@ -813,10 +817,16 @@ local function get_desc(item, lang_code)
if def then
local desc = def.description
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
return strip_newline(toupper(desc))
desc = toupper(desc)
end
return strip_newline(translate(lang_code, desc))

return desc

elseif true_str(item) then
return toupper(match(item, ":(.*)"))
Expand Down

0 comments on commit 96f9c85

Please sign in to comment.