#[non_exhaustive]pub enum Block {
#[non_exhaustive] Text {
content: String,
footnotes: Vec<Footnote>,
},
#[non_exhaustive] Quote {
content: String,
footnotes: Vec<Footnote>,
},
#[non_exhaustive] Title {
content: String,
footnotes: Vec<Footnote>,
level: usize,
},
#[non_exhaustive] Image {
url: PathBuf,
alt: Option<String>,
caption: Option<String>,
footnotes: Vec<Footnote>,
},
#[non_exhaustive] Audio {
url: PathBuf,
fallback: String,
caption: Option<String>,
footnotes: Vec<Footnote>,
},
#[non_exhaustive] Video {
url: PathBuf,
fallback: String,
caption: Option<String>,
footnotes: Vec<Footnote>,
},
#[non_exhaustive] MathML {
element_str: String,
fallback_image: Option<PathBuf>,
caption: Option<String>,
footnotes: Vec<Footnote>,
},
}Expand description
Content Block
The content block is the basic unit of content in a content document. It can be one of the following types: Text, Quote, Title, Image, Audio, Video, MathML.
For each type of block, we can add a footnote to it, where Text, Quote and Title’s footnote will be added to the content and Image, Audio, Video and MathML’s footnote will be added to the caption.
Each block type has its own structure and required fields. We show the structure of each block so that you can manually write css files for Content for a more beautiful interface.
In addition, the footnote index in the body has the following structure:
<a href="#footnote-1" id="ref-1" class="footnote-ref">[1]</a>Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]Text
Text paragraph
This block represents a paragraph of text. The block structure is as follows:
<p class="content-block text-block">
{{ text.content }}
</p>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Quote
Quote paragraph
This block represents a paragraph of quoted text. The block structure is as follows:
<blockquote class="content-block quote-block">
{{ quote.content }}
</blockquote>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Title
Heading
The block structure is as follows:
<h1 class="content-block title-block">
{{ title.content }}
</h1>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Image
Image block
The block structure is as follows:
<figure class="content-block image-block">
<img src="{{ image.url }}" alt="{{ image.alt }}" />
<figcaption>
{{ image.caption }}
</figcaption>
</figure>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Audio
Audio block
The block structure is as follows:
<figure class="content-block audio-block">
<audio src="{{ audio.url }}" controls>
<p>{{ audio.fallback }}</p>
</audio>
<figcaption>
Audio caption text
</figcaption>
</figure>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Video
Video block
The block structure is as follows:
<figure class="content-block video-block">
<video src="{{ video.url }}" controls>
<p>{{ video.fallback }}</p>
</video>
<figcaption>
{{ video.caption }}
</figcaption>
</figure>Fields
This variant is marked as non-exhaustive
#[non_exhaustive]MathML
MathML block
The block structure is as follows:
<figure class="content-block mathml-block">
{{ mathml.element_str as innerHTML }}
<img src="{{ mathml.fallback_image }}" class="mathml-fallback" />
<figcaption>
{{ mathml.caption }}
</figcaption>
</figure>§Notes
- The MathML markup is inserted directly without validation. Users must ensure the MathML is well-formed.
- The fallback image is displayed when the reading system doesn’t support MathML.
Fields
This variant is marked as non-exhaustive
element_str: StringMathML element raw data
This field stores the raw data of the MathML markup, which we do not verify, and the user needs to make sure it is correct.