ferri-pdf 0.1.1

HTML and CSS to PDF renderer for print, in pure Rust
Documentation
/* HTML rendering defaults (HTML Standard §15.3). */
@namespace url("http://www.w3.org/1999/xhtml");
@page { size: auto; margin: 72pt; }
html, body, address, article, aside, blockquote, center, div, dl, dt, dd, dir,
figure, figcaption, footer, form, header, hgroup, main, menu, nav, ol, p, pre,
search, section, ul, listing, plaintext, xmp, legend, dialog { display: block; }
hr { display: block; color: gray; border-style: inset; border-width: 1px;
    margin-block: .5em; margin-inline: auto; overflow: hidden; }
area, base, basefont, datalist, head, link, meta, noembed, noframes, param,
rp, script, style, template, title { display: none; }
slot { display: contents; }
[hidden]:not([hidden=until-found i]):not(embed) { display: none; }
[hidden=until-found i]:not(embed) { content-visibility: hidden; }
embed[hidden] { display: inline; height: 0; width: 0; }
input[type=hidden i] { display: none !important; }
dialog:not([open]) { display: none; }
dialog { position: absolute; inset-inline-start: 0; inset-inline-end: 0; width: fit-content;
    height: fit-content; margin: auto; border: solid; padding: 1em;
    background-color: Canvas; color: CanvasText; }
dialog:modal { position: fixed; overflow: auto; inset-block: 0;
    max-width: calc(100% - 6px - 2em); max-height: calc(100% - 6px - 2em); }
[popover]:not(:popover-open):not(dialog[open]) { display: none; }
dialog:popover-open { display: block; }
[popover] { position: fixed; inset: 0; width: fit-content; height: fit-content; margin: auto;
    border: solid; padding: 0.25em; overflow: auto; color: CanvasText; background-color: Canvas; }
details, summary { display: block; }
details > summary:first-of-type { display: list-item; counter-increment: list-item 0;
    list-style: disclosure-closed inside; }
details[open] > summary:first-of-type { list-style-type: disclosure-open; }
marquee { display: inline-block; text-align: initial; overflow: hidden !important; }
body { margin: 8px; }
p, blockquote, figure, pre, listing, plaintext, xmp, dl, dir, menu, ol, ul {
    margin-block: 1em;
}
blockquote, figure { margin-inline: 40px; }
dd { margin-inline-start: 40px; }
dir, menu, ol, ul { padding-inline-start: 40px; }
dir dir, dir dl, dir menu, dir ol, dir ul,
dl dir, dl dl, dl menu, dl ol, dl ul,
menu dir, menu dl, menu menu, menu ol, menu ul,
ol dir, ol dl, ol menu, ol ol, ol ul,
ul dir, ul dl, ul menu, ul ol, ul ul { margin-block: 0; }
li { display: list-item; text-align: match-parent; }
/* CSS Inline 3 §7.4.1 */
[lang]:lang(zh, ja, ko, ii) { initial-letter-align: ideographic; }
[lang]:lang(hi, mr, ne, pi, kok, brx, mai, sd, sa) { initial-letter-align: hanging; }
[lang]:lang('*-Latn', '*-Cyrl') { initial-letter-align: alphabetic; }
[lang]:lang('*-Hani', '*-Hant', '*-Hans') { initial-letter-align: ideographic; }
/* CSS Lists 3 §3.1.1 */
::marker { unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: pre;
    text-transform: none; }
ol { list-style-type: decimal; }
ol, ul, menu { counter-reset: list-item; }
ol, ul { break-before: avoid; }
dir, menu, ul { list-style-type: disc; }
:is(dir, menu, ol, ul) :is(dir, menu, ul) { list-style-type: circle; }
:is(dir, menu, ol, ul) :is(dir, menu, ol, ul) :is(dir, menu, ul) { list-style-type: square; }
h1, h2, h3, h4, h5, h6 { display: block; font-weight: bold; break-after: avoid; break-inside: avoid; }
address, cite, dfn, em, i, var { font-style: italic; }
b, strong { font-weight: bolder; }
pre, listing, plaintext, xmp, code, kbd, samp, tt { font-family: monospace; }
pre, listing, plaintext, xmp { white-space: pre; }
big { font-size: larger; }
small { font-size: smaller; }
sub { vertical-align: sub; }
sup { vertical-align: super; }
sub, sup { line-height: normal; font-size: smaller; }
a[href] { color: #0000ee; text-decoration: underline; }
ins, u { text-decoration: underline; }
del, s, strike { text-decoration: line-through; }
abbr[title], acronym[title] { text-decoration: dotted underline; }
mark { color: black; background-color: yellow; }
/* HTML Standard §15.3.4 and CSS Ruby 1 Appendix A.1, whose bopomofo selector list ends
   without a trailing comma. */
ruby { display: ruby; }
rbc { display: ruby-base-container; }
rtc { display: ruby-text-container; }
rb { display: ruby-base; white-space: nowrap; }
rt { display: ruby-text; }
ruby, rb, rt, rbc, rtc { unicode-bidi: isolate; }
rtc, rt { font-variant-east-asian: ruby; text-justify: ruby; text-emphasis: none;
    white-space: nowrap; line-height: 1; }
rtc, :not(rtc) > rt { font-size: 50%; }
rtc:lang(zh-TW), :not(rtc) > rt:lang(zh-TW),
rtc:lang(zh-Hanb), :not(rtc) > rt:lang(zh-Hanb) { font-size: 30%; }
q::before { content: open-quote; }
q::after { content: close-quote; }
nobr { white-space: nowrap; }
nobr wbr { white-space: normal; }
table { display: table; box-sizing: border-box; border-spacing: 2px; border-collapse: separate; }
caption { display: table-caption; text-align: center; break-after: avoid; break-inside: avoid; }
colgroup { display: table-column-group; }
col { display: table-column; }
thead { display: table-header-group; }
tbody { display: table-row-group; }
tfoot { display: table-footer-group; }
tr { display: table-row; }
td, th { display: table-cell; padding: 1px; }
th { font-weight: bold; }
thead, tbody, tfoot, table > tr { vertical-align: middle; }
tr, td, th { vertical-align: inherit; }

[dir]:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) { direction: ltr; }
[dir]:dir(rtl), bdi:dir(rtl) { direction: rtl; }
address, blockquote, center, div, figure, figcaption, footer, form, header,
hr, legend, listing, main, p, plaintext, pre, summary, xmp, article, aside,
:heading, hgroup, nav, search, section, table, caption, colgroup, col, thead,
tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, bdi, output,
[dir=ltr i], [dir=rtl i], [dir=auto i] { unicode-bidi: isolate; }
bdo, bdo[dir] { unicode-bidi: isolate-override; }
input[dir=auto i]:is([type=search i], [type=tel i], [type=url i], [type=email i]),
textarea[dir=auto i], pre[dir=auto i] { unicode-bidi: plaintext; }
thead, tbody, tfoot, tr { border-color: inherit; }
:is(table, thead, tbody, tfoot, tr) > form { display: none !important; }
/* Form controls (HTML Standard §15.3.10, §15.5). */
input, button, textarea { letter-spacing: initial; word-spacing: initial; line-height: initial; }
input, select, button, textarea { text-transform: initial; text-indent: initial;
    text-shadow: initial; appearance: auto; }
input:not([type=range i], [type=checkbox i], [type=radio i]) { overflow: clip !important;
    overflow-clip-margin: 0 !important; }
input[type=image i] { overflow-clip-margin: content-box !important; }
input, select, textarea { text-align: initial; }
:autofill { field-sizing: fixed !important; }
input:is([type=reset i], [type=button i], [type=submit i]), button { text-align: center; }
input, button { display: inline-block; }
input[type=hidden i], input[type=file i], input[type=image i] { appearance: none; }
input:is([type=radio i], [type=checkbox i], [type=reset i], [type=button i], [type=submit i],
    [type=color i], [type=search i]), select, button { box-sizing: border-box; }
textarea { white-space: pre-wrap; }
input:not([type=file i], [type=range i], [type=checkbox i], [type=radio i]) {
    align-content: unsafe center; }
button, ::file-selector-button, input:is([type=color i], [type=reset i], [type=button i],
    [type=submit i]) { align-content: center; }
option { display: block; }
optgroup { display: block; font-weight: bolder; }
optgroup > option { font-weight: normal; padding-inline-start: 1em; }
select { letter-spacing: initial; word-spacing: initial; line-height: initial;
    display: inline-block; align-content: center; }
meter, progress { appearance: auto; display: inline-block; vertical-align: -0.2em; }
/* The print look of text-bearing widgets, kept by their primitive appearance. */
input:not([type=checkbox i], [type=radio i], [type=range i], [type=image i], [type=file i],
    [type=reset i], [type=button i], [type=submit i], [type=color i]), textarea, select {
    border: 1px solid ButtonBorder; border-radius: 2px; padding: 1px 2px;
    background-color: Field; color: FieldText; }
button, ::file-selector-button, input:is([type=reset i], [type=button i], [type=submit i],
    [type=color i]) { border: 1px solid ButtonBorder; border-radius: 3px; padding: 1px 6px;
    background-color: ButtonFace; color: ButtonText; }
input[type=color i] { padding: 2px; }
input:is([type=checkbox i], [type=radio i]) { margin-block: 3px; margin-inline: 4px 3px; }
select:is([multiple], [size]:not([size="0"], [size="1"])) option:checked {
    background-color: SelectedItem; color: SelectedItemText; }
::placeholder { color: GrayText; }
:disabled:is(input, textarea, select, button), option:disabled, optgroup:disabled {
    color: GrayText; }
fieldset { display: block; margin-inline: 2px; border: groove 2px ThreeDFace;
    padding-block: 0.35em 0.625em; padding-inline: 0.75em; min-inline-size: min-content; }
legend { padding-inline: 2px; }
legend[align=left i] { justify-self: left; }
legend[align=center i] { justify-self: center; }
legend[align=right i] { justify-self: right; }
/* Embedded content (HTML Standard §15.4.1). */
iframe { border: 2px inset; }
video { object-fit: contain; }
img:is([sizes="auto" i], [sizes^="auto," i]) {
    contain: size !important;
    contain-intrinsic-size: 300px 150px;
}