Enum ftml::tree::Element[][src]

pub enum Element<'t> {
Show 28 variants Container(Container<'t>), Module(Module<'t>), Text(Cow<'t, str>), Raw(Cow<'t, str>), Variable(Cow<'t, str>), Email(Cow<'t, str>), Table(Table<'t>), Anchor { target: Option<AnchorTarget>, attributes: AttributeMap<'t>, elements: Vec<Element<'t>>, }, Link { link: LinkLocation<'t>, label: LinkLabel<'t>, target: Option<AnchorTarget>, }, Image { source: ImageSource<'t>, link: Option<LinkLocation<'t>>, alignment: Option<FloatAlignment>, attributes: AttributeMap<'t>, }, List { ltype: ListType, attributes: AttributeMap<'t>, items: Vec<ListItem<'t>>, }, RadioButton { name: Cow<'t, str>, checked: bool, attributes: AttributeMap<'t>, }, CheckBox { checked: bool, attributes: AttributeMap<'t>, }, Collapsible { elements: Vec<Element<'t>>, attributes: AttributeMap<'t>, start_open: bool, show_text: Option<Cow<'t, str>>, hide_text: Option<Cow<'t, str>>, show_top: bool, show_bottom: bool, }, TableOfContents { attributes: AttributeMap<'t>, align: Option<Alignment>, }, Footnote, FootnoteBlock { title: Option<Cow<'t, str>>, hide: bool, }, User { name: Cow<'t, str>, show_avatar: bool, }, Color { color: Cow<'t, str>, elements: Vec<Element<'t>>, }, Code { contents: Cow<'t, str>, language: Option<Cow<'t, str>>, }, Html { contents: Cow<'t, str>, }, Iframe { attributes: AttributeMap<'t>, url: Cow<'t, str>, }, Include { paragraph_safe: bool, variables: VariableMap<'t>, location: PageRef<'t>, elements: Vec<Element<'t>>, }, LineBreak, LineBreaks(NonZeroU32), ClearFloat(ClearFloat), HorizontalRule, Partial(PartialElement<'t>),
}

Variants

Container(Container<'t>)

Generic element that contains other elements within it.

Examples would include divs, italics, paragraphs, etc.

Tuple Fields of Container

0: Container<'t>
Module(Module<'t>)

A Wikidot module being invoked, along with its arguments.

These modules require some kind of processing by backend software, so are represented in module forum rather than as elements to be directly rendered.

Tuple Fields of Module

0: Module<'t>
Text(Cow<'t, str>)

An element only containing text.

Should be formatted like typical body text.

Tuple Fields of Text

0: Cow<'t, str>
Raw(Cow<'t, str>)

Raw text.

This should be formatted exactly as listed. For instance, spaces being rendered to HTML should produce a &nbsp;.

Tuple Fields of Raw

0: Cow<'t, str>
Variable(Cow<'t, str>)

A wikitext variable.

During rendering, this will be replaced with its actual value, as appropriate to the context.

Tuple Fields of Variable

0: Cow<'t, str>
Email(Cow<'t, str>)

An element indicating an email.

Whether this should become a clickable href link or just text is up to the render implementation.

Tuple Fields of Email

0: Cow<'t, str>
Table(Table<'t>)

An element representing an HTML table.

Tuple Fields of Table

0: Table<'t>
Anchor

An element representing an arbitrary anchor.

This is distinct from link in that it maps to HTML <a>, and does not necessarily mean a link to some other URL.

Fields of Anchor

target: Option<AnchorTarget>attributes: AttributeMap<'t>elements: Vec<Element<'t>>

An element linking to a different page.

The “label” field is an optional field denoting what the link should display.

The “link” field is either a page reference (relative URL) or full URL.

Fields of Link

link: LinkLocation<'t>label: LinkLabel<'t>target: Option<AnchorTarget>
Image

An element representing an image and its associated metadata.

The “source” field is the link to the image itself.

The “link” field is what the <a> points to, when the user clicks on the image.

Fields of Image

source: ImageSource<'t>link: Option<LinkLocation<'t>>alignment: Option<FloatAlignment>attributes: AttributeMap<'t>
List

An ordered or unordered list.

Fields of List

ltype: ListTypeattributes: AttributeMap<'t>items: Vec<ListItem<'t>>
RadioButton

A radio button.

The “name” field translates to HTML, but is standard for grouping them. The “checked” field determines if the radio button starts checked or not.

Fields of RadioButton

name: Cow<'t, str>checked: boolattributes: AttributeMap<'t>
CheckBox

A checkbox.

The “checked” field determines if the radio button starts checked or not.

Fields of CheckBox

checked: boolattributes: AttributeMap<'t>
Collapsible

A collapsible, containing content hidden to be opened on click.

This is an interactable element provided by Wikidot which allows hiding all of the internal elements until it is opened by clicking, which can then be re-hidden by clicking again.

Fields of Collapsible

elements: Vec<Element<'t>>attributes: AttributeMap<'t>start_open: boolshow_text: Option<Cow<'t, str>>hide_text: Option<Cow<'t, str>>show_top: boolshow_bottom: bool
TableOfContents

A table of contents block.

This contains links to sub-headings on the page.

Fields of TableOfContents

attributes: AttributeMap<'t>align: Option<Alignment>
Footnote

A footnote reference.

This specifies that a [[footnote]] was here, and that a clickable link to the footnote block should be added.

The index is not saved because it is part of the rendering context. It is indirectly preserved as the index of the footnotes list in the syntax tree.

FootnoteBlock

A footnote block, containing all the footnotes from throughout the page.

If a [[footnoteblock]] is not added somewhere in the content of the page, then it is automatically appended to the end of the syntax tree.

Fields of FootnoteBlock

title: Option<Cow<'t, str>>hide: bool
User

A user block, linking to their information and possibly showing their avatar.

Fields of User

name: Cow<'t, str>show_avatar: bool
Color

Element containing colored text.

The CSS designation of the color is specified, followed by the elements contained within.

Fields of Color

color: Cow<'t, str>elements: Vec<Element<'t>>
Code

Element containing a code block.

Fields of Code

contents: Cow<'t, str>language: Option<Cow<'t, str>>
Html

Element containing a sandboxed HTML block.

Fields of Html

contents: Cow<'t, str>
Iframe

Element containing an iframe component.

Fields of Iframe

attributes: AttributeMap<'t>url: Cow<'t, str>
Include

Element containing the contents of a page included elsewhere.

From [[include-elements]].

Fields of Include

paragraph_safe: boolvariables: VariableMap<'t>location: PageRef<'t>elements: Vec<Element<'t>>
LineBreak

A newline or line break.

This calls for a newline in the final output, such as <br> in HTML.

LineBreaks(NonZeroU32)

A collection of line breaks adjacent to each other.

Tuple Fields of LineBreaks

0: NonZeroU32
ClearFloat(ClearFloat)

A “clear float” div.

Tuple Fields of ClearFloat

0: ClearFloat
HorizontalRule

A horizontal rule.

Partial(PartialElement<'t>)

A partial element.

This will not appear in final syntax trees, but exists to facilitate parsing of complicated structures.

See WJ-816.

Tuple Fields of Partial

0: PartialElement<'t>

Implementations

Determines if the element is “unintentional whitespace”.

Specifically, it returns true if the element is:

  • Element::LineBreak
  • Element::Text where the contents all have the Unicode property White_Space.

This does not count Element::LineBreaks because it is produced intentionally via [[lines]] rather than extra whitespace in between syntactical elements.

Returns the Rust name of this Element variant.

Determines if this element type is able to be embedded in a paragraph.

It does not look into the interiors of the element, it only does a surface-level check.

This is to avoid making the call very expensive, but for a complete understanding of the paragraph requirements, see the Elements return.

See https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#phrasing_content

Deep-clones the object, making it an owned version.

Note that .to_owned() on Cow just copies the pointer, it doesn’t make an Cow::Owned(_) version like its name suggests.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Serialize self into Serializer Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.