Last active
December 26, 2024 03:46
-
-
Save ucarion/1ad28c36667fa39d448b to your computer and use it in GitHub Desktop.
Composing programs to PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
input = $stdin.readlines.join | |
page = Nokogiri::HTML(input) | |
page.css('.example').each do |elem| | |
elem.inner_html = '<i>Environment diagram omitted.</i>' | |
end | |
page.css('img').remove | |
puts page.css('.inner-content').inner_html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
pages="11-getting-started | |
12-elements-of-programming | |
13-defining-new-functions | |
14-designing-functions | |
15-control | |
16-higher-order-functions | |
17-recursive-functions" | |
function html_to_pdf { | |
pandoc -f html -o "$1" --latex-engine=xelatex | |
} | |
while read -r page; do | |
url="http://composingprograms.com/pages/$page.html" | |
curl -s $url | ruby html_cleanup.rb | html_to_pdf "output/$page.pdf" | |
echo "Done with $page" | |
done <<< "$pages" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment