Allow access to numbering for unordered lists
This commit is contained in:
parent
3ca5b23823
commit
d24c7030d8
@ -72,10 +72,6 @@ impl<const L: ListKind> Show for ListNode<L> {
|
||||
|
||||
for item in &self.items {
|
||||
number = item.number.unwrap_or(number);
|
||||
if L == UNORDERED {
|
||||
number = 1;
|
||||
}
|
||||
|
||||
children.push(LayoutNode::default());
|
||||
children.push(label.resolve(ctx, L, number)?.pack());
|
||||
children.push(LayoutNode::default());
|
||||
|
@ -1,4 +1,3 @@
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::ColumnsNode;
|
||||
@ -233,18 +232,24 @@ macro_rules! papers {
|
||||
}
|
||||
|
||||
impl FromStr for Paper {
|
||||
type Err = PaperError;
|
||||
type Err = &'static str;
|
||||
|
||||
fn from_str(name: &str) -> Result<Self, Self::Err> {
|
||||
match name.to_lowercase().as_str() {
|
||||
$($($pats)* => Ok(Self::$var),)*
|
||||
_ => Err(PaperError),
|
||||
_ => Err("invalid paper name"),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
castable! {
|
||||
Paper,
|
||||
Expected: "string",
|
||||
Value::Str(string) => Self::from_str(&string)?,
|
||||
}
|
||||
|
||||
// All paper sizes in mm.
|
||||
//
|
||||
// Resources:
|
||||
@ -399,21 +404,3 @@ papers! {
|
||||
(PRESENTATION_16_9: 297.0, 167.0625, "presentation-16-9")
|
||||
(PRESENTATION_4_3: 280.0, 210.0, "presentation-4-3")
|
||||
}
|
||||
|
||||
castable! {
|
||||
Paper,
|
||||
Expected: "string",
|
||||
Value::Str(string) => Paper::from_str(&string).map_err(|e| e.to_string())?,
|
||||
}
|
||||
|
||||
/// The error when parsing a [`Paper`] from a string fails.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct PaperError;
|
||||
|
||||
impl Display for PaperError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
f.pad("invalid paper name")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for PaperError {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user