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: StringThe 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: boolWhether 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: StringThe 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.
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: u8The 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
impl Clone for HtmlRenderOptions
Source§impl Debug for HtmlRenderOptions
impl Debug for HtmlRenderOptions
Source§impl Default for HtmlRenderOptions
impl Default for HtmlRenderOptions
Source§fn default() -> HtmlRenderOptions
fn default() -> HtmlRenderOptions
Source§impl<'de> Deserialize<'de> for HtmlRenderOptionswhere
HtmlRenderOptions: Default,
impl<'de> Deserialize<'de> for HtmlRenderOptionswhere
HtmlRenderOptions: Default,
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 Eq for HtmlRenderOptions
Source§impl Hash for HtmlRenderOptions
impl Hash for HtmlRenderOptions
Source§impl JsonSchema for HtmlRenderOptions
impl JsonSchema for HtmlRenderOptions
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for HtmlRenderOptions
impl PartialEq for HtmlRenderOptions
impl StructuralPartialEq for HtmlRenderOptions
Auto Trait Implementations§
impl Forget for HtmlRenderOptions
impl Freeze for HtmlRenderOptionswhere
*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 HtmlRenderOptionswhere
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 HtmlRenderOptionswhere
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
impl UnsafeUnpin for HtmlRenderOptionswhere
*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 HtmlRenderOptionswhere
RawVecInner: UnwindSafe,
BTreeMap<Name, DefinitionOverride>: UnwindSafe,
BTreeMap<Name, SetValZST>: UnwindSafe,
BTreeMap<Name, String>: UnwindSafe,
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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