feat: primitive quoteblock support
This commit is contained in:
@@ -77,6 +77,60 @@ pub fn to_tumblr_npf<'a>(ast: &'a Node<'a, RefCell<Ast>>) -> Result<RefCell<NPF>
|
||||
|
||||
npf.borrow_mut().content.push(ContentType::Text(block));
|
||||
}
|
||||
NodeValue::BlockQuote => {
|
||||
let block_quote = to_tumblr_npf(node);
|
||||
let final_block = RefCell::new(content_types::Text::new());
|
||||
|
||||
block_quote
|
||||
.unwrap()
|
||||
.borrow_mut()
|
||||
.content
|
||||
.iter_mut()
|
||||
.for_each(|b| {
|
||||
if let ContentType::Text(t) = b {
|
||||
let mut fb = final_block.borrow_mut();
|
||||
let text_len = fb.text.chars().count();
|
||||
|
||||
if let Some(formattings) = &t.formatting {
|
||||
for formatting in formattings {
|
||||
match fb.formatting {
|
||||
Some(ref mut v) => v.push(Formatting {
|
||||
start: text_len + formatting.start,
|
||||
end: text_len + formatting.end,
|
||||
..formatting.clone()
|
||||
}),
|
||||
None => {
|
||||
fb.formatting = Some(vec![Formatting {
|
||||
start: text_len + formatting.start,
|
||||
end: text_len + formatting.end,
|
||||
..formatting.clone()
|
||||
}]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fb.text.push_str(&format!("{}\n\n", &t.text));
|
||||
} else {
|
||||
}
|
||||
});
|
||||
|
||||
println!("{node:#?}");
|
||||
println!("{:#?}", final_block.borrow());
|
||||
/*
|
||||
block_quote
|
||||
.unwrap()
|
||||
.borrow_mut()
|
||||
.content
|
||||
.iter_mut()
|
||||
.map(|b| {
|
||||
if let ContentType::Text(ref mut t) = b {
|
||||
t.subtype = Some(Subtypes::Indented);
|
||||
}
|
||||
b
|
||||
})
|
||||
.for_each(|b| npf.borrow_mut().content.push(b.clone()));
|
||||
*/
|
||||
}
|
||||
_ => (),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user