Element

Enum Element 

Source
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 &nbsp;.

§

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.

Fields

§attributes: AttributeMap<'t>
§elements: Vec<Element<'t>>
§

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]].

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.

Fields

§ltype: LinkType
§link: LinkLocation<'t>
§extra: Option<Cow<'t, str>>
§label: LinkLabel<'t>
§

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>
§attributes: AttributeMap<'t>
§

List

An ordered or unordered list.

Fields

§ltype: ListType
§attributes: AttributeMap<'t>
§items: Vec<ListItem<'t>>
§

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.

Fields

§name: Cow<'t, str>
§checked: bool
§attributes: AttributeMap<'t>
§

CheckBox

A checkbox.

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

Fields

§checked: bool
§attributes: 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

§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

A table of contents block.

This contains links to sub-headings on the page.

Fields

§attributes: AttributeMap<'t>
§

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

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

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 ...]].

Fields

§label: Cow<'t, str>
§brackets: bool
§

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.

Fields

§index: usize
§title: Option<Cow<'t, str>>
§hide: bool
§

User

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

Fields

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

Date

A date display, showcasing a particular moment in time.

Fields

§value: DateItem
§format: Option<Cow<'t, str>>
§hover: bool
§

Color

Element containing colored text.

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

Fields

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

Code(CodeBlock<'t>)

Element containing a code block.

§

Math

Element containing a named math equation.

Fields

§name: Option<Cow<'t, str>>
§latex_source: Cow<'t, str>
§

MathInline

Element containing inline math.

Fields

§latex_source: Cow<'t, str>
§

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.

Fields

§contents: Cow<'t, str>
§attributes: AttributeMap<'t>
§

Iframe

Element containing an iframe component.

Fields

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

Include

Element containing the contents of a page included elsewhere.

From [[include-elements]].

Fields

§paragraph_safe: bool
§variables: VariableMap<'t>
§location: PageRef
§elements: Vec<Element<'t>>
§

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<'_>

Source

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 property White_Space.

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

Source

pub fn name(&self) -> &'static str

Returns the Rust name of this Element variant.

Source

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

Source

pub fn to_owned(&self) -> Element<'static>

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§

Source§

impl<'t> Clone for Element<'t>

Source§

fn clone(&self) -> Element<'t>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'t> Debug for Element<'t>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, 't> Deserialize<'de> for Element<'t>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'t> From<Element<'t>> for Elements<'t>

Source§

fn from(element: Element<'t>) -> Elements<'t>

Converts to this type from the input type.
Source§

impl<'t> PartialEq for Element<'t>

Source§

fn eq(&self, other: &Element<'t>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'t> Serialize for Element<'t>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'t> Eq for Element<'t>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,