Transpose Option and Smart (#4052)

This commit is contained in:
bluebear94 2024-05-06 10:11:38 -04:00 committed by GitHub
parent f120932bcd
commit 102e6717e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 14 deletions

View File

@ -105,8 +105,7 @@ pub struct BibliographyElem {
/// 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>>,
pub title: Smart<Option<Content>>,
/// Whether to include all works from the given bibliography files, even
/// those that weren't cited in the document.
@ -213,11 +212,9 @@ impl Show for Packed<BibliographyElem> {
const INDENT: Em = Em::new(1.5);
let mut seq = vec![];
if let Some(title) = self.title(styles) {
let title = title.unwrap_or_else(|| {
TextElem::packed(Self::local_name_in(styles)).spanned(self.span())
});
if let Some(title) = self.title(styles).unwrap_or_else(|| {
Some(TextElem::packed(Self::local_name_in(styles)).spanned(self.span()))
}) {
seq.push(
HeadingElem::new(title)
.with_level(Smart::Custom(NonZeroUsize::ONE))

View File

@ -73,8 +73,7 @@ pub struct OutlineElem {
/// 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>>,
pub title: Smart<Option<Content>>,
/// The type of element to include in the outline.
///
@ -193,11 +192,9 @@ impl Show for Packed<OutlineElem> {
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
let mut seq = vec![ParbreakElem::new().pack()];
// Build the outline title.
if let Some(title) = self.title(styles) {
let title = title.unwrap_or_else(|| {
TextElem::packed(Self::local_name_in(styles)).spanned(self.span())
});
if let Some(title) = self.title(styles).unwrap_or_else(|| {
Some(TextElem::packed(Self::local_name_in(styles)).spanned(self.span()))
}) {
seq.push(
HeadingElem::new(title)
.with_depth(NonZeroUsize::ONE)