Liking cljdoc? Tell your friends :D

dk.simongray.html-pieces

Embedded pieces of HTML, such as comments, the descriptions in feeds or the fields of a CMS, read into Hiccup and rendered from there.

TODO: an optional report of what parsing discarded and sanitizing removed, e.g. in metadata, so that a validator can tell the author of the HTML what a client won't show.

TODO: in the browser, an option to parse with the browser's own DOMParser and read its DOM as Hiccup, as hickory does, which would keep the tokenizer, the tree builder and the table of character references out of the bundle. It would come at a cost:

  • the result could differ from the JVM's and Node's, since a browser follows every rule of tree construction, e.g. it carries formatting on past a misnested end tag, moves the content of tables, and rearranges the html, head and body of a whole page
  • Node has no DOM, so the tokenizer would still be needed there
  • DOMParser reads a whole document, so a fragment would be the children of its body, and :max-depth would have to be applied while reading the DOM
Embedded pieces of HTML, such as comments, the descriptions in feeds or
the fields of a CMS, read into Hiccup and rendered from there.

TODO: an optional report of what parsing discarded and sanitizing
removed, e.g. in metadata, so that a validator can tell the author of
the HTML what a client won't show.

TODO: in the browser, an option to parse with the browser's own
DOMParser and read its DOM as Hiccup, as hickory does, which would keep
the tokenizer, the tree builder and the table of character references
out of the bundle. It would come at a cost:

- the result could differ from the JVM's and Node's, since a browser
  follows every rule of tree construction, e.g. it carries formatting on
  past a misnested end tag, moves the content of tables, and rearranges
  the html, head and body of a whole page
- Node has no DOM, so the tokenizer would still be needed there
- DOMParser reads a whole document, so a fragment would be the children
  of its body, and :max-depth would have to be applied while reading the
  DOM
raw docstring

allowed-attributesclj/s

The attributes that are safe to render, by element.

The attributes that are safe to render, by element.
sourceraw docstring

allowed-schemesclj/s

The schemes of the URLs that are safe to keep or show as links.

The schemes of the URLs that are safe to keep or show as links.
sourceraw docstring

allowed-tagsclj/s

The elements that are safe to render.

The elements that are safe to render.
sourceraw docstring

default-optionsclj/s

The default of each option. Most are vars of the same name, and the others are:

  • :url-fn, a function of a URL that gives the URL to keep, or nil
  • :links?, true to put the URL of each link after it in plain text
  • :quirks?, true to read a C1 control character as windows-1252 in text and Markdown, a repair that the HTML Standard doesn't make
The default of each option. Most are vars of the same name, and the
others are:

- :url-fn, a function of a URL that gives the URL to keep, or nil
- :links?, true to put the URL of each link after it in plain text
- :quirks?, true to read a C1 control character as windows-1252 in text
  and Markdown, a repair that the HTML Standard doesn't make
sourceraw docstring

dropped-tagsclj/s

The elements that are removed with their content.

The elements that are removed with their content.
sourceraw docstring

hiccupclj/s

(hiccup x)
(hiccup x opts)

The HTML, plain text or Hiccup x as Hiccup that's safe to render, by these keys of opts:

  • elements of :allowed-tags are kept, with the attributes of :allowed-attributes
  • elements of :dropped-tags are removed with their content
  • other elements are replaced by their children
  • a URL is kept, as :url-fn rewrites it, when its scheme is one of :allowed-schemes, which leaves out relative URLs by default

Plain text becomes paragraphs with line breaks. Text is decoded, e.g. < is <, so use a renderer that escapes text.

The HTML, plain text or Hiccup `x` as Hiccup that's safe to render, by
these keys of `opts`:

- elements of :allowed-tags are kept, with the attributes of
  :allowed-attributes
- elements of :dropped-tags are removed with their content
- other elements are replaced by their children
- a URL is kept, as :url-fn rewrites it, when its scheme is one of
  :allowed-schemes, which leaves out relative URLs by default

Plain text becomes paragraphs with line breaks. Text is decoded, e.g.
&lt; is <, so use a renderer that escapes text.
sourceraw docstring

line-tagsclj/s

Elements that end a line in text and Markdown.

Elements that end a line in text and Markdown.
sourceraw docstring

markdownclj/s

(markdown x)
(markdown x opts)

The HTML or Hiccup x as Markdown, by opts. Text is escaped where Markdown would read it as markup, and a link or an image is its text when the scheme isn't allowed. Control characters are left out, but for tabs and line breaks.

The HTML or Hiccup `x` as Markdown, by `opts`. Text is escaped where
Markdown would read it as markup, and a link or an image is its text
when the scheme isn't allowed. Control characters are left out, but for
tabs and line breaks.
sourceraw docstring

markup?clj/s

(markup? s)

Whether the text s is HTML rather than plain text: whether it holds a comment or a whole tag.

Whether the text `s` is HTML rather than plain text: whether it holds a
comment or a whole tag.
sourceraw docstring

max-depthclj/s

How deep elements nest at most. An element opened deeper is kept empty, and its content goes to its parent, so that no walk of the tree overflows the stack.

How deep elements nest at most. An element opened deeper is kept empty,
and its content goes to its parent, so that no walk of the tree
overflows the stack.
sourceraw docstring

max-quote-depthclj/s

How deep quotes nest in Markdown at most. A deeper quote is a plain paragraph, so that no line starts with hundreds of >.

How deep quotes nest in Markdown at most. A deeper quote is a plain
paragraph, so that no line starts with hundreds of >.
sourceraw docstring

paragraph-tagsclj/s

Elements set off by a blank line in text and Markdown.

Elements set off by a blank line in text and Markdown.
sourceraw docstring

parseclj/s

(parse s)
(parse s opts)

The HTML s as a sequence of Hiccup nodes, nested at most as deep as the :max-depth of opts. Nothing is sanitized, so for HTML to render, use hiccup or sanitize.

Unclosed elements close where a browser closes them, but formatting isn't carried on past a misnested end tag. The html, head and body elements of a whole page stay as they're written. Comments and DOCTYPEs are left out.

The HTML `s` as a sequence of Hiccup nodes, nested at most as deep as the
:max-depth of `opts`. Nothing is sanitized, so for HTML to render, use
hiccup or sanitize.

Unclosed elements close where a browser closes them, but formatting isn't
carried on past a misnested end tag. The html, head and body elements of
a whole page stay as they're written. Comments and DOCTYPEs are left out.
sourceraw docstring

sanitizeclj/s

(sanitize x)
(sanitize x opts)

The HTML, plain text or Hiccup x as HTML that's safe to render, by the opts of hiccup.

The HTML, plain text or Hiccup `x` as HTML that's safe to render, by the
`opts` of hiccup.
sourceraw docstring

textclj/s

(text x)
(text x opts)

The HTML or Hiccup x as plain text, by opts. An image is its alt text, and a link is followed by its URL when :links? and the scheme is allowed. Control characters are left out, but for tabs and line breaks.

The HTML or Hiccup `x` as plain text, by `opts`. An image is its alt
text, and a link is followed by its URL when :links? and the scheme is
allowed. Control characters are left out, but for tabs and line breaks.
sourceraw docstring

url-attributesclj/s

The attributes whose value is a URL.

The attributes whose value is a URL.
sourceraw docstring

url-list-attributesclj/s

The attributes whose value is a list of URLs, separated by spaces, or by commas in a srcset.

The attributes whose value is a list of URLs, separated by spaces, or by
commas in a srcset.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close