A Clojure library for parsing, sanitising and escaping HTML, built on jsoup.
A Clojure library for parsing, sanitising and escaping HTML, built on jsoup.
(body-html doc)Returns the inner HTML of the document body as a string.
Returns the inner HTML of the document body as a string.
(clean html)(clean html opts)Removes everything from the html string that is not allowed by a
safelist, so that untrusted markup can be embedded safely. Returns a
string.
Options:
:safelist one of :none, :simple-text, :basic (default),
:basic-with-images, :relaxed.:add-tags tags to allow in addition to the safelist, e.g. [:section].:remove-tags tags to disallow.:add-attributes map of tag to attributes to allow,
e.g. {:a [:target] :all [:class]}.:remove-attributes same shape, to disallow attributes.:base-uri base used to resolve relative links, default "". Without
it, relative links cannot be resolved and are removed.:preserve-relative-links keep relative URLs as they are instead of
making them absolute. Still requires :base-uri.:pretty-print boolean, default false.:escape-mode one of :base, :xhtml, :extended.Removes everything from the `html` string that is not allowed by a
safelist, so that untrusted markup can be embedded safely. Returns a
string.
Options:
- `:safelist` one of :none, :simple-text, :basic (default),
:basic-with-images, :relaxed.
- `:add-tags` tags to allow in addition to the safelist, e.g. [:section].
- `:remove-tags` tags to disallow.
- `:add-attributes` map of tag to attributes to allow,
e.g. {:a [:target] :all [:class]}.
- `:remove-attributes` same shape, to disallow attributes.
- `:base-uri` base used to resolve relative links, default "". Without
it, relative links cannot be resolved and are removed.
- `:preserve-relative-links` keep relative URLs as they are instead of
making them absolute. Still requires `:base-uri`.
- `:pretty-print` boolean, default false.
- `:escape-mode` one of :base, :xhtml, :extended.(escape-html s)(escape-html s opts)Escapes s so it is safe to embed as HTML text.
Takes the same :escape-mode and :pretty-print options as parse
(default :base).
Escapes `s` so it is safe to embed as HTML text. Takes the same `:escape-mode` and `:pretty-print` options as `parse` (default :base).
(parse html)(parse html opts)Parses the html string into a jsoup Document.
Options:
:pretty-print boolean, default true.:escape-mode one of :base, :xhtml, :extended.Parses the `html` string into a jsoup Document. Options: - `:pretty-print` boolean, default true. - `:escape-mode` one of :base, :xhtml, :extended.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |