arsd.html

This module includes functions to work with HTML and CSS.

It publically imports the DOM module to get started. Then it adds a number of functions to enhance html DOM documents and make other changes, like scripts and stylesheets.

Members

Classes

CssPart
class CssPart

This wraps up a bunch of javascript magic. It doesn't actually parse or run it - it just collects it for attachment to a DOM document.

Enums

HtmlFeatures
enum HtmlFeatures

This is a list of features you can allow when using the sanitizedHtml function.

UriFeatures
enum UriFeatures

The things to allow in links, images, css, and aother urls. FIXME: implement this for better flexibility

Functions

addOnLoad
void addOnLoad(Document document)

Adds some script to run onload FIXME: not implemented

appearsToBeHtml
bool appearsToBeHtml(string src)

Returns true of the string appears to be html/xml - if it matches the pattern for tags or entities.

denestCss
const(CssPart)[] denestCss(CssPart[] css)

Translates nested css

makePostLink
Form makePostLink(string href, string innerText, string[string] params = null)

Convenience function to create a small <form> to POST, but the creation function is more like a link than a DOM form.

makePostLink
Form makePostLink(string href, Html innerHtml, string[string] params = null)

Similar to the above, but lets you pass HTML rather than just text. It puts the html inside a <button type="submit"> element.

makePostLink
Form makePostLink(string href, Element submitButtonContents, string[string] params = null)

Like the Html overload, this uses a <button> tag to get fancier with the submit button. The element you pass is appended to the submit button.

makePostLink
Form makePostLink(Element link)

Given an existing link, create a POST item from it. You can use this to do something like:

sanitizedHtml
Element sanitizedHtml(Element userContent, string idPrefix = null, HtmlFeatures allow = HtmlFeatures.links | HtmlFeatures.images | HtmlFeatures.css)

This returns an element wrapping sanitized content, using a whitelist for html tags and attributes, and a blacklist for css. Javascript is never allowed.

translateDateInputs
void translateDateInputs(Document document)

makes input[type=date] to call displayDatePicker with a button

translateFiltering
void translateFiltering(Document document)

tries to make an input to filter a list. it kinda sucks.

translateInputTitles
void translateInputTitles(Element rootElement)

find <input> elements with a title. Make the title the default internal content

translateStriping
void translateStriping(Document document)

finds class="striped" and adds class="odd"/class="even" to the relevant children

translateValidation
void translateValidation(Document document)

Translates validate="" tags to inline javascript. "this" is the thing being checked.

wrapTextNodes
void wrapTextNodes(Document document, TextWrapperWhitespaceBehavior whatToDoWithWhitespaceNodes = TextWrapperWhitespaceBehavior.ignore)

This wraps every non-empty text mode in the document body with <t:t></t:t>, and sets an xmlns:t to the html root.

Variables

recommendedBasicCssForUserContent
string recommendedBasicCssForUserContent

This is some basic CSS I suggest you copy/paste into your stylesheet if you use the sanitizedHtml function.

Suggestion Box / Bug Report