Unsolicited code review:
system("multimarkdown -s ../#{part}/story.md | sed -E 's/_([^_]+)_/<em>\\1<\\/em>/g' | sed -E 's/<h1 .+<\\/h1>//g' | sed 's/<p>%<\\/p>/<p class=\"section-break\">%<\\/p>/g' > output-#{part}.html")
IMO: s_<p>%</p>_<p class="section-break">%</p>_g
is easier to read than: s/<p>%<\\/p>/<p class=\"section-break\">%<\\/p>/g
Any reason to keep the %-sign?Those sed commands could probably be reduced to one invocation of sed(1) instead of three.
system("cat #{htmls} | #{wkhtmltopdf_cmd} --footer-html footer.html - body.pdf")
No need to use cat.