Skip to content

Instantly share code, notes, and snippets.

@ytakano
Last active August 15, 2024 15:04
Show Gist options
  • Save ytakano/c843480fe4b382e374babdbb015f371c to your computer and use it in GitHub Desktop.
Save ytakano/c843480fe4b382e374babdbb015f371c to your computer and use it in GitHub Desktop.
横書きのepubファイルを縦書きに変更するスクリプト
#!/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"
@Sponge-bink
Copy link

Thank you for the script! It still works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment