Skip to content

Commit

Permalink
Make some changes that were deferred until after 0.11 (#3934)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurmaedje committed Apr 15, 2024
1 parent f258746 commit 401ba82
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion crates/typst/src/foundations/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ impl Selector {
pub fn matches(&self, target: &Content, styles: Option<StyleChain>) -> bool {
match self {
Self::Elem(element, dict) => {
// TODO: Optimize field access to not clone.
target.func() == *element
&& dict.iter().flat_map(|dict| dict.iter()).all(|(id, value)| {
target.get(*id, styles).as_ref() == Some(value)
Expand Down
11 changes: 1 addition & 10 deletions crates/typst/src/introspection/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::diag::SourceResult;
use crate::engine::Engine;
use crate::foundations::{elem, Content, Packed, Show, StyleChain, Value};
use crate::introspection::Locatable;
use crate::realize::{Behave, Behaviour};

/// Exposes a value to the query system without producing visible content.
///
Expand All @@ -24,7 +23,7 @@ use crate::realize::{Behave, Behaviour};
/// query(<note>).first().value
/// }
/// ```
#[elem(Behave, Show, Locatable)]
#[elem(Show, Locatable)]
pub struct MetadataElem {
/// The value to embed into the document.
#[required]
Expand All @@ -36,11 +35,3 @@ impl Show for Packed<MetadataElem> {
Ok(Content::empty())
}
}

// 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
}
}
5 changes: 1 addition & 4 deletions crates/typst/src/realize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,7 @@ 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) {
if !self.0.is_empty() {
self.0.push(content, styles);
return true;
}
Expand Down
1 change: 0 additions & 1 deletion tests/suite/layout/container.typ
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ There

--- block-spacing-table ---
// Test that paragraph spacing loses against block spacing.
// TODO
#set block(spacing: 100pt)
#show table: set block(above: 5pt, below: 5pt)
Hello
Expand Down

0 comments on commit 401ba82

Please sign in to comment.