Tobias Schmitz 8356a1a2cb
feat: [WIP] make more things locatable
skip-checks:true
2025-07-01 14:26:43 +02:00

36 lines
736 B
Rust

use typst_syntax::Span;
use crate::foundations::{elem, func, Content, NativeElement};
use crate::introspection::Locatable;
use crate::math::Mathy;
/// A square root.
///
/// ```example
/// $ sqrt(3 - 2 sqrt(2)) = sqrt(2) - 1 $
/// ```
#[func(title = "Square Root")]
pub fn sqrt(
span: Span,
/// The expression to take the square root of.
radicand: Content,
) -> Content {
RootElem::new(radicand).pack().spanned(span)
}
/// A general root.
///
/// ```example
/// $ root(3, x) $
/// ```
#[elem(Mathy, Locatable)]
pub struct RootElem {
/// Which root of the radicand to take.
#[positional]
pub index: Option<Content>,
/// The expression to take the root of.
#[required]
pub radicand: Content,
}