import { AmmoniaBuilder } from "https://deno.land/x/ammonia@0.3.1/mod.ts";
Properties
Sets the CSS classes that are allowed on specific tags.
The values is structured as a map from tag names to a set of class names.
If the class
attribute is itself whitelisted for a tag, then adding
entries to this map will cause a panic.
Defaults
The set of allowed classes is empty by default.
The tags whose contents will be completely removed from the output.
Adding tags which are whitelisted in tags or tagAttributes will cause a panic.
Defaults
script, style
Prefixes all "id" attribute values with a given string. Note that the tag and attribute themselves must still be whitelisted.
Defaults
null
Configures a rel
attribute that will be added on links.
If rel
is in the generic or tag attributes, this must be set to null
.
Common rel
values to include:
noopener
: This prevents a particular type of XSS attack, and should usually be turned on for untrusted HTML.noreferrer
: This prevents the browser from sending the source URL to the website that is linked to.nofollow
: This prevents search engines from using this link for ranking, which disincentivizes spammers.
To turn on rel-insertion, call this function with a space-separated list. Ammonia does not parse rel-attributes; it just puts the given string into the attribute directly.
Defaults
"noopener noreferrer"
Sets the values of HTML attributes that are to be set on specific tags.
The value is structured as a map from tag names to a map from attribute names to an attribute value.
If a tag is not itself whitelisted, adding entries to this map will do nothing.
Defaults
None
Configures the handling of HTML comments.
If this option is false, comments will be preserved.
Defaults
true
The HTML attributes that are allowed on specific tags.
The value is structured as a map from tag names to a set of attribute names.
If a tag is not itself whitelisted, adding entries to this map will do nothing.
Defaults
a =>
href, hreflang
bdo =>
dir
blockquote =>
cite
col =>
align, char, charoff, span
colgroup =>
align, char, charoff, span
del =>
cite, datetime
hr =>
align, size, width
img =>
align, alt, height, src, width
ins =>
cite, datetime
ol =>
start
q =>
cite
table =>
align, char, charoff, summary
tbody =>
align, char, charoff
td =>
align, char, charoff, colspan, headers, rowspan
tfoot =>
align, char, charoff
th =>
align, char, charoff, colspan, headers, rowspan, scope
thead =>
align, char, charoff
tr =>
align, char, charoff
Sets the values of HTML attributes that are allowed on specific tags.
The value is structured as a map from tag names to a map from attribute names to a set of attribute values.
If a tag is not itself whitelisted, adding entries to this map will do nothing.
Defaults
None
The tags that are allowed.
Defaults
a, abbr, acronym, area, article, aside, b, bdi,
bdo, blockquote, br, caption, center, cite, code,
col, colgroup, data, dd, del, details, dfn, div,
dl, dt, em, figcaption, figure, footer, h1, h2,
h3, h4, h5, h6, header, hgroup, hr, i, img,
ins, kbd, kbd, li, map, mark, nav, ol, p, pre,
q, rp, rt, rtc, ruby, s, samp, small, span,
strike, strong, sub, summary, sup, table, tbody,
td, th, thead, time, tr, tt, u, ul, var, wbr