summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMathias Fischler <Mafii@users.noreply.github.com>2023-08-07 13:47:29 +0200
committerGitHub <noreply@github.com>2023-08-07 13:47:29 +0200
commit800744ed9d3923eecf3436f2029e77033e8f1b6a (patch)
tree6b7a16c14fa912204305cb248f9df9a024ee350c /crates
parent63935b9513718027b2af2619998a49a2234c57a5 (diff)
Show warning to user if they use double/empty underscores (italic) (#1871)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/eval/mod.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/typst/src/eval/mod.rs b/crates/typst/src/eval/mod.rs
index 770d9fd1..544f04f0 100644
--- a/crates/typst/src/eval/mod.rs
+++ b/crates/typst/src/eval/mod.rs
@@ -600,7 +600,18 @@ impl Eval for ast::Emph {
#[tracing::instrument(name = "Emph::eval", skip_all)]
fn eval(&self, vm: &mut Vm) -> SourceResult<Self::Output> {
- Ok((vm.items.emph)(self.body().eval(vm)?))
+ let body = self.body();
+ if body.exprs().next().is_none() {
+ vm.vt
+ .tracer
+ .warn(warning!(self.span(), "no text within underscores").with_hint(
+ EcoString::from(
+ "using multiple consecutive underscores (e.g. __) has no additional effect",
+ ),
+ ));
+ }
+
+ Ok((vm.items.emph)(body.eval(vm)?))
}
}