Fix figure caption separator synthesis (#3621)

This commit is contained in:
Laurenz 2024-03-11 12:51:38 +01:00 committed by GitHub
parent 671b67d43f
commit 7f0b7a28c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -437,7 +437,7 @@ impl Outlinable for Packed<FigureElem> {
/// caption: [A rectangle], /// caption: [A rectangle],
/// ) /// )
/// ``` /// ```
#[elem(name = "caption", Show)] #[elem(name = "caption", Synthesize, Show)]
pub struct FigureCaption { pub struct FigureCaption {
/// The caption's position in the figure. Either `{top}` or `{bottom}`. /// The caption's position in the figure. Either `{top}` or `{bottom}`.
/// ///
@ -546,6 +546,14 @@ impl FigureCaption {
} }
} }
impl Synthesize for Packed<FigureCaption> {
fn synthesize(&mut self, _: &mut Engine, styles: StyleChain) -> SourceResult<()> {
let elem = self.as_mut();
elem.push_separator(Smart::Custom(elem.get_separator(styles)));
Ok(())
}
}
impl Show for Packed<FigureCaption> { impl Show for Packed<FigureCaption> {
#[typst_macros::time(name = "figure.caption", span = self.span())] #[typst_macros::time(name = "figure.caption", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {

View File

@ -0,0 +1,7 @@
// Test that figure caption separator is synthesized correctly.
// https://github.com/typst/typst/issues/3586
// Ref: false
---
#show figure.caption: c => test(c.separator, [#": "])
#figure(table[], caption: [This is a test caption])