Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on princexml.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://anggtwu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://anggtwu.net/e/prince.e>
#           or at <http://anggtwu.net/e/prince.e.html>.
#        See also <http://anggtwu.net/emacs.html>,
#                 <http://anggtwu.net/.emacs[.html]>,
#                 <http://anggtwu.net/.zshrc[.html]>,
#                 <http://anggtwu.net/escripts.html>,
#             and <http://anggtwu.net/>.
#
#######



(find-es "html" "princexml")
(find-es "html" "prince-pre")
(find-angg ".emacs.templates" "find-prince-links")
(find-angg ".emacs.templates" "find-princeurl-links")

# (find-esgrep "grep --color=auto -nH --null -e prince *.e")


# «.princexml»			(to "princexml")
# «.princexml-video»		(to "princexml-video")
# «.prince-pre»			(to "prince-pre")
# «.prince-browser»		(to "prince-browser")
# «.prince-page-numbers»	(to "prince-page-numbers")
# «.prince-page-size»		(to "prince-page-size")
# «.prince-twb-rwh»		(to "prince-twb-rwh")
# «.prince-font-size»		(to "prince-font-size")
# «.prince-twb-toc»		(to "prince-twb-toc")




#####
#
# PrinceXML: an HTML to PDF converter (written in Mercury)
# 2011jun20
#
#####

# «princexml»  (to ".princexml")
# http://www.princexml.com/overview/
# http://www.princexml.com/download/
# http://www.princexml.com/download/prince_7.2-4ubuntu10.04_i386.deb
# http://www.princexml.com/download/prince_9.0-5_debian7.4_i386.deb
# http://www.princexml.com/download/prince_11.1-1_debian7.4_amd64.deb
# https://www.princexml.com/download/prince_12.5-1_debian9.1_amd64.deb
# https://www.princexml.com/download/prince_13.4-1_debian10_amd64.deb
# https://www.princexml.com/download/prince_14.2-1_debian10_amd64.deb
sudo dpkg -i $S/http/www.princexml.com/download/prince_7.2-4ubuntu10.04_i386.deb
sudo dpkg -i $S/http/www.princexml.com/download/prince_9.0-5_debian7.4_i386.deb
sudo dpkg -i $S/http/www.princexml.com/download/prince_11.1-1_debian7.4_amd64.deb
sudo dpkg -i $S/https/www.princexml.com/download/prince_12.5-1_debian9.1_amd64.deb
sudo dpkg -i $S/https/www.princexml.com/download/prince_13.4-1_debian10_amd64.deb
sudo dpkg -i $S/https/www.princexml.com/download/prince_14.2-1_debian10_amd64.deb

# 2019jun19:
https://www.princexml.com/download/prince_12.5-1_ubuntu18.04_amd64.deb
sudo dpkg -i $S/https/www.princexml.com/download/prince_12.5-1_ubuntu18.04_amd64.deb
apti libjpeg8

https://www.princexml.com/download/prince-12.5-linux-generic-x86_64.tar.gz
tar -C ~/usrc/ -xvzf $S/https/www.princexml.com/download/prince-12.5-linux-generic-x86_64.tar.gz
sudo ~/usrc/prince-12.5-linux-generic-x86_64/install.sh


# (find-status   "prince")
# (find-vldifile "prince.list")
# (find-udfile   "prince/")
# (find-man "1 prince")
# (find-fline "/usr/lib/prince/style/")

# http://www.princexml.com/doc/7.0/properties/
# http://www.princexml.com/doc/7.0/properties/font-size/
# http://www.princexml.com/doc/7.0/properties/content/
# http://www.princexml.com/doc/7.0/selectors/
# http://www.princexml.com/doc/7.0/command-line/
# http://www.princexml.com/doc/7.0/page-breaks/
# http://www.princexml.com/doc/7.0/page-headers-footers/
# http://www.princexml.com/samples/
# http://www.princexml.com/samples/mygut.css
# http://www.alistapart.com/articles/boom

# http://news.ycombinator.com/item?id=501897
# http://tomayko.com/writings/princexml
# http://www.youtube.com/watch?v=vcXUrNSvjhU
# ^ Prince XML: Generating High Quality PDFs from HTML + CSS
# http://www.lua.org/lua.css



* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# http://tomayko.com/writings/princexml
cat > /tmp/print.css <<'%%%'
body { margin:0 !important }
#footer, #nav, .pages { display:none }
%%%
prince -o /tmp/tomayko-print.pdf -s /tmp/print.css http://tomayko.com
# (find-xpdfpage "/tmp/tomayko-print.pdf")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# http://tomayko.com/writings/princexml
cat > /tmp/print.css <<'%%%'
body { font-size: 8pt !important }
%%%
prince -o /tmp/monep-8.pdf -s /tmp/print.css ~/TH/L/monep.html
# (find-xpdfpage "/tmp/monep-8.pdf")



#####
#
# PrinceXML: the Google TechTalks video
# 2012mar12
#
#####

;; «princexml-video»  (to ".princexml-video")
;; (find-angg ".emacs.templates" "find-youtubedl-links")
;; (find-youtubedl-links "/sda5/videos/" "Prince_XML_Generating_High_Quality_PDFs_from_HTML_CSS" "vcXUrNSvjhU" ".flv" "princexml")
(code-video "princexmlvideo" "/sda5/videos/Prince_XML_Generating_High_Quality_PDFs_from_HTML_CSS-vcXUrNSvjhU.flv")
;; (find-princexmlvideo)
;; (find-princexmlvideo "0:23" "(beginning)")
;; (find-princexmlvideo "1:04" "CSS")
;; (find-princexmlvideo "1:13" "a proposal")
;; (find-princexmlvideo "2:03" "CSS")
;; (find-princexmlvideo "2:50" "book")
;; (find-princexmlvideo "5:17" "pdf newspapers")
;; (find-princexmlvideo "7:20" "thesis")
;; (find-princexmlvideo "7:56" "CSS")
;; (find-princexmlvideo "8:40" "quick introduction to CSS")
;; (find-princexmlvideo "9:46" "CSS for paged media")
;; (find-princexmlvideo "10:24" "page-break-before")
;; (find-princexmlvideo "13:13" "@page")
;; (find-princexmlvideo "14:20" "headers and footers")
;; (find-princexmlvideo "17:40" "page:left")
;; (find-princexmlvideo "18:54" "multi-column layout")
;; (find-princexmlvideo "23:50" "http support")
;; (find-princexmlvideo "26:21" "bookmarks")
;; (find-princexmlvideo "27:40" "footnotes")
;; (find-princexmlvideo "27:56" "mathml")
;; (find-princexmlvideo "32:40" "cropmarks")
;; (find-princexmlvideo "35:06" "rounded borders")
;; (find-princexmlvideo "35:36" "prince in applications")
;; (find-princexmlvideo "40:00" "menu")
;; (find-princexmlvideo "40:53" "meny")
;; (find-princexmlvideo "41:55" "web fonts")
;; (find-princexmlvideo "42:14" "microsoft core fonts")
;; (find-princexmlvideo "43:02" "font families available for browsers")
;; (find-princexmlvideo "43:40" "web fonts")
;; (find-princexmlvideo "43:56" "giant tigers")
;; (find-princexmlvideo "44:23" "prince:")
;; (find-princexmlvideo "45:40" "gyparody")
;; (find-princexmlvideo "46:06" "the road to enlightenment")

# http://en.wikipedia.org/wiki/H%C3%A5kon_Wium_Lie
# http://people.opera.com/howcome/2006/phd/#ch-preweb




#####
#
# Using prince to print an UTF-8 file using <pre>...</pre>
# 2019jun20
#
#####

# «prince-pre» (to ".prince-pre")

# (find-angg "LATEX/2018-2-C2-P1.tex")
# (find-THfile "2014-xs.blogme" "find-prince-links")
# (find-fline "/home/edrx/TH/L/2014-xs.html")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cat > /tmp/o.html <<'%%%'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>2018-2-C2-P1.tex
</title>
</head>
<body>
<pre>
</pre> 
</body>
</html>
%%%

(find-2a
  ' (find-angg "LATEX/2018-2-C2-P1.tex")
  ' (find-fline "/tmp/o.html")
  )

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
allhtml = function (title, body)
    return [[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>]] .. title ..[[
</title>
</head>
<body>
<pre>
]] .. body .. "\n" .. [[
</pre>
</body>
</html>
]]
  end

= allhtml("foo", "bar")
-- (find-fline    "~/usrc/agda-categories/src/Categories/")
-- (find-fline    "~/usrc/agda-categories/src/Categories/Category.agda")
-- (find-fline    "~/usrc/agda-categories/src/Categories/Functor.agda")
-- (find-fline    "~/usrc/agda-categories/src/Categories/Functor/Core.agda")
-- (find-fline    "~/usrc/agda-categories/src/Categories/Adjoint.agda")
bod = ee_readfile "~/usrc/agda-categories/src/Categories/Adjoint.agda"
htm = allhtml("Adjoint.agda", bod)
ee_writefile("/tmp/o.html", htm)

preize = function (stem)
    local fnamend  = fnamenondirectory(stem)
    local srcfname = "~/usrc/agda-categories/src/Categories/" .. stem
    local fname_   = stem:gsub("/", "_")
    local fname    = "/tmp/" .. fname_ .. ".html"
    local bod = ee_readfile(srcfname)
    local htm = allhtml(stem, bod)
    ee_writefile(fname, htm)
    printf('# (find-fline "%s")\n', fname)
    printf('prince -s /tmp/print.css -o /tmp/%s.pdf /tmp/%s.html\n', fname_, fname_)
  end

preize("Category.agda")
preize("Functor.agda")
preize("Functor/Core.agda")
preize("Adjoint.agda")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cat > /tmp/print.css <<'%%%'
body { font-size: 8pt !important }
%%%
cat > /tmp/print.css <<'%%%'
body { font-size: 7pt !important }
%%%
prince -s /tmp/print.css      \
       -o /tmp/o.pdf  \
          /tmp/o.html

;; (find-pdf-page "/tmp/o.pdf")
;; (find-pdf-text "/tmp/o.pdf")

cd /tmp/
prince -s /tmp/print.css -o /tmp/Adjoint.agda.pdf /tmp/Adjoint.agda.html
prince -s /tmp/print.css -o /tmp/Category.agda.pdf /tmp/Category.agda.html
prince -s /tmp/print.css -o /tmp/Functor.agda.pdf /tmp/Functor.agda.html
prince -s /tmp/print.css -o /tmp/Functor_Core.agda.pdf /tmp/Functor_Core.agda.html





#####
#
# twb's prince-browser script
# 2020dec30
#
#####

# «prince-browser»  (to ".prince-browser")
# http://cyber.com.au/~twb/.bin/prince-browser
<twb> edrx: http://cyber.com.au/~twb/.bin/twb-pdf-new
<twb> Those aren't really suitable for other people tho
<twb> Also for open-source (Japanese only)
      http://cyber.com.au/~twb/.html2psrc





#####
#
# prince-page-numbers
# 2021jun26
#
#####

# «prince-page-numbers»  (to ".prince-page-numbers")
# (find-es "agda" "plfa-chapters-prince" "content: counter(page);")
# https://www.princexml.com/doc/cookbook/#page-numbering
# https://newbedev.com/print-page-numbers-on-pages-when-printing-html
# https://docraptor.com/documentation/tutorial/page-numbers
# (find-efunction 'find-telegram-save-log-links)
# (find-efunction 'find-telegram-save-log-links "content: counter(page)")



#####
#
# prince-page-size
# 2022mar17
#
#####

# «prince-page-size»  (to ".prince-page-size")
# https://www.princexml.com/doc/paged/#page-size
@page { size: A4 }




#####
#
# prince-twb-rwh
# 2022mar17
#
#####

# «prince-twb-rwh»  (to ".prince-twb-rwh")
# (find-fline "~/LOGS/2022mar17.emacs")
# https://cyber.com.au/~twb/.bin/rwh
# https://cyber.com.au/~twb/.bin/twb-pdf
# https://cyber.com.au/~twb/prince/prince.css
# (find-status   "librsvg2-bin")
# (find-vldifile "librsvg2-bin.list")
# (find-udfile   "librsvg2-bin/")
# (find-status   "xmlstarlet")
# (find-vldifile "xmlstarlet.list")
# (find-udfile   "xmlstarlet/")
# (find-status   "html2ps")
# (find-vldifile "html2ps.list")
# (find-udfile   "html2ps/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
for i in curl wget rsvg-convert tidy xmlstarlet html2ps
do type $i
done

cd /tmp/

base="http://book.realworldhaskell.org/read/"
rm -rf rwh
mkdir  rwh
cd     rwh
wget -O- $base | egrep -o "[^\"'[:space:]]+\\.html" | sed \$d >chapter.list
# BUG: callouts/{1..10}.png 404 at rwh, which makes wget error out.
wget -nv -nH -nd -k -p --base $base -i chapter.list -R js,css$(printf ,%s.png {1..10})
wget -nv http://docbook.sf.net/release/xsl/current/images/callouts/{1..10}.{png,svg}
wget -nv http://docbook.sf.net/release/xsl/current/images/{caution,note,tip,warning}.svg

# Prepare HTML for xmlstarlet.
tidy -m -q --show-warnings no -n -asxml -utf8 --indent auto --wrap 8192 *.html ||
test $? -eq 1                   # ignore warnings from tidy
sed -rsi *.html \
    -e 's|xmlns="http://www.w3.org/1999/xhtml"||' \
    -e '/<head>/a<meta name="author" content="Bryan O&#8217;Sullivan, Don Stewart, and John Goerzen" />'

for i in *.html
do
    # This
    # 1. removes the inline toc and navigation;
    # 2. changes the page title from <h2> to <h1>; and
    # 3. works around an <li><p x=y> bug in html2ps.
    # 4. use vector images for standard docbook icons.
    <$i >$i~ xmlstarlet ed -P -S \
        -d "//p/@id" -d "//pre/@id" -d "//a/@id" \
        -d "//div[@class='navheader' or @class='navfooter' or @class='rwhfooter']" \
        -r "//div[@class='preface' or @class='chapter' or @class='appendix']/div/div/div/h2[1]" -v h1 \
        -u "//img[@src='caution.png']/@src" -v caution.svg \
        -u "//img[@src='note.png']/@src"    -v note.svg \
        -u "//img[@src='tip.png']/@src"     -v tip.svg \
        -u "//img[@src='warning.png']/@src" -v warning.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/1.png']/@src" -v 1.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/2.png']/@src" -v 2.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/3.png']/@src" -v 3.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/4.png']/@src" -v 4.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/5.png']/@src" -v 5.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/6.png']/@src" -v 6.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/7.png']/@src" -v 7.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/8.png']/@src" -v 8.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/9.png']/@src" -v 9.svg \
        -u "//img[@src='http://book.realworldhaskell.org/read/images/callouts/10.png']/@src" -v 10.svg
    mv $i~ $i
done

# FIXME: ~/.prince.css here.
# https://cyber.com.au/~twb/.bin/twb-pdf
# (find-fline "$S/https/cyber.com.au/~twb/.bin/twb-pdf")

* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
cd /tmp/rwh/

wget -nc https://cyber.com.au/~twb/prince/prince.css

cat > ./twb-pdf <<'%%%'
#!/bin/bash
set -eEu
set -o pipefail
trap 'echo >&2 "${0##*/}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): } unknown error"' ERR
(($#)) || set -- -              # Without arguments, have prince read from stdin.
export BROWSER='/tmp/rwh/twb-pdf --media=screen'

# prince --no-author-style -s /tmp/rwh/prince.css "$@" -o/dev/stdout |

prince --no-author-style \
  -s https://cyber.com.au/~twb/prince/prince.css \
  "$@" -o/dev/stdout |
if [[ -t 1 && -e /proc/self/fd/1 && -n "${DISPLAY:-}" ]]
then with-temp-file xpdf.real -title "$*" -fullscreen -rv 2>/dev/null
else cat
fi
%%%
chmod 755 twb-pdf

chrt --idle 0 nice ionice -c3 ./twb-pdf $(<chapter.list) >rwh.pdf

# (find-sh "prince --help")
PDF
twb-pdf and twb-pdf-new are a huge mess, though.
# (find-man "chrt")




#####
#
# prince-font-size
# 2022mar17
#
#####

# «prince-font-size»  (to ".prince-font-size")
# (find-fline "~/LOGS/2022mar17.emacs" ":root{font-size:12pt}")




#####
#
# prince: adding page numbers to the Table of Contents
# 2022mar17
#
#####

# «prince-twb-toc»  (to ".prince-twb-toc")

/* Example adding page numbers to the Table of Contents of https://de.wikipedia.org/wiki/Kultur */

#toc a::after {
    content: leader(" . ") target-counter(attr(href), page) }
#toc li {
    list-style-type: none }
#toc > ul {
    columns: 40ex;
    column-gap: 1em;
    float: top;
    margin: 0;
    padding: 0;
    margin-bottom: 1ex;
    padding-bottom: 1ex;
    border-borrom: thin black solid }
#toctitle, .tocnumber {
    display: none }




# (find-sh "prince")
# (find-sh "prince --help")
# (find-sh "prince --help" "--media=MEDIA")
# (find-sh "prince --help" "--media=MEDIA" "print")










#  Local Variables:
#  coding:               utf-8-unix
#  End: