Compare commits

..

6 Commits

8 changed files with 30 additions and 14 deletions

View File

@ -404,12 +404,14 @@ fn wrap_args_in_math(
if trailing_comma { if trailing_comma {
body += SymbolElem::packed(','); body += SymbolElem::packed(',');
} }
Ok(Value::Content(
callee.display().spanned(callee_span) let formatted = callee.display().spanned(callee_span)
+ LrElem::new(SymbolElem::packed('(') + body + SymbolElem::packed(')')) + LrElem::new(SymbolElem::packed('(') + body + SymbolElem::packed(')'))
.pack() .pack()
.spanned(args.span), .spanned(args.span);
))
args.finish()?;
Ok(Value::Content(formatted))
} }
/// Provide a hint if the callee is a shadowed standard library function. /// Provide a hint if the callee is a shadowed standard library function.

View File

@ -86,7 +86,7 @@ fn expr_tooltip(world: &dyn IdeWorld, leaf: &LinkedNode) -> Option<Tooltip> {
*count += 1; *count += 1;
continue; continue;
} else if *count > 1 { } else if *count > 1 {
write!(pieces.last_mut().unwrap(), " (x{count})").unwrap(); write!(pieces.last_mut().unwrap(), " (×{count})").unwrap();
} }
} }
pieces.push(value.repr()); pieces.push(value.repr());
@ -95,7 +95,7 @@ fn expr_tooltip(world: &dyn IdeWorld, leaf: &LinkedNode) -> Option<Tooltip> {
if let Some((_, count)) = last { if let Some((_, count)) = last {
if count > 1 { if count > 1 {
write!(pieces.last_mut().unwrap(), " (x{count})").unwrap(); write!(pieces.last_mut().unwrap(), " (×{count})").unwrap();
} }
} }

View File

@ -414,7 +414,7 @@ impl Content {
/// Elements produced in `show` rules will not be included in the results. /// Elements produced in `show` rules will not be included in the results.
pub fn query(&self, selector: Selector) -> Vec<Content> { pub fn query(&self, selector: Selector) -> Vec<Content> {
let mut results = Vec::new(); let mut results = Vec::new();
self.traverse(&mut |element| -> ControlFlow<()> { let _ = self.traverse(&mut |element| -> ControlFlow<()> {
if selector.matches(&element, None) { if selector.matches(&element, None) {
results.push(element); results.push(element);
} }
@ -441,7 +441,7 @@ impl Content {
/// Extracts the plain text of this content. /// Extracts the plain text of this content.
pub fn plain_text(&self) -> EcoString { pub fn plain_text(&self) -> EcoString {
let mut text = EcoString::new(); let mut text = EcoString::new();
self.traverse(&mut |element| -> ControlFlow<()> { let _ = self.traverse(&mut |element| -> ControlFlow<()> {
if let Some(textable) = element.with::<dyn PlainText>() { if let Some(textable) = element.with::<dyn PlainText>() {
textable.plain_text(&mut text); textable.plain_text(&mut text);
} }

View File

@ -348,15 +348,17 @@ pub struct TextElem {
/// This can make justification visually more pleasing. /// This can make justification visually more pleasing.
/// ///
/// ```example /// ```example
/// #set page(width: 220pt)
///
/// #set par(justify: true) /// #set par(justify: true)
/// This justified text has a hyphen in /// 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 /// the hyphen slightly into the margin
/// results in a clearer paragraph edge. /// results in a clearer paragraph edge.
/// ///
/// #set text(overhang: false) /// #set text(overhang: false)
/// This justified text has a hyphen in /// 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 /// the hyphen slightly into the margin
/// results in a clearer paragraph edge. /// results in a clearer paragraph edge.
/// ``` /// ```

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

View File

@ -30,7 +30,8 @@ pub struct Test {
impl Display for Test { impl Display for Test {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { 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)
} }
} }

View File

@ -59,7 +59,9 @@ fn main() {
fn setup() { fn setup() {
// Make all paths relative to the workspace. That's nicer for IDEs when // Make all paths relative to the workspace. That's nicer for IDEs when
// clicking on paths printed to the terminal. // 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. // Create the storage.
for ext in ["render", "html", "pdf", "svg"] { for ext in ["render", "html", "pdf", "svg"] {

View File

@ -221,6 +221,15 @@ $
// Hint: 4-6 or if you meant to display this as text, try placing it in quotes: `"ab"` // Hint: 4-6 or if you meant to display this as text, try placing it in quotes: `"ab"`
$ 5ab $ $ 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 --- --- issue-3774-math-call-empty-2d-args ---
$ mat(;,) $ $ mat(;,) $
// Add some whitespace/trivia: // Add some whitespace/trivia: