nicer formatting
This commit is contained in:
parent
41862d5150
commit
afa326e426
|
@ -58,11 +58,11 @@ function M.lookup()
|
|||
api.nvim_buf_set_option(buf, "modifiable", true)
|
||||
|
||||
api.nvim_buf_set_lines(buf, 0, 1, false, {
|
||||
"Interesting ACM Publications",
|
||||
" Interesting ACM Publications",
|
||||
})
|
||||
|
||||
api.nvim_buf_set_lines(buf, 1, 2, false, {
|
||||
"Requesting papers from ACM...",
|
||||
" Requesting papers from ACM...",
|
||||
})
|
||||
|
||||
-- Setup a http socket and request
|
||||
|
@ -82,19 +82,19 @@ function M.lookup()
|
|||
local rss_url = response:match('"https://dl%.acm%.org/action/showFeed%?.-"')
|
||||
if rss_url == nil then
|
||||
api.nvim_buf_set_lines(buf, 3, 4, false, {
|
||||
"ERROR: Could not locate Feed!",
|
||||
" ERROR: Could not locate Feed!",
|
||||
})
|
||||
return
|
||||
end
|
||||
rss_url = rss_url:sub(2, #rss_url - 1)
|
||||
|
||||
api.nvim_buf_set_lines(buf, 3, 4, false, {
|
||||
"Feed found at: " .. rss_url,
|
||||
" Feed found at: " .. rss_url,
|
||||
})
|
||||
|
||||
local rss_content = httprequest(rss_url)
|
||||
api.nvim_buf_set_lines(buf, 4, 5, false, {
|
||||
"Received feed content",
|
||||
" Received feed content",
|
||||
})
|
||||
|
||||
-- skip initial block
|
||||
|
@ -148,35 +148,17 @@ function M.lookup()
|
|||
b = y
|
||||
end
|
||||
|
||||
-- select descriptions from rss_content
|
||||
b = b_start
|
||||
local descriptions = {}
|
||||
while true do
|
||||
local x, y = rss_content:find("<description>.-</description>", b, false)
|
||||
|
||||
-- stop if no further occurrences are found
|
||||
if x == nil or y == nil then
|
||||
break
|
||||
end
|
||||
|
||||
-- save substring to descriptions
|
||||
table.insert(descriptions, rss_content:sub(x + 12, y - 13))
|
||||
b = y
|
||||
end
|
||||
|
||||
api.nvim_buf_set_lines(buf, 1, -1, false, {
|
||||
"Found entries: " .. #dates,
|
||||
" Found entries: " .. #dates,
|
||||
})
|
||||
|
||||
local current_line = 4
|
||||
for x = 1, #dates do
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { "Title: " .. titles[x] })
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { " Title: " .. titles[x] })
|
||||
current_line = current_line + 1
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { "Date: " .. dates[x] })
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { " Date: " .. dates[x] })
|
||||
current_line = current_line + 1
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { "Description: " .. descriptions[x] })
|
||||
current_line = current_line + 1
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { "Website: " .. links[x] })
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { " Website: " .. links[x] })
|
||||
current_line = current_line + 1
|
||||
api.nvim_buf_set_lines(buf, current_line, -1, false, { "" })
|
||||
current_line = current_line + 2
|
||||
|
|
Loading…
Reference in New Issue