mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix Behaviour
of spacing (#3634)
This commit is contained in:
parent
1d027ff6d2
commit
0fef857064
@ -37,6 +37,8 @@ impl Show for Packed<MetadataElem> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Metadata shows as empty content, so this behaviour is unnecessary. It
|
||||
// can be removed once 0.11 has landed.
|
||||
impl Behave for Packed<MetadataElem> {
|
||||
fn behaviour(&self) -> Behaviour {
|
||||
Behaviour::Invisible
|
||||
|
@ -68,7 +68,7 @@ impl Behave for Packed<HElem> {
|
||||
} else if self.weak(StyleChain::default()) {
|
||||
Behaviour::Weak(1)
|
||||
} else {
|
||||
Behaviour::Invisible
|
||||
Behaviour::Ignorant
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ impl Behave for Packed<VElem> {
|
||||
} else if self.weakness(StyleChain::default()) > 0 {
|
||||
Behaviour::Weak(self.weakness(StyleChain::default()))
|
||||
} else {
|
||||
Behaviour::Invisible
|
||||
Behaviour::Ignorant
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,11 @@ pub enum Behaviour {
|
||||
/// An element that destroys adjacent weak elements.
|
||||
Destructive,
|
||||
/// An element that does not interact at all with other elements, having the
|
||||
/// same effect as if it didn't exist, but has a visual representation.
|
||||
/// same effect as if it didn't exist, but has layout extent and/or a visual
|
||||
/// representation.
|
||||
Ignorant,
|
||||
/// An element that does not have a visual representation.
|
||||
/// An element that does not have any layout extent or visual
|
||||
/// representation.
|
||||
Invisible,
|
||||
}
|
||||
|
||||
|
@ -416,6 +416,9 @@ struct ParBuilder<'a>(BehavedBuilder<'a>);
|
||||
impl<'a> ParBuilder<'a> {
|
||||
fn accept(&mut self, content: &'a Content, styles: StyleChain<'a>) -> bool {
|
||||
if content.is::<MetaElem>() {
|
||||
// TODO: This could probably just be `self.0.is_empty()` since no
|
||||
// weak or invisible elements can be at the start of the builder. It
|
||||
// can be removed once 0.11 has landed.
|
||||
if self.0.has_strong_elements(false) {
|
||||
self.0.push(content, styles);
|
||||
return true;
|
||||
|
BIN
tests/ref/bugs/spacing-behaviour.png
Normal file
BIN
tests/ref/bugs/spacing-behaviour.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 638 B |
9
tests/typ/bugs/spacing-behaviour.typ
Normal file
9
tests/typ/bugs/spacing-behaviour.typ
Normal file
@ -0,0 +1,9 @@
|
||||
// Test that metadata after spacing does not force a new paragraph.
|
||||
|
||||
---
|
||||
#{
|
||||
h(1em)
|
||||
counter(heading).update(4)
|
||||
[Hello ]
|
||||
counter(heading).display()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user