summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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