Notebook.sh: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
The script below uses <code>curl</code>, <code>pandoc</code>, <code>weasyprint</code>, <code>pdfbook2</code> and [[User:Manetta/Booklet-stylesheet.css|Booklet-stylesheet.css]] as a stylesheet to render a PDF from a wiki page. | The script below uses <code>curl</code>, <code>pandoc</code>, <code>weasyprint</code>, <code>pdfbook2</code> and [[User:Manetta/Booklet-stylesheet.css|Booklet-stylesheet.css]] as a stylesheet to render a PDF from a wiki page. | ||
You can copy the script and save it as a local bash file, for example: <code>booklet.sh</code>. | |||
And run it with: <code>$ bash booklet.sh WIKIPAGE</code>, for example: <code>$ bash booklet.sh Pen plotters</code> | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# insert your wiki page below, between the quotes | # insert your wiki page below, between the quotes | ||
WIKIPAGE= | WIKIPAGE=$1 | ||
# first download the wiki page in wikitext to a local file | # first download the wiki page in wikitext to a local file |
Revision as of 15:25, 21 November 2023
The script below uses curl
, pandoc
, weasyprint
, pdfbook2
and Booklet-stylesheet.css as a stylesheet to render a PDF from a wiki page.
You can copy the script and save it as a local bash file, for example: booklet.sh
.
And run it with: $ bash booklet.sh WIKIPAGE
, for example: $ bash booklet.sh Pen plotters
# insert your wiki page below, between the quotes
WIKIPAGE=$1
# first download the wiki page in wikitext to a local file
curl https://pzwiki.wdka.nl/mediadesign/$WIKIPAGE?action=raw > $WIKIPAGE.mediawiki
# then convert this file into a HTML page, using the stylesheet at https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css
pandoc --from mediawiki --to html $WIKIPAGE.mediawiki --css https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw --output $WIKIPAGE.html
# then turn the HTML page into a PDF with weasyprint
weasyprint $WIKIPAGE.html --stylesheet https://pzwiki.wdka.nl/mediadesign/User:Manetta/Booklet-stylesheet.css?action=raw $WIKIPAGE.pdf
# and finally, turn the PDF into an A5 booklet PDF for printing
# pdfbook2 is part of the texlive-extra-utils package in Debian
pdfbook2 --paper=a4paper --short-edge --no-crop $WIKIPAGE.pdf