summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-23 15:01:34 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-23 15:06:42 +0200
commitff1e4049d168c7526d3e5e65a8a42bef9500bbf7 (patch)
tree6adc44006acf953144c09105a665413d0ebb267b /library/src
parente9a0cf97419b3c7dac0ab74566a921ba255ead37 (diff)
Support show-set for outline and bibliography headings
Diffstat (limited to 'library/src')
-rw-r--r--library/src/meta/bibliography.rs20
-rw-r--r--library/src/meta/outline.rs23
2 files changed, 28 insertions, 15 deletions
diff --git a/library/src/meta/bibliography.rs b/library/src/meta/bibliography.rs
index f35264af..368a7c39 100644
--- a/library/src/meta/bibliography.rs
+++ b/library/src/meta/bibliography.rs
@@ -43,7 +43,7 @@ use crate::text::TextElem;
///
/// Display: Bibliography
/// Category: meta
-#[element(Locatable, Synthesize, Show, LocalName)]
+#[element(Locatable, Synthesize, Show, Finalize, LocalName)]
pub struct BibliographyElem {
/// Path to a Hayagriva `.yml` or BibLaTeX `.bib` file.
#[required]
@@ -66,6 +66,11 @@ pub struct BibliographyElem {
/// language]($func/text.lang) will be used. This is the default.
/// - When set to `{none}`, the bibliography will not have a title.
/// - A custom title can be set by passing content.
+ ///
+ /// The bibliography's heading will not be numbered by default, but you can
+ /// force it to be with a show-set rule:
+ /// `{show bibliography: set heading(numbering: "1.")}`
+ /// ```
#[default(Some(Smart::Auto))]
pub title: Option<Smart<Content>>,
@@ -152,12 +157,7 @@ impl Show for BibliographyElem {
.spanned(self.span())
});
- seq.push(
- HeadingElem::new(title)
- .with_level(NonZeroUsize::ONE)
- .with_numbering(None)
- .pack(),
- );
+ seq.push(HeadingElem::new(title).with_level(NonZeroUsize::ONE).pack());
}
if !vt.introspector.init() {
@@ -199,6 +199,12 @@ impl Show for BibliographyElem {
}
}
+impl Finalize for BibliographyElem {
+ fn finalize(&self, realized: Content, _: StyleChain) -> Content {
+ realized.styled(HeadingElem::set_numbering(None))
+ }
+}
+
impl LocalName for BibliographyElem {
fn local_name(&self, lang: Lang) -> &'static str {
match lang {
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index a5c7a5de..25211164 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -47,7 +47,7 @@ use crate::text::{LinebreakElem, SpaceElem, TextElem};
///
/// Display: Outline
/// Category: meta
-#[element(Show, LocalName)]
+#[element(Show, Finalize, LocalName)]
pub struct OutlineElem {
/// The title of the outline.
///
@@ -55,6 +55,11 @@ pub struct OutlineElem {
/// [text language]($func/text.lang) will be used. This is the default.
/// - When set to `{none}`, the outline will not have a title.
/// - A custom title can be set by passing content.
+ ///
+ /// The outline's heading will not be numbered by default, but you can
+ /// force it to be with a show-set rule:
+ /// `{show outline: set heading(numbering: "1.")}`
+ /// ```
#[default(Some(Smart::Auto))]
pub title: Option<Smart<Content>>,
@@ -141,13 +146,7 @@ impl Show for OutlineElem {
.spanned(self.span())
});
- seq.push(
- HeadingElem::new(title)
- .with_level(NonZeroUsize::ONE)
- .with_numbering(None)
- .with_outlined(false)
- .pack(),
- );
+ seq.push(HeadingElem::new(title).with_level(NonZeroUsize::ONE).pack());
}
let indent = self.indent(styles);
@@ -247,6 +246,14 @@ impl Show for OutlineElem {
}
}
+impl Finalize for OutlineElem {
+ fn finalize(&self, realized: Content, _: StyleChain) -> Content {
+ realized
+ .styled(HeadingElem::set_outlined(false))
+ .styled(HeadingElem::set_numbering(None))
+ }
+}
+
impl LocalName for OutlineElem {
fn local_name(&self, lang: Lang) -> &'static str {
match lang {