typst_library/model/
emph.rs

1use crate::foundations::{Content, elem};
2use crate::introspection::{Locatable, Tagged};
3
4/// Emphasizes content by toggling italics.
5///
6/// - If the current [text style]($text.style) is `{"normal"}`, this turns it
7///   into `{"italic"}`.
8/// - If it is already `{"italic"}` or `{"oblique"}`, it turns it back to
9///   `{"normal"}`.
10///
11/// # Example
12/// ```example
13/// This is _emphasized._ \
14/// This is #emph[too.]
15///
16/// #show emph: it => {
17///   text(blue, it.body)
18/// }
19///
20/// This is _emphasized_ differently.
21/// ```
22///
23/// # Syntax
24/// This function also has dedicated syntax: To emphasize content, simply
25/// enclose it in underscores (`_`). Note that this only works at word
26/// boundaries. To emphasize part of a word, you have to use the function.
27#[elem(title = "Emphasis", keywords = ["italic"], Locatable, Tagged)]
28pub struct EmphElem {
29    /// The content to emphasize.
30    #[required]
31    pub body: Content,
32}