Skip to content

Commit 6234a84

Browse files
author
jghauser
committed
feat: use short titles when formatting notes
1 parent 2e8b846 commit 6234a84

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/papis/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ local default_config = {
7373
{ "year", "(%s) ", "" },
7474
{ "title", "%s", "" },
7575
}
76-
local title = require("papis.utils"):format_display_strings(entry, title_format)
76+
local title = require("papis.utils"):format_display_strings(entry, title_format, true)
7777
for k, v in ipairs(title) do
7878
title[k] = v[1]
7979
end

lua/papis/utils.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ end
333333

334334
---Creates a table of formatted strings to be displayed in a line (e.g. Telescope results pane)
335335
---@param entry table #A papis entry
336+
---@param use_shortitle? boolean #If true, use short titles
336337
---@return table #A list of strings
337-
function M:format_display_strings(entry, format_table)
338+
function M:format_display_strings(entry, format_table, use_shortitle)
338339
local clean_results_format = self.do_clean_format_tbl(format_table, entry, true)
339340

340341
local str_elements = {}
@@ -370,6 +371,9 @@ function M:format_display_strings(entry, format_table)
370371
end
371372
table.insert(str_elements, table.concat(authors, ", ") .. " (eds.)")
372373
end
374+
elseif v[1] == "title" and use_shortitle then
375+
local shortitle = entry["title"]:match("([^:]+)")
376+
table.insert(str_elements, shortitle)
373377
else
374378
table.insert(str_elements, entry[v[1]])
375379
end

0 commit comments

Comments
 (0)