Decorator

com.alecdorrington.annotatedtextformat.dom.Decorator
object Decorator

Puts annotations into the page itself, in the text of a Passage, as a page that is not one's own must be: splitting its text nodes and wrapping their parts, never building the passage anew, and leaving each text node of the page where it was, so that Decoration.restore gives the page back exactly as it was, its own text nodes whole.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Decorator.type

Members list

Value members

Concrete methods

def decorate[A](passage: Passage, annotated: AnnotatedText[A], look: Look[A], prefix: String = ..., whole: Boolean = ..., split: (Text, Text) => Unit = ...): Either[Refusal, Decoration[A]]

annotated, put into the page in passage, whose text it must be of, as look shows it. Each element it puts there has the class prefix, or one beginning with it, the attribute data-, the indices of the annotations it belongs to, and the attribute Passage.decorated. It owns the background of each element it highlights, drawing beneath the highlight whatever layers look adds, and, where the system forces its own colours, which takes backgrounds away, it underlines the text. It is refused if the annotations are of another text, or if prefix could not begin a class's name as it is, unescaped in a selector.

annotated, put into the page in passage, whose text it must be of, as look shows it. Each element it puts there has the class prefix, or one beginning with it, the attribute data-, the indices of the annotations it belongs to, and the attribute Passage.decorated. It owns the background of each element it highlights, drawing beneath the highlight whatever layers look adds, and, where the system forces its own colours, which takes backgrounds away, it underlines the text. It is refused if the annotations are of another text, or if prefix could not begin a class's name as it is, unescaped in a selector.

If whole, an annotation is put in only if all of it can be, as it cannot be over what is not prose, or another decoration, nor over line breaks alone, nor at a point with no text beside it or within what another annotation shows in place of its text, nor show its text in place of what another already does; the rest are its unplaced.

Once the page is decorated, it tells split of each text node of the page that it split, with the node split off it, if that is still in the page, not wrapped or replaced by an element of its own, as an application marking the page's nodes may copy its mark; a split that throws is passed over. As the decoration is restored, each node split off is joined back into the node it came from, and taken out of the page.

Decorations of one page may be restored in any order.

Attributes