feat(npf): strikethrough conversion

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-04-25 16:35:21 -03:00
parent f5a01fbf1f
commit 4bdf0fcdb4

View File

@@ -21,6 +21,7 @@ use content_blocks::{BlockText, BlockValue};
use text_formatting::{FormatTypeBold, FormatTypeItalic, FormatValue};
use self::content_blocks::BlockImage;
use text_formatting::{FormatTypeLink, FormatTypeStrikeThrough};
#[derive(Debug)]
pub enum NPFConvertError {
@@ -88,6 +89,22 @@ impl<'a> TryFrom<&'a Node<'a, RefCell<Ast>>> for objects::Post {
Ok(())
}
NodeValue::Strikethrough => {
let mut content = Self::try_from(n)?
.fold_content()
.for_each_content(|c| {
if let BlockValue::Text(ref mut t) = c {
let format = FormatValue::StrikeThrough(
FormatTypeStrikeThrough::from(&t.text),
);
t.push_formatting(format);
t.text = String::from(t.text.trim());
}
})
.content;
post.content.append(&mut content);
Ok(())
}
_ => Ok(()),
})
.collect();