Skip to content

Instantly share code, notes, and snippets.

@ytakano
Last active December 28, 2024 17:34
Show Gist options
  • Select an option

  • Save ytakano/c843480fe4b382e374babdbb015f371c to your computer and use it in GitHub Desktop.

Select an option

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"
@April-June-August
Copy link
Copy Markdown

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