mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Show warning to user if they use double/empty underscores (italic) (#1871)
This commit is contained in:
parent
63935b9513
commit
800744ed9d
@ -600,7 +600,18 @@ impl Eval for ast::Emph {
|
|||||||
|
|
||||||
#[tracing::instrument(name = "Emph::eval", skip_all)]
|
#[tracing::instrument(name = "Emph::eval", skip_all)]
|
||||||
fn eval(&self, vm: &mut Vm) -> SourceResult<Self::Output> {
|
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)?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,22 @@
|
|||||||
// Warning: 1-3 no text within stars
|
// Warning: 1-3 no text within stars
|
||||||
// Hint: 1-3 using multiple consecutive stars (e.g. **) has no additional effect
|
// Hint: 1-3 using multiple consecutive stars (e.g. **) has no additional effect
|
||||||
**
|
**
|
||||||
|
|
||||||
---
|
---
|
||||||
// Warning: 1-3 no text within stars
|
// Warning: 1-3 no text within stars
|
||||||
// Hint: 1-3 using multiple consecutive stars (e.g. **) has no additional effect
|
// Hint: 1-3 using multiple consecutive stars (e.g. **) has no additional effect
|
||||||
// Warning: 11-13 no text within stars
|
// Warning: 11-13 no text within stars
|
||||||
// Hint: 11-13 using multiple consecutive stars (e.g. **) has no additional effect
|
// Hint: 11-13 using multiple consecutive stars (e.g. **) has no additional effect
|
||||||
**not bold**
|
**not bold**
|
||||||
|
|
||||||
|
---
|
||||||
|
// Warning: 1-3 no text within underscores
|
||||||
|
// Hint: 1-3 using multiple consecutive underscores (e.g. __) has no additional effect
|
||||||
|
__
|
||||||
|
|
||||||
|
---
|
||||||
|
// Warning: 1-3 no text within underscores
|
||||||
|
// Hint: 1-3 using multiple consecutive underscores (e.g. __) has no additional effect
|
||||||
|
// Warning: 13-15 no text within underscores
|
||||||
|
// Hint: 13-15 using multiple consecutive underscores (e.g. __) has no additional effect
|
||||||
|
__not italic__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user