diff --git a/README.md b/README.md index bd8a8db..8ab079f 100644 --- a/README.md +++ b/README.md @@ -93,10 +93,10 @@ require("nuke").setup{ | Markdown | | glow/lowdown/mdless | | | HTML | | w3m/elinks/lynx | | | MS doc | | antiword/catdoc/wvWare | | -| MS docx | | libreoffice | | +| MS docx | | pandoc/libreoffice | | | MS xls | | xlhtml/xls2csv | | | MS xlsx | | libreoffice | | -| Epub | | | einfo | +| Epub | | pandoc | einfo | *recomended terminal emulator with support of [Terminal graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/)* diff --git a/init.lua b/init.lua index 7e620a6..892f0a0 100644 --- a/init.lua +++ b/init.lua @@ -444,7 +444,9 @@ local function smart_view_doc(node) end local function smart_view_docx(node) - if program_exists("lowriter") then + if program_exists("pandoc") then + return exec_paging("pandoc", node, "-o -", "-t plain") + elseif program_exists("lowriter") then return {{ BashExec = 'VIEWRTMP=`mktemp -q -d ${TMPDIR:-/tmp}/xplr-nuke.XXXXXX` && cp "' .. node.absolute_path .. '" $VIEWRTMP/temp.docx && cd $VIEWRTMP && libreoffice --headless --convert-to txt $VIEWRTMP/temp.docx > /dev/null 2>&1 && cat $VIEWRTMP/temp.txt | ' @@ -480,6 +482,22 @@ local function smart_view_xls(node) end end +local function smart_view_epub(node) + if program_exists("pandoc") then + return exec_paging("pandoc", node, "-o -", "-t plain") + end + + return info_view_epub(node) +end + +local function smart_view_fb2(node) + if program_exists("pandoc") then + return exec_paging("pandoc", node, "-o -", "-t plain") + end + + return info_view_epub(node) +end + local function smart_view(ctx) local node = ctx.focused_node local node_mime = node.mime_essence @@ -514,12 +532,16 @@ local function smart_view(ctx) ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] = function() return smart_view_docx(node) end, ["application/vnd.ms-excel"] = function() return smart_view_xls(node) end, ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] = function() return smart_view_xlsx(node) end, - ["application/epub+zip"] = function() return info_view_epub(node) end, + ["application/epub+zip"] = function() return smart_view_epub(node) end, } local res = _case(node_mime, cases); if res then return res end + local cases = { + ["fb2"] = function() return smart_view_fb2(node) end, + } + if node_mime:match("^image/.*") then return smart_view_image(node) elseif node_mime:match("^video/.*") then