Skip to main content

HtmlRenderOptions

Struct HtmlRenderOptions 

Source
pub struct HtmlRenderOptions {
    pub title: String,
    pub lang: Option<String>,
    pub source_spans: bool,
    pub run_in_stop: String,
    pub definitions: BTreeMap<Name, DefinitionOverride>,
    pub required_definitions: BTreeSet<Name>,
    pub heading_tags: BTreeMap<Name, String>,
    pub root_heading_level: u8,
}
Expand description

The render options of the HTML backend: the page’s title and language, the source-position attribute, the stop after a run-in heading, how stylesheets and scripts are delivered, the stylesheets and scripts the host adds to the page, how headings are tagged, and the heading level written as <h1>.

The option type is declared with Bind::Render, so its values come from the render request rather than from the document (see settings, options and configuration). The values are set on the plan request (PlanRequest::render_options), so two runs asking for different titles use two plans. The emit stages (flm.html.emit, flm.html.emit-pieces), the resolve stage flm.html.resolve-definitions and the regions stage flm.html.regions read them; the final stage reads only the regions.

§Examples

use flm_core::stdlib::backends::html::{DEFAULT_TITLE, HtmlRenderOptions};

let options = HtmlRenderOptions::default();
assert_eq!(options.title, DEFAULT_TITLE);
assert_eq!(options.lang, None);
assert!(!options.source_spans);
assert_eq!(options.run_in_stop, ".");
assert!(options.definitions.is_empty());
assert!(options.required_definitions.is_empty());
assert!(options.heading_tags.is_empty());
assert_eq!(options.root_heading_level, 1);

Fields§

§title: String

The page’s title when the document states none: the words written into <title> (the output region title) when the render places no title piece (flm.metadata.title) or the title piece holds no words. The default is DEFAULT_TITLE.

§lang: Option<String>

The page’s language as a language tag (en, de-CH), written as the lang attribute of <html> (the output region lang). None, the default, writes no attribute, because a page that claims a language it is not written in is worse for a reader using a screen reader than one that claims none.

§source_spans: bool

Whether the emitter writes the attribute data-flm-source-span, which records where in the source a node was written, on the element it writes for each node.

The attribute is written on every element written for a node, inline or block-level, once per node, when the node’s position can be traced back to a source with a name. Its value is a JSON array of the source’s name, the first byte of the range and the byte just past its end (["book/ch1.flm",0,8]), so a script reads it back with JSON.parse. It is written between single quotation marks, which HTML allows, so the raw page shows the JSON as JSON. Off by default: the attribute serves tools that map a place in the page back to the document, and it adds bytes to every page.

§run_in_stop: String

The stop written after the title of a run-in heading, so that \paragraph{Note} Some content. reads as Note. Some content. A run-in heading is a heading set at the start of the paragraph it introduces, on the paragraph’s first line (headings). The default is DEFAULT_RUN_IN_STOP, a period; the empty text writes none.

The stop is written as escaped text inside the run-in decoration’s <span>, after the title, so a reader copies it with the rest of the page and a host that replaces the stylesheet keeps it. It is written only when the title holds text and does not already end in sentence punctuation (ends_in_sentence_punctuation). That test looks only at the characters the title ends with, so a title that ends in a formula, or in a box an author’s own command draws, gets the stop after it. A host that needs headings written another way registers a lowering rule or a stage of its own (the extension guide).

§definitions: BTreeMap<Name, DefinitionOverride>

The deliveries the host gives in place of the declared content of style and script definitions, by definition identifier (DefinitionOverride). Empty by default: every definition is then delivered as its declaration says.

An identifier that no feature declares is ignored and reported as the Warning flm.html.unknown-definition.

§required_definitions: BTreeSet<Name>

The style and script definitions the host requires for the page as a whole, by identifier, in addition to those the document’s content requires. Empty by default: a page then carries exactly what its content needs.

A host that adds something of its own to every page it serves (for example a script that keeps an open page in step with the document, and its stylesheet) registers it as a definition of one of its features and lists its identifier here, rather than editing the page after it was written. A definition listed here appears once in the definitions table, like any other, whether or not the content requires it too, and reaches the page the same way; definitions still decides its delivery. An identifier that no feature declares is reported as the Error flm.html.unknown-requirement, as a requirement of the content would be.

§heading_tags: BTreeMap<Name, String>

The tag a block heading of each heading kind is written with, keyed by the heading kind’s name (section), the tag written without angle brackets (h2). Empty by default. A heading kind the map does not list is written <h1> to <h6> by its level (root_heading_level).

The title above every list of xnotes (notes set apart from the running text, such as footnotes; see xnotes) is a heading of the heading kind xnotes (TITLE_HEADING), for every xnote kind: mapping xnotes to h3 writes every such title <h3>.

The tag is not part of the HTML contract: the attributes a block heading carries (data-flm-heading, data-flm-level, data-flm-toc) are the same regardless of its tag. A heading of a run-in kind is written as a <span> carrying the same attributes inside its run-in decoration, never with this tag. A tag that is not a writable HTML tag name (is_valid_tag_name) is reported as flm.html.invalid-name, and the heading is written with the tag of its level.

§root_heading_level: u8

The heading level the page writes as its first-level heading, <h1>.

A heading’s level is a number counted from zero, the smaller the outer (HeadingPayload::level); a heading at this level is <h1>, one level deeper <h2>, and so on to <h6>, which every deeper level shares. The default is DEFAULT_ROOT_HEADING_LEVEL, 1, the level of a section: a section is <h1>. A root of 0 writes a kind declared at level 0, a chapter, <h1> and a section <h2>; a root of 2 writes the content of one section with its subsections as the first-level headings.

A heading whose level is less than the root is reported as flm.pres.heading-above-root and written <h1>, or with its tag where heading_tags maps its kind: the mapping decides the tag and nothing else. The attribute data-flm-level holds a heading’s own level regardless of the root. The option concerns the page’s tags only: the numbering, the run-in headings and the identifiers read a heading’s own level, as every other output does. The text output has the same option (TextRenderOptions::root_heading_level).

Trait Implementations§

Source§

impl Clone for HtmlRenderOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for HtmlRenderOptions

Source§

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

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

impl Default for HtmlRenderOptions

Source§

fn default() -> HtmlRenderOptions

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

impl<'de> Deserialize<'de> for HtmlRenderOptions

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 Eq for HtmlRenderOptions

Source§

impl Hash for HtmlRenderOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for HtmlRenderOptions

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for HtmlRenderOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HtmlRenderOptions

Auto Trait Implementations§

§

impl Forget for HtmlRenderOptions

§

impl Freeze for HtmlRenderOptions
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<Name, DefinitionOverride> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(Name, DefinitionOverride)>>: Freeze, *const LeafNode<Name, SetValZST> is !null: Freeze, PhantomData<Box<(Name, SetValZST)>>: Freeze, *const LeafNode<Name, String> is !null: Freeze, PhantomData<Box<(Name, String)>>: Freeze,

§

impl Move for HtmlRenderOptions

§

impl RefUnwindSafe for HtmlRenderOptions

§

impl Send for HtmlRenderOptions
where RawVecInner: Send, NodeRef<Owned, Name, DefinitionOverride, LeafOrInternal>: Send, BoxRaw<(Name, DefinitionOverride)>: Send, NodeRef<Owned, Name, SetValZST, LeafOrInternal>: Send, BoxRaw<(Name, SetValZST)>: Send, NodeRef<Owned, Name, String, LeafOrInternal>: Send, BoxRaw<(Name, String)>: Send,

§

impl Sync for HtmlRenderOptions
where RawVecInner: Sync, NodeRef<Owned, Name, DefinitionOverride, LeafOrInternal>: Sync, BoxRaw<(Name, DefinitionOverride)>: Sync, NodeRef<Owned, Name, SetValZST, LeafOrInternal>: Sync, BoxRaw<(Name, SetValZST)>: Sync, NodeRef<Owned, Name, String, LeafOrInternal>: Sync, BoxRaw<(Name, String)>: Sync,

§

impl Unpin for HtmlRenderOptions
where *const u8 is !null: Unpin, *const LeafNode<Name, DefinitionOverride> is !null: Unpin, Box<(Name, DefinitionOverride)>: Unpin, *const LeafNode<Name, SetValZST> is !null: Unpin, Box<(Name, SetValZST)>: Unpin, *const LeafNode<Name, String> is !null: Unpin, Box<(Name, String)>: Unpin,

§

impl UnsafeUnpin for HtmlRenderOptions
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<Name, DefinitionOverride> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(Name, DefinitionOverride)>>: UnsafeUnpin, *const LeafNode<Name, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(Name, SetValZST)>>: UnsafeUnpin, *const LeafNode<Name, String> is !null: UnsafeUnpin, PhantomData<Box<(Name, String)>>: UnsafeUnpin,

§

impl UnwindSafe for HtmlRenderOptions

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<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<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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> Options for T
where T: Any + Send + Sync + Default + Hash + Debug,

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> SettingsData for T

Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.