mirror of
https://github.com/typst/typst
synced 2025-05-18 11:05:28 +08:00
Fix figure caption separator synthesis (#3621)
This commit is contained in:
parent
671b67d43f
commit
7f0b7a28c7
@ -437,7 +437,7 @@ impl Outlinable for Packed<FigureElem> {
|
||||
/// caption: [A rectangle],
|
||||
/// )
|
||||
/// ```
|
||||
#[elem(name = "caption", Show)]
|
||||
#[elem(name = "caption", Synthesize, Show)]
|
||||
pub struct FigureCaption {
|
||||
/// 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> {
|
||||
#[typst_macros::time(name = "figure.caption", span = self.span())]
|
||||
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
|
||||
|
7
tests/typ/bugs/3586-figure-caption-separator.typ
Normal file
7
tests/typ/bugs/3586-figure-caption-separator.typ
Normal 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])
|
Loading…
x
Reference in New Issue
Block a user