fix(npf): check if vectors has element before accessing them
This commit is contained in:
@@ -78,8 +78,10 @@ impl<'a> TryFrom<&'a Node<'a, RefCell<Ast>>> for objects::Post {
|
|||||||
}
|
}
|
||||||
NodeValue::BlockQuote => {
|
NodeValue::BlockQuote => {
|
||||||
let mut p = Self::try_from(node.children())?.join_content("\n\n");
|
let mut p = Self::try_from(node.children())?.join_content("\n\n");
|
||||||
if let BlockValue::Text(ref mut t) = &mut p.content[0] {
|
if p.content.len() > 0 {
|
||||||
t.subtype = Some(BlockTextSubtype::Indented);
|
if let BlockValue::Text(ref mut t) = &mut p.content[0] {
|
||||||
|
t.subtype = Some(BlockTextSubtype::Indented);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(p)
|
Ok(p)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,9 +84,11 @@ impl Post {
|
|||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let block = &mut self.content[0];
|
if self.content.len() > 0 {
|
||||||
if let BlockValue::Text(ref mut t) = block {
|
let block = &mut self.content[0];
|
||||||
t.text = String::from(t.text.strip_suffix(sep).unwrap_or(&t.text));
|
if let BlockValue::Text(ref mut t) = block {
|
||||||
|
t.text = String::from(t.text.strip_suffix(sep).unwrap_or(&t.text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user