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