diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-21 17:46:09 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-21 17:50:56 +0100 |
| commit | 5e08028fb36aa766957cba64c5c665edf9b96fb7 (patch) | |
| tree | 912799dad3c1e25b7032f3e3bee009537c6f555b /src/library/base.rs | |
| parent | 898728f260923a91444eb23b522d0abf01a4299b (diff) | |
Syntax functions 🚀
This adds overridable functions that markup desugars into. Specifically:
- \ desugars into linebreak
- Two newlines desugar into parbreak
- * desugars into strong
- _ desugars into emph
- = .. desugars into heading
- `..` desugars into raw
Diffstat (limited to 'src/library/base.rs')
| -rw-r--r-- | src/library/base.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/library/base.rs b/src/library/base.rs index 22adb1f4..fdabdc47 100644 --- a/src/library/base.rs +++ b/src/library/base.rs @@ -3,6 +3,20 @@ use crate::pretty::pretty; use super::*; +/// `type`: Get the name of a value's type. +/// +/// # Positional parameters +/// - Any value. +/// +/// # Return value +/// The name of the value's type as a string. +pub fn type_(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { + match args.require::<Value>(ctx, "value") { + Some(value) => value.type_name().into(), + None => Value::Error, + } +} + /// `repr`: Get the string representation of a value. /// /// # Positional parameters @@ -17,7 +31,7 @@ pub fn repr(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { } } -/// `rgb`: Create an RGB(A) color. +/// `rgb`: Construct an RGB(A) color. /// /// # Positional parameters /// - Red component: of type `float`, between 0.0 and 1.0. @@ -49,17 +63,3 @@ pub fn rgb(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { clamp(a, 255), ))) } - -/// `type`: Find out the name of a value's type. -/// -/// # Positional parameters -/// - Any value. -/// -/// # Return value -/// The name of the value's type as a string. -pub fn type_(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { - match args.require::<Value>(ctx, "value") { - Some(value) => value.type_name().into(), - None => Value::Error, - } -} |
