summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-07-17 15:04:23 +0100
committerLars Wirzenius <liw@liw.fi>2011-07-17 15:04:23 +0100
commitb276de40496780fbfde73d104b811493e39eb673 (patch)
tree2a31370668a79a215eaa3c2c301bb30b8c8e57f8
parent247ae9abf621085db297345a839d084f5d8db534 (diff)
downloadgtdfh.liw.fi-b276de40496780fbfde73d104b811493e39eb673.tar.gz
Add a script plus css file for making a PDF of the book.
-rw-r--r--book.css5
-rwxr-xr-xmarkdown-to-pdf44
2 files changed, 49 insertions, 0 deletions
diff --git a/book.css b/book.css
new file mode 100644
index 0000000..5e1c975
--- /dev/null
+++ b/book.css
@@ -0,0 +1,5 @@
+@media print {
+ html {
+ max-width: 40em;
+ }
+}
diff --git a/markdown-to-pdf b/markdown-to-pdf
new file mode 100755
index 0000000..732a456
--- /dev/null
+++ b/markdown-to-pdf
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+set -e
+
+book_prelude()
+{
+ cat <<eof
+<html>
+<head>
+<title>Book</title>
+<link rel="stylesheet" href="book.css" type="text/css" />
+</head>
+<body>
+eof
+}
+
+book_end()
+{
+ cat <<eof
+</body>
+</html>
+eof
+}
+
+chapter()
+{
+ cat <<eof
+<div class="chapter">
+eof
+
+ markdown "$1"
+
+ cat <<eof
+</div>
+eof
+}
+
+(book_prelude
+for f in "$@"
+do
+ chapter "$f"
+done
+book_end) > book.html
+wkhtmltopdf book.html book.pdf