From 4bdf0fcdb4c121db545963a5b0de19e9bab4cbc0 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Thu, 25 Apr 2024 16:35:21 -0300 Subject: [PATCH] feat(npf): strikethrough conversion --- src/convert/npf.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/convert/npf.rs b/src/convert/npf.rs index 563cc1d..567089a 100644 --- a/src/convert/npf.rs +++ b/src/convert/npf.rs @@ -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>> 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();