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>
An element only containing text.
Should be formatted like typical body text.
Raw text.
This should be formatted exactly as listed.
For instance, spaces being rendered to HTML should
produce a
.
A wikitext variable.
During rendering, this will be replaced with its actual value, as appropriate to the context.
An element indicating an email.
Whether this should become a clickable href link or just text is up to the render implementation.
Table(Table<'t>)
An element representing an HTML table.
Tuple Fields of Table
0: Table<'t>
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
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
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>
An ordered or unordered list.
Fields of List
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
A checkbox.
The “checked” field determines if the radio button starts checked or not.
Fields of CheckBox
checked: bool
attributes: AttributeMap<'t>
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
A table of contents block.
This contains links to sub-headings on the page.
Fields of TableOfContents
attributes: AttributeMap<'t>
align: Option<Alignment>
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.
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.
A user block, linking to their information and possibly showing their avatar.
Element containing colored text.
The CSS designation of the color is specified, followed by the elements contained within.
Element containing a code block.
Element containing a sandboxed HTML block.
Element containing an iframe component.
Fields of Iframe
attributes: AttributeMap<'t>
url: Cow<'t, str>
Element containing the contents of a page included elsewhere.
From [[include-elements]]
.
Fields of Include
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
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 propertyWhite_Space
.
This does not count Element::LineBreaks
because it is produced intentionally
via [[lines]]
rather than extra whitespace in between syntactical elements.
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
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<'t> RefUnwindSafe for Element<'t>
impl<'t> UnwindSafe for Element<'t>
Blanket Implementations
Mutably borrows from an owned value. Read more