summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-01 13:15:10 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-01 13:15:10 +0200
commitaafd3c95cacd829b647cfab1533de5d4833b9a04 (patch)
tree3a16ea942eb71dcda46dd9a3112fa83db0729a7b /src/library
parent885bfec5d7524845b41e180fadc9cf5626157eec (diff)
Rename table to dict ✏
Diffstat (limited to 'src/library')
-rw-r--r--src/library/align.rs2
-rw-r--r--src/library/boxed.rs2
-rw-r--r--src/library/color.rs2
-rw-r--r--src/library/font.rs19
-rw-r--r--src/library/page.rs4
-rw-r--r--src/library/spacing.rs6
6 files changed, 20 insertions, 15 deletions
diff --git a/src/library/align.rs b/src/library/align.rs
index 55e0f65e..55259fd5 100644
--- a/src/library/align.rs
+++ b/src/library/align.rs
@@ -14,7 +14,7 @@ use super::*;
/// - `vertical`: Any of `top`, `bottom` or `center`.
///
/// There may not be two alignment specifications for the same axis.
-pub async fn align(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass<Value> {
+pub async fn align(_: Span, mut args: DictValue, ctx: LayoutContext<'_>) -> Pass<Value> {
let mut f = Feedback::new();
let content = args.take::<SyntaxTree>();
diff --git a/src/library/boxed.rs b/src/library/boxed.rs
index 5d98760f..672e77d1 100644
--- a/src/library/boxed.rs
+++ b/src/library/boxed.rs
@@ -8,7 +8,7 @@ use crate::length::ScaleLength;
/// - `height`: The height of the box (length of relative to parent's height).
pub async fn boxed(
_: Span,
- mut args: TableValue,
+ mut args: DictValue,
mut ctx: LayoutContext<'_>,
) -> Pass<Value> {
let mut f = Feedback::new();
diff --git a/src/library/color.rs b/src/library/color.rs
index 0d7e8535..43d9253f 100644
--- a/src/library/color.rs
+++ b/src/library/color.rs
@@ -2,7 +2,7 @@ use super::*;
use crate::color::RgbaColor;
/// `rgb`: Create an RGB(A) color.
-pub async fn rgb(span: Span, mut args: TableValue, _: LayoutContext<'_>) -> Pass<Value> {
+pub async fn rgb(span: Span, mut args: DictValue, _: LayoutContext<'_>) -> Pass<Value> {
let mut f = Feedback::new();
let r = args.expect::<Spanned<f64>>("red value", span, &mut f);
diff --git a/src/library/font.rs b/src/library/font.rs
index ed9360e0..e9f6f9b4 100644
--- a/src/library/font.rs
+++ b/src/library/font.rs
@@ -12,13 +12,18 @@ use crate::length::ScaleLength;
/// # Keyword arguments
/// - `style`: `normal`, `italic` or `oblique`.
/// - `weight`: `100` - `900` or a name like `thin`.
-/// - `width`: `normal`, `condensed`, `expanded`, ...
-/// - Any other keyword argument whose value is a table of strings is a class
-/// fallback definition like:
+/// - `width`: `1` - `9` or a name like `condensed`.
+/// - Any other keyword argument whose value is a dictionary of strings defines
+/// a fallback class, for example:
/// ```typst
-/// serif = ("Source Serif Pro", "Noto Serif")
+/// [font: serif = ("Source Serif Pro", "Noto Serif")]
/// ```
-pub async fn font(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass<Value> {
+/// This class can be used in the fallback list or other fallback classes as
+/// long as the resulting fallback tree is acylic.
+/// ```typst
+/// [font: "My Serif", serif]
+/// ```
+pub async fn font(_: Span, mut args: DictValue, ctx: LayoutContext<'_>) -> Pass<Value> {
let mut f = Feedback::new();
let mut text = ctx.style.text.clone();
let mut updated_fallback = false;
@@ -57,8 +62,8 @@ pub async fn font(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass
text.variant.stretch = stretch;
}
- for (class, mut table) in args.take_all_str::<TableValue>() {
- let fallback = table
+ for (class, mut dict) in args.take_all_str::<DictValue>() {
+ let fallback = dict
.take_all_num_vals::<StringLike>()
.map(|s| s.to_lowercase())
.collect();
diff --git a/src/library/page.rs b/src/library/page.rs
index ee551064..b4f74e48 100644
--- a/src/library/page.rs
+++ b/src/library/page.rs
@@ -16,7 +16,7 @@ use crate::paper::{Paper, PaperClass};
/// - `top`: The top margin (length or relative to height).
/// - `bottom`: The bottom margin (length or relative to height).
/// - `flip`: Flips custom or paper-defined width and height (boolean).
-pub async fn page(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass<Value> {
+pub async fn page(_: Span, mut args: DictValue, ctx: LayoutContext<'_>) -> Pass<Value> {
let mut f = Feedback::new();
let mut style = ctx.style.page;
@@ -64,7 +64,7 @@ pub async fn page(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass
}
/// `pagebreak`: Ends the current page.
-pub async fn pagebreak(_: Span, args: TableValue, _: LayoutContext<'_>) -> Pass<Value> {
+pub async fn pagebreak(_: Span, args: DictValue, _: LayoutContext<'_>) -> Pass<Value> {
let mut f = Feedback::new();
args.unexpected(&mut f);
Pass::commands(vec![BreakPage], f)
diff --git a/src/library/spacing.rs b/src/library/spacing.rs
index 8b2f1622..aa2712d3 100644
--- a/src/library/spacing.rs
+++ b/src/library/spacing.rs
@@ -6,7 +6,7 @@ use crate::length::ScaleLength;
///
/// # Positional arguments
/// - The spacing (length or relative to font size).
-pub async fn h(name: Span, args: TableValue, ctx: LayoutContext<'_>) -> Pass<Value> {
+pub async fn h(name: Span, args: DictValue, ctx: LayoutContext<'_>) -> Pass<Value> {
spacing(name, args, ctx, Horizontal)
}
@@ -14,13 +14,13 @@ pub async fn h(name: Span, args: TableValue, ctx: LayoutContext<'_>) -> Pass<Val
///
/// # Positional arguments
/// - The spacing (length or relative to font size).
-pub async fn v(name: Span, args: TableValue, ctx: LayoutContext<'_>) -> Pass<Value> {
+pub async fn v(name: Span, args: DictValue, ctx: LayoutContext<'_>) -> Pass<Value> {
spacing(name, args, ctx, Vertical)
}
fn spacing(
name: Span,
- mut args: TableValue,
+ mut args: DictValue,
ctx: LayoutContext<'_>,
axis: SpecAxis,
) -> Pass<Value> {