fix(emphasis): continue if text content is empty (#10)
This commit is contained in:
parent
d86597fb25
commit
37853180bb
|
@ -12,13 +12,21 @@ pub(crate) struct Emphasis<'a> {
|
||||||
|
|
||||||
impl<'a> Emphasis<'a> {
|
impl<'a> Emphasis<'a> {
|
||||||
pub fn parse(text: &str, marker: u8) -> Option<(&str, Emphasis)> {
|
pub fn parse(text: &str, marker: u8) -> Option<(&str, Emphasis)> {
|
||||||
debug_assert!(text.len() >= 3);
|
if text.len() < 3 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let bytes = text.as_bytes();
|
let bytes = text.as_bytes();
|
||||||
|
|
||||||
if bytes[1].is_ascii_whitespace() {
|
if bytes[1].is_ascii_whitespace() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in memchr_iter(marker, bytes).skip(1) {
|
for i in memchr_iter(marker, bytes).skip(1) {
|
||||||
if count(&bytes[1..i], b'\n') >= 2 {
|
// contains at least one character
|
||||||
|
if i == 1 {
|
||||||
|
continue;
|
||||||
|
} else if count(&bytes[1..i], b'\n') >= 2 {
|
||||||
break;
|
break;
|
||||||
} else if validate_marker(i, text) {
|
} else if validate_marker(i, text) {
|
||||||
return Some((
|
return Some((
|
||||||
|
|
Loading…
Reference in a new issue