mirror of
https://github.com/typst/typst
synced 2025-08-21 10:18:35 +08:00
Compare commits
6 Commits
d204a28818
...
df89a0e85b
Author | SHA1 | Date | |
---|---|---|---|
|
df89a0e85b | ||
|
ca8d223fde | ||
|
d42d2ed200 | ||
|
e90c2f74ef | ||
|
300a782451 | ||
|
91cadbf307 |
@ -404,12 +404,14 @@ fn wrap_args_in_math(
|
||||
if trailing_comma {
|
||||
body += SymbolElem::packed(',');
|
||||
}
|
||||
Ok(Value::Content(
|
||||
callee.display().spanned(callee_span)
|
||||
+ LrElem::new(SymbolElem::packed('(') + body + SymbolElem::packed(')'))
|
||||
.pack()
|
||||
.spanned(args.span),
|
||||
))
|
||||
|
||||
let formatted = callee.display().spanned(callee_span)
|
||||
+ LrElem::new(SymbolElem::packed('(') + body + SymbolElem::packed(')'))
|
||||
.pack()
|
||||
.spanned(args.span);
|
||||
|
||||
args.finish()?;
|
||||
Ok(Value::Content(formatted))
|
||||
}
|
||||
|
||||
/// Provide a hint if the callee is a shadowed standard library function.
|
||||
|
@ -86,7 +86,7 @@ fn expr_tooltip(world: &dyn IdeWorld, leaf: &LinkedNode) -> Option<Tooltip> {
|
||||
*count += 1;
|
||||
continue;
|
||||
} else if *count > 1 {
|
||||
write!(pieces.last_mut().unwrap(), " (x{count})").unwrap();
|
||||
write!(pieces.last_mut().unwrap(), " (×{count})").unwrap();
|
||||
}
|
||||
}
|
||||
pieces.push(value.repr());
|
||||
@ -95,7 +95,7 @@ fn expr_tooltip(world: &dyn IdeWorld, leaf: &LinkedNode) -> Option<Tooltip> {
|
||||
|
||||
if let Some((_, count)) = last {
|
||||
if count > 1 {
|
||||
write!(pieces.last_mut().unwrap(), " (x{count})").unwrap();
|
||||
write!(pieces.last_mut().unwrap(), " (×{count})").unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ impl Content {
|
||||
/// Elements produced in `show` rules will not be included in the results.
|
||||
pub fn query(&self, selector: Selector) -> Vec<Content> {
|
||||
let mut results = Vec::new();
|
||||
self.traverse(&mut |element| -> ControlFlow<()> {
|
||||
let _ = self.traverse(&mut |element| -> ControlFlow<()> {
|
||||
if selector.matches(&element, None) {
|
||||
results.push(element);
|
||||
}
|
||||
@ -441,7 +441,7 @@ impl Content {
|
||||
/// Extracts the plain text of this content.
|
||||
pub fn plain_text(&self) -> EcoString {
|
||||
let mut text = EcoString::new();
|
||||
self.traverse(&mut |element| -> ControlFlow<()> {
|
||||
let _ = self.traverse(&mut |element| -> ControlFlow<()> {
|
||||
if let Some(textable) = element.with::<dyn PlainText>() {
|
||||
textable.plain_text(&mut text);
|
||||
}
|
||||
|
@ -348,15 +348,17 @@ pub struct TextElem {
|
||||
/// This can make justification visually more pleasing.
|
||||
///
|
||||
/// ```example
|
||||
/// #set page(width: 220pt)
|
||||
///
|
||||
/// #set par(justify: true)
|
||||
/// This justified text has a hyphen in
|
||||
/// the paragraph's first line. Hanging
|
||||
/// the paragraph's second line. Hanging
|
||||
/// the hyphen slightly into the margin
|
||||
/// results in a clearer paragraph edge.
|
||||
///
|
||||
/// #set text(overhang: false)
|
||||
/// This justified text has a hyphen in
|
||||
/// the paragraph's first line. Hanging
|
||||
/// the paragraph's second line. Hanging
|
||||
/// the hyphen slightly into the margin
|
||||
/// results in a clearer paragraph edge.
|
||||
/// ```
|
||||
|
BIN
tests/ref/math-call-symbol.png
Normal file
BIN
tests/ref/math-call-symbol.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 703 B |
@ -30,7 +30,8 @@ pub struct Test {
|
||||
|
||||
impl Display for Test {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
write!(f, "{} ({})", self.name, self.pos)
|
||||
// underline path
|
||||
write!(f, "{} (\x1B[4m{}\x1B[0m)", self.name, self.pos)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,9 @@ fn main() {
|
||||
fn setup() {
|
||||
// Make all paths relative to the workspace. That's nicer for IDEs when
|
||||
// clicking on paths printed to the terminal.
|
||||
std::env::set_current_dir("..").unwrap();
|
||||
let workspace_dir =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join(std::path::Component::ParentDir);
|
||||
std::env::set_current_dir(workspace_dir).unwrap();
|
||||
|
||||
// Create the storage.
|
||||
for ext in ["render", "html", "pdf", "svg"] {
|
||||
|
@ -221,6 +221,15 @@ $
|
||||
// Hint: 4-6 or if you meant to display this as text, try placing it in quotes: `"ab"`
|
||||
$ 5ab $
|
||||
|
||||
--- math-call-symbol ---
|
||||
$ phi(x) $
|
||||
$ phi(x, y) $
|
||||
$ phi(1,2,,3,) $
|
||||
|
||||
--- math-call-symbol-named-argument ---
|
||||
// Error: 10-18 unexpected argument: alpha
|
||||
$ phi(x, alpha: y) $
|
||||
|
||||
--- issue-3774-math-call-empty-2d-args ---
|
||||
$ mat(;,) $
|
||||
// Add some whitespace/trivia:
|
||||
|
Loading…
x
Reference in New Issue
Block a user