#[non_exhaustive]
pub enum HtmlVersion {
    HTML5,
    HTML4,
    XHTML1_0,
    XHTML1_1,
}
Expand description

Versions of the HTML (or XHTML) standard

These can be used to change the doctype and apply attributes to an HtmlPage.

Example

assert_eq!(
    HtmlPage::with_version(HtmlVersion::HTML5).to_html_string(),
    "<!DOCTYPE html><html><head></head><body></body></html>"
);

assert_eq!(
    HtmlPage::with_version(HtmlVersion::XHTML1_0).to_html_string(),
    concat!(
        r#"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "#,
        r#""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"#,
        r#"<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>"#,
    ),
)

Compliance With HTML Standards

Please note that while we allow users to specify the version of the HTML standard their page is written in, this library does not and will not check whether your page is actually valid in that standard. Our feature set is targeting development in HTML5 and it is possible that some tags or attributes may not be valid in older HTML versions. You are responsible for knowing which subset of the provided features are valid for your chosen version. Use this feature at your own risk.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

HTML5

HTML 5. The current and preferred version of the HTML standard.

§

HTML4

Legacy HTML 4.01. Potentially useful for supporting old browsers.

§

XHTML1_0

Legacy XHTML 1.0. This is still common in HTML emails for backwards compatibility with different email clients.

§

XHTML1_1

Legacy XHTML 1.1.

Implementations§

source§

impl HtmlVersion

source

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

Return the DOCTYPE (DTD) that corresponds to this version of the HTML standard

source

pub fn html_attrs(&self) -> Attributes

Return the set of attributes that should be applied to the HtmlPage’s opening HTML tag

Trait Implementations§

source§

impl Debug for HtmlVersion

source§

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

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

impl Default for HtmlVersion

source§

fn default() -> HtmlVersion

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.