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 => {
|
||||
let mut p = Self::try_from(node.children())?.join_content("\n\n");
|
||||
if let BlockValue::Text(ref mut t) = &mut p.content[0] {
|
||||
t.subtype = Some(BlockTextSubtype::Indented);
|
||||
if p.content.len() > 0 {
|
||||
if let BlockValue::Text(ref mut t) = &mut p.content[0] {
|
||||
t.subtype = Some(BlockTextSubtype::Indented);
|
||||
}
|
||||
}
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
@@ -84,9 +84,11 @@ impl Post {
|
||||
})
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
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));
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user