pub enum Element<'t> {
Show 39 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>),
TabView(Vec<Tab<'t>>),
Anchor {
target: Option<AnchorTarget>,
attributes: AttributeMap<'t>,
elements: Vec<Element<'t>>,
},
AnchorName(Cow<'t, str>),
Link {
ltype: LinkType,
link: LinkLocation<'t>,
extra: Option<Cow<'t, str>>,
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>>,
},
DefinitionList(Vec<DefinitionListItem<'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,
},
BibliographyCite {
label: Cow<'t, str>,
brackets: bool,
},
BibliographyBlock {
index: usize,
title: Option<Cow<'t, str>>,
hide: bool,
},
User {
name: Cow<'t, str>,
show_avatar: bool,
},
Date {
value: DateItem,
format: Option<Cow<'t, str>>,
hover: bool,
},
Color {
color: Cow<'t, str>,
elements: Vec<Element<'t>>,
},
Code(CodeBlock<'t>),
Math {
name: Option<Cow<'t, str>>,
latex_source: Cow<'t, str>,
},
MathInline {
latex_source: Cow<'t, str>,
},
EquationReference(Cow<'t, str>),
Embed(Embed<'t>),
Html {
contents: Cow<'t, str>,
attributes: AttributeMap<'t>,
},
Iframe {
url: Cow<'t, str>,
attributes: AttributeMap<'t>,
},
Include {
paragraph_safe: bool,
variables: VariableMap<'t>,
location: PageRef,
elements: Vec<Element<'t>>,
},
Style(Cow<'t, str>),
LineBreak,
LineBreaks(NonZeroU32),
ClearFloat(ClearFloat),
HorizontalRule,
Partial(PartialElement<'t>),
}
Expand description
Represents an element to be rendered.
Variants§
Container(Container<'t>)
Generic element that contains other elements within it.
Examples would include divs, italics, paragraphs, etc.
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.
Text(Cow<'t, str>)
An element only containing text.
Should be formatted like typical body text.
Raw(Cow<'t, str>)
Raw text.
This should be formatted exactly as listed.
For instance, spaces being rendered to HTML should
produce a
.
Variable(Cow<'t, str>)
A wikitext variable.
During rendering, this will be replaced with its actual value, as appropriate to the context.
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.
Table(Table<'t>)
An element representing an HTML table.
TabView(Vec<Tab<'t>>)
An element representing a tabview.
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.
AnchorName(Cow<'t, str>)
An element representing a named anchor.
This is an area of the page that can be jumped to by name.
Associated syntax is [[# name-of-anchor]]
.
Link
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.
The “ltype” field tells what kind of link produced this element.
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
source: ImageSource<'t>
link: Option<LinkLocation<'t>>
alignment: Option<FloatAlignment>
attributes: AttributeMap<'t>
List
An ordered or unordered list.
DefinitionList(Vec<DefinitionListItem<'t>>)
A definition list.
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.
CheckBox
A checkbox.
The “checked” field determines if the radio button starts checked or not.
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
attributes: AttributeMap<'t>
TableOfContents
A table of contents block.
This contains links to sub-headings on the page.
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.
BibliographyCite
A citation of a bibliography element, invoked via ((bibcite ...))
.
The brackets
field tells whether the resultant HTML should be surrounded
in [..]
, which is not very easily possible when using [[bibcite ...]]
.
BibliographyBlock
A bibliography block, containing all the cited items from throughout the page.
The index
field is the zero-indexed value of which bibliography block this is.
User
A user block, linking to their information and possibly showing their avatar.
Date
A date display, showcasing a particular moment in time.
Color
Element containing colored text.
The CSS designation of the color is specified, followed by the elements contained within.
Code(CodeBlock<'t>)
Element containing a code block.
Math
Element containing a named math equation.
MathInline
Element containing inline math.
EquationReference(Cow<'t, str>)
Element referring to an equation elsewhere in the page.
Embed(Embed<'t>)
An embedded piece of media or content from elsewhere.
Html
Element containing a sandboxed HTML block.
Iframe
Element containing an iframe component.
Include
Element containing the contents of a page included elsewhere.
From [[include-elements]]
.
Style(Cow<'t, str>)
A CSS stylesheet.
Corresponds with a <style>
entity in the body of the HTML.
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.
ClearFloat(ClearFloat)
A “clear float” div.
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
.
Implementations§
Source§impl Element<'_>
impl Element<'_>
Sourcepub fn is_whitespace(&self) -> bool
pub fn is_whitespace(&self) -> bool
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.
Sourcepub fn paragraph_safe(&self) -> bool
pub fn paragraph_safe(&self) -> bool
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§
Source§impl<'de, 't> Deserialize<'de> for Element<'t>
impl<'de, 't> Deserialize<'de> for Element<'t>
Source§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>,
impl<'t> Eq for Element<'t>
impl<'t> StructuralPartialEq for Element<'t>
Auto Trait Implementations§
impl<'t> Freeze for Element<'t>
impl<'t> RefUnwindSafe for Element<'t>
impl<'t> Send for Element<'t>
impl<'t> Sync for Element<'t>
impl<'t> Unpin for Element<'t>
impl<'t> UnwindSafe for Element<'t>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more