diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
| commit | 551ea99d05166b0be50792f767ddd38b996e32fa (patch) | |
| tree | ec5e86a087e79e8c181c7d4b904216a775227e2d /library/src/layout/list.rs | |
| parent | 46aace78ac4ac1c075b9b1670dbb7372df1a0a82 (diff) | |
Show default values in documentation
Fixes #169
Fixes #1102
Diffstat (limited to 'library/src/layout/list.rs')
| -rw-r--r-- | library/src/layout/list.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs index 75fc7c3a..1e42d51b 100644 --- a/library/src/layout/list.rs +++ b/library/src/layout/list.rs @@ -66,8 +66,6 @@ pub struct ListElem { /// control, you may pass a function that maps the list's nesting depth /// (starting from `{0}`) to a desired marker. /// - /// Default: `•` - /// /// ```example /// #set list(marker: [--]) /// - A more classic list @@ -79,7 +77,7 @@ pub struct ListElem { /// - Items /// - Items /// ``` - #[default(ListMarker::Content(vec![]))] + #[default(ListMarker::Content(vec![TextElem::packed('•')]))] pub marker: ListMarker, /// The indent of each item. @@ -192,11 +190,9 @@ impl ListMarker { /// Resolve the marker for the given depth. fn resolve(&self, vt: &mut Vt, depth: usize) -> SourceResult<Content> { Ok(match self { - Self::Content(list) => list - .get(depth) - .or(list.last()) - .cloned() - .unwrap_or_else(|| TextElem::packed('•')), + Self::Content(list) => { + list.get(depth).or(list.last()).cloned().unwrap_or_default() + } Self::Func(func) => func.call_vt(vt, [Value::Int(depth as i64)])?.display(), }) } @@ -216,7 +212,11 @@ cast_from_value! { cast_to_value! { v: ListMarker => match v { - ListMarker::Content(vec) => vec.into(), + ListMarker::Content(vec) => if vec.len() == 1 { + vec.into_iter().next().unwrap().into() + } else { + vec.into() + }, ListMarker::Func(func) => func.into(), } } |
