From 2d6a79ba32f6c075ea84cc1b6496b91a1e993058 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 1 Apr 2023 19:04:06 +0200 Subject: [PATCH] Don't display empty counters and state Fixes #338. --- library/src/meta/counter.rs | 4 ++++ library/src/meta/state.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/library/src/meta/counter.rs b/library/src/meta/counter.rs index fb656c766..1d8e642d7 100644 --- a/library/src/meta/counter.rs +++ b/library/src/meta/counter.rs @@ -583,6 +583,10 @@ struct DisplayElem { impl Show for DisplayElem { fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult { + if !vt.introspector.init() { + return Ok(Content::empty()); + } + let location = self.0.location().unwrap(); let counter = self.counter(); let numbering = self diff --git a/library/src/meta/state.rs b/library/src/meta/state.rs index 110735946..3e6d65b27 100644 --- a/library/src/meta/state.rs +++ b/library/src/meta/state.rs @@ -393,6 +393,10 @@ struct DisplayElem { impl Show for DisplayElem { fn show(&self, vt: &mut Vt, _: StyleChain) -> SourceResult { + if !vt.introspector.init() { + return Ok(Content::empty()); + } + let location = self.0.location().unwrap(); let value = self.state().at(vt, location)?; Ok(match self.func() {