mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
remove extra conditions
This commit is contained in:
parent
f08ae77b7c
commit
b4d9686db5
3 changed files with 13 additions and 27 deletions
|
|
@ -26,27 +26,15 @@ impl Header {
|
||||||
RegexMatchFlags::DEFAULT,
|
RegexMatchFlags::DEFAULT,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Detect header level
|
|
||||||
let level = regex.get(1)?;
|
|
||||||
|
|
||||||
let level = match level.len() {
|
|
||||||
1 => Level::H1,
|
|
||||||
2 => Level::H2,
|
|
||||||
3 => Level::H3,
|
|
||||||
_ => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Detect header value
|
|
||||||
let value = regex.get(2)?.trim();
|
|
||||||
|
|
||||||
if value.is_empty() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Some(Self {
|
Some(Self {
|
||||||
level,
|
level: match regex.get(1)?.len() {
|
||||||
value: value.to_string(),
|
1 => Level::H1,
|
||||||
|
2 => Level::H2,
|
||||||
|
3 => Level::H3,
|
||||||
|
_ => return None,
|
||||||
|
},
|
||||||
|
value: regex.get(2)?.trim().to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@ impl List {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Extract formatted value
|
// Extract formatted value
|
||||||
let value = regex.get(1)?.trim().to_string();
|
Some(Self {
|
||||||
|
value: regex.get(1)?.trim().to_string(),
|
||||||
// Result
|
})
|
||||||
Some(Self { value })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@ impl Quote {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Extract formatted value
|
// Extract formatted value
|
||||||
let value = regex.get(1)?.trim().to_string();
|
Some(Self {
|
||||||
|
value: regex.get(1)?.trim().to_string(),
|
||||||
// Result
|
})
|
||||||
Some(Self { value })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue