Skip to content

Commit

Permalink
Add epub search helper (#2867)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy7701 authored Jun 10, 2022
1 parent 1140fcf commit d5644ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions search-helpers/epub2text.nemo_search_helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Nemo Search Helper]
TryExec=unzip;html2text;nemo-epub2text;
Exec=nemo-epub2text %s
MimeType=application/epub+zip;
Priority=100
14 changes: 14 additions & 0 deletions search-helpers/nemo-epub2text
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Requires unzip package
# ==================================
# 1. Get a list of all xhtml/html/htm files, exclude titlepage.xhtml (if present)
# It appears that the zipped files _never_ contain problem characters such as spaces...
# 2. Extract the html files and convert to text (UTF-8 output is available).
# ==================================

# 1. Get a list of xhtml/html/htm files [using unzip's weird regular expression] - and exclude any named titlepage/toc/copyright
files=$(unzip -Z1 "$1" \*.*htm* | egrep -v 'titlepage.*|toc.*|copyright.*')

# 2. Uncompress each of the files and process with html2text.
unzip -cqq "$1" $files | html2text -o -

0 comments on commit d5644ad

Please sign in to comment.