summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/meta/bibliography.rs20
-rw-r--r--library/src/meta/outline.rs23
-rw-r--r--tests/ref/meta/bibliography.pngbin167075 -> 118062 bytes
-rw-r--r--tests/typ/meta/bibliography.typ3
4 files changed, 31 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 {
diff --git a/tests/ref/meta/bibliography.png b/tests/ref/meta/bibliography.png
index c5a408af..8e5e18ec 100644
--- a/tests/ref/meta/bibliography.png
+++ b/tests/ref/meta/bibliography.png
Binary files differ
diff --git a/tests/typ/meta/bibliography.typ b/tests/typ/meta/bibliography.typ
index e25c5410..94b44346 100644
--- a/tests/typ/meta/bibliography.typ
+++ b/tests/typ/meta/bibliography.typ
@@ -30,6 +30,9 @@ And quark! @quark
---
#set page(width: 200pt)
+#set heading(numbering: "1.")
+#show bibliography: set heading(numbering: "1.")
+
= Multiple Bibs
Now we have multiple bibliographies containing #cite("glacier-melt", "keshav2007read")
#bibliography(("/works.bib", "/works_too.bib"))