Last active
August 15, 2024 15:04
-
-
Save ytakano/c843480fe4b382e374babdbb015f371c to your computer and use it in GitHub Desktop.
横書きのepubファイルを縦書きに変更するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
if [ $# -ne 1 ]; then | |
echo "need epub file!" 1>&2 | |
echo "example:" 1>&2 | |
echo " $ $0 ebook.epub" 1>&2 | |
exit 1 | |
fi | |
FILE=`basename "$1" .epub` | |
DIR=/tmp/$FILE.vertical | |
mkdir "$DIR" | |
unzip "$1" -d "$DIR" | |
echo '@charset "utf-8"; | |
* { | |
line-height: 150%; | |
} | |
.vertical,.vrtl { | |
writing-mode: vertical-rl; | |
-epub-writing-mode: vertical-rl; | |
-webkit-writing-mode: vertical-rl; | |
line-break: normal; | |
-epub-line-break: normal; | |
-webkit-line-break: normal; | |
} | |
p{ | |
margin: 0; | |
} | |
h2{ | |
margin-left:3rem; | |
margin-top:3rem; | |
}' >> "$DIR/page_styles.css" | |
OUT=`pwd`"/$FILE.vertical.epub" | |
cd "$DIR" | |
zip -0 -X "$OUT" mimetype | |
zip -r "$OUT" * -x mimetype | |
cd /tmp | |
rm -rf "$DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the script! It still works!