Skip to content

Commit

Permalink
implement new parse for text height
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiving authored Oct 16, 2024
1 parent c32dd2c commit e7caef3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/state/src/values/text_height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ use crate::{
};

impl Parse for TextHeightBehavior {
fn parse(value: &str) -> Result<Self, ParseError> {
match value {
"all" => Ok(TextHeightBehavior::All),
"disable-first-ascent" => Ok(TextHeightBehavior::DisableFirstAscent),
"disable-least-ascent" => Ok(TextHeightBehavior::DisableLastDescent),
"disable-all" => Ok(TextHeightBehavior::DisableAll),
_ => Err(ParseError),
}
fn from_parser(parser: &mut Parser) -> Result<Self, ParseError> {
parser.consume_map(|value| {
value.try_as_str().and_then(|value| match value {
"all" => Some(TextHeightBehavior::All),
"disable-first-ascent" => Some(TextHeightBehavior::DisableFirstAscent),
"disable-least-ascent" => Some(TextHeightBehavior::DisableLastDescent),
"disable-all" => Some(TextHeightBehavior::DisableAll),
_ => None,
})
})
}
}

Expand Down

0 comments on commit e7caef3

Please sign in to comment.