commit 82e42d2559de874abb94bc0783218e2f7e328d22
Author: Sunur Efe Vural <efe@efe.kim>
Date: Sun, 5 May 2019 13:42:14 -0400
initialize
Diffstat:
8 files changed, 217 insertions(+), 0 deletions(-)
diff --git a/less.conf b/less.conf
@@ -0,0 +1,83 @@
+#command
+j forw-line
+k back-line
+l right-scroll
+h left-scroll
+$ end-scroll
+0 no-scroll
+d forw-scroll
+u back-scroll
+f forw-screen
+b back-screen
+r repaint
+R repaint-flush
+g goto-line
+p percent
+G goto-end
+s status
+/ forw-search
+? back-search
+n repeat-search
+N reverse-search
+m set-mark
+' goto-mark
+M clear-mark
+w toggle-option S
+q quit
+Q quit
+
+\kd forw-line
+\ku back-line
+\kl left-scroll
+\kr right-scroll
+\kD forw-screen
+\kU back-screen
+\kx no-scroll
+\kh goto-line
+\ke goto-end
+\t forw-search
+\40 forw-screen
+\e undo-hilite
+c undo-hilite
+
+^G status
+= status
+^D forw-scroll
+^U back-scroll
+^N forw-line
+^P back-line
+^E forw-line
+^B back-screen
+^Y back-line
+^F forw-screen
+^R repaint-flush
+
+1 digit
+2 digit
+3 digit
+4 digit
+5 digit
+6 digit
+7 digit
+8 digit
+9 digit
+
+#stop
+
+#line-edit
+\t forw-complete
+\17 back-complete
+^L expand
+^V literal
+^A literal
+\kr right
+\kl left
+\kx delete
+\kh home
+\ku up
+^G abort
+
+#env
+LESS = -e -i -S -W -J -G -z-2 -~ -Q -x4 \#2
+LESSCHARSET = utf-8
+LESSHISTFILE = /dev/null
diff --git a/lesskey b/lesskey
Binary files differ.
diff --git a/w3m.conf b/w3m.conf
@@ -0,0 +1,51 @@
+display_charset UTF-8
+document_charset UTF-8
+color 0
+display_link 0
+display_link_number 0
+tabstop 4
+follow_redirection 0
+argv_is_url 0
+indent_incr 4
+target_self 0
+multicol 1
+alt_entity 0
+graphic_char 0
+display_borders 0
+display_ins_del 2
+ignore_null_img_alt 1
+view_unseenobject 0
+display_image 0
+pseudo_inlines 0
+image_map_list 0
+show_lnum 0
+active_style 0
+use_history 0
+save_hist 0
+mark 0
+vi_prec_num 0
+mark_all_pages 0
+clear_buffer 1
+decode_cte 0
+auto_uncompress 0
+preserve_timestamp 0
+disable_secret_security_check 0
+user_agent
+no_referer 0
+retry_http 0
+use_proxy 0
+no_cache 1
+use_cookie 0
+show_cookie 0
+accept_cookie 0
+auto_detect 2
+system_charset UTF-8
+follow_locale 1
+ext_halfdump 0
+use_wide 0
+use_combining 1
+east_asian_width 1
+use_language_tag 1
+search_conv 1
+fix_width_conv 1
+simple_preserve_space 0
diff --git a/w3mepub b/w3mepub
@@ -0,0 +1,32 @@
+#!/bin/sh
+#dep: w3m, less, xsltproc, unzip
+
+tmpdir=$(mktemp -d /tmp/w3mepub-XXXXXX)
+xsldir=~/test/w3mepub/xslt
+confile=~/test/w3mepub/w3m.conf
+LESSKEY=$HOME/test/w3mepub/lesskey
+export LESSKEY
+unset LESS_IS_MORE
+unset LESSSECURE
+
+trap 'rm -r $tmpdir' 0 1 15
+
+xmltr() {
+ xsltproc --stringparam rootdir "${rootdir:-na}" \
+ "${xsldir}/${1}.xsl" "${tmpdir}/${2}"
+}
+
+unzip -q "$1" -d "$tmpdir" || {
+ echo Cannot extract
+ exit 0
+}
+
+fullpath=$(xmltr fullpath META-INF/container.xml)
+title=$(xmltr title "$fullpath")
+abspath=${tmpdir}/${fullpath}
+rootdir=${abspath%/*}
+
+IFS="
+"
+w3m -config "$confile" -T text/html -cols 65 -dump \
+ $(xmltr content "$fullpath") | less
diff --git a/xslt/content.xsl b/xslt/content.xsl
@@ -0,0 +1,15 @@
+<xsl:stylesheet version="1.0" encoding="UTF-8"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:opf="http://www.idpf.org/2007/opf"
+xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <xsl:output method="text"/>
+ <xsl:template match="/opf:package">
+ <xsl:for-each select="opf:spine/opf:itemref">
+ <xsl:variable name="idsel" select="@idref"/>
+ <xsl:value-of select="$rootdir" />
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="/opf:package/opf:manifest/opf:item[@id=$idsel]/@href"/>
+ <xsl:text>
</xsl:text>
+ </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/xslt/fullpath.xsl b/xslt/fullpath.xsl
@@ -0,0 +1,10 @@
+<xsl:stylesheet version="1.0" encoding="UTF-8"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:c="urn:oasis:names:tc:opendocument:xmlns:container">
+ <xsl:output omit-xml-declaration="yes"/>
+ <xsl:template match="/">
+ <xsl:value-of select="/c:container/c:rootfiles/
+ c:rootfile[@media-type='application/oebps-package+xml']/
+ @full-path[1]"/>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/xslt/parse.xsl b/xslt/parse.xsl
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:exslt="http://exslt.org/common"
+xmlns="http://www.w3.org/1999/xhtml"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns:ops="http://www.idpf.org/2007/ops"
+xmlns:_="http://www.w3.org/1999/xhtml"
+xmlns:DEFAULT="http://www.w3.org/1999/xhtml"
+extension-element-prefixes="exslt">
+ <xsl:output omit-xml-declaration="yes" indent="no"/>
+ <xsl:template match="/">
+ <xsl:copy-of select="/_:html/_:body"/>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/xslt/title.xsl b/xslt/title.xsl
@@ -0,0 +1,11 @@
+<xsl:stylesheet version="1.0" encoding="UTF-8"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:opf="http://www.idpf.org/2007/opf"
+xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <xsl:output method="text"/>
+ <xsl:template match="/">
+ <xsl:value-of select="/opf:package//dc:creator[1]"/>
+ <xsl:text> -- </xsl:text>
+ <xsl:value-of select="/opf:package//dc:title[1]"/>
+ </xsl:template>
+</xsl:stylesheet>