summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2019-12-30 21:20:41 +0100
committertoonn <toonn@toonn.io>2019-12-30 21:20:41 +0100
commit515467584d95790d266ba24bad18f42745b580bd (patch)
tree8bb04edeb7b64d7a3af374e7d0b0e850c6dcee5f
parent1300d2f3491739538e2b52478cfdcb0660c9b913 (diff)
parentb3c1bedb1edb66408501719558f903850f6ab771 (diff)
downloadranger-515467584d95790d266ba24bad18f42745b580bd.tar.gz
Merge branch 'prosoitos-add_preview'
-rwxr-xr-xranger/data/scope.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index ae09fe39..f403ed83 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -83,6 +83,15 @@ handle_extension() {
         odt|ods|odp|sxw)
             ## Preview as text conversion
             odt2txt "${FILE_PATH}" && exit 5
+            ## Preview as markdown conversion
+            pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
+            exit 1;;
+
+        ## XLSX
+        xlsx)
+            ## Preview as csv conversion
+            ## Uses: https://github.com/dilshod/xlsx2csv
+            xlsx2csv -- "${FILE_PATH}" && exit 5
             exit 1;;
 
         ## HTML
@@ -91,6 +100,7 @@ handle_extension() {
             w3m -dump "${FILE_PATH}" && exit 5
             lynx -dump -- "${FILE_PATH}" && exit 5
             elinks -dump "${FILE_PATH}" && exit 5
+            pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
             ;;
 
         ## JSON
@@ -255,6 +265,30 @@ handle_image() {
 handle_mime() {
     local mimetype="${1}"
     case "${mimetype}" in
+        ## RTF and DOC
+        text/rtf|*msword)
+            ## Preview as text conversion
+            ## note: catdoc does not always work for .doc files
+            ## catdoc: http://www.wagner.pp.ru/~vitus/software/catdoc/
+            catdoc -- "${FILE_PATH}" && exit 5
+            exit 1;;
+
+        ## DOCX, ePub, FB2 (using markdown)
+        ## You might want to remove "|epub" and/or "|fb2" below if you have
+        ## uncommented other methods to preview those formats
+        *wordprocessingml.document|*/epub+zip|*/x-fictionbook+xml)
+            ## Preview as markdown conversion
+            pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
+            exit 1;;
+
+        ## XLS
+        *ms-excel)
+            ## Preview as csv conversion
+            ## xls2csv comes with catdoc:
+            ##   http://www.wagner.pp.ru/~vitus/software/catdoc/
+            xls2csv -- "${FILE_PATH}" && exit 5
+            exit 1;;
+
         ## Text
         text/* | */xml)
             ## Syntax highlight