diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-26 13:06:37 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-26 13:06:37 +0200 |
| commit | 285c2f617b74e182be69decea46bbd0afdb0f604 (patch) | |
| tree | 41bdb5d19bc80c165df6e55e829051f0812f7c3d /src/library/lang.rs | |
| parent | 63cf36149635156013f0324b660bf4d362beb87f (diff) | |
Cleanse library
- Remove doc-comments for Typst functions from library
- Reduce number of library source files
Diffstat (limited to 'src/library/lang.rs')
| -rw-r--r-- | src/library/lang.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/library/lang.rs b/src/library/lang.rs deleted file mode 100644 index 7a08001a..00000000 --- a/src/library/lang.rs +++ /dev/null @@ -1,44 +0,0 @@ -use super::*; - -/// `lang`: Configure the language. -/// -/// # Positional parameters -/// - Language: of type `string`. Has to be a valid ISO 639-1 code. -/// -/// # Named parameters -/// - Text direction: `dir`, of type `direction`, must be horizontal. -/// -/// # Return value -/// A template that configures language properties. -/// -/// # Relevant types and constants -/// - Type `direction` -/// - `ltr` -/// - `rtl` -pub fn lang(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { - let iso = args.eat::<String>(ctx).map(|s| lang_dir(&s)); - let dir = match args.named::<Spanned<Dir>>(ctx, "dir") { - Some(dir) if dir.v.axis() == SpecAxis::Horizontal => Some(dir.v), - Some(dir) => { - ctx.diag(error!(dir.span, "must be horizontal")); - None - } - None => None, - }; - - Value::template("lang", move |ctx| { - if let Some(dir) = dir.or(iso) { - ctx.state.lang.dir = dir; - } - - ctx.parbreak(); - }) -} - -/// The default direction for the language identified by `iso`. -fn lang_dir(iso: &str) -> Dir { - match iso.to_ascii_lowercase().as_str() { - "ar" | "he" | "fa" | "ur" | "ps" | "yi" => Dir::RTL, - "en" | "fr" | "de" | _ => Dir::LTR, - } -} |
