From 09f8aa5480d1ec9c204eea7ee658919819e28b58 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Mon, 1 Apr 2024 17:00:17 -0300 Subject: [PATCH] feat: headings support --- src/convert.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/convert.rs b/src/convert.rs index 4842258..8fee437 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -131,6 +131,33 @@ pub fn to_tumblr_npf<'a>(ast: &'a Node<'a, RefCell>) -> Result .for_each(|b| npf.borrow_mut().content.push(b.clone())); */ } + NodeValue::Heading(h) => { + let mut text = content_types::Text::from(utils::extract_text(node)); + + if h.level == 1 { + text.subtype = Some(Subtypes::Heading1); + } else if h.level == 2 { + text.subtype = Some(Subtypes::Heading2); + } else if h.level == 3 { + text.subtype = Some(Subtypes::UnorderedListItem); + let formatting = Formatting { + r#type: FormattingType::Bold, + start: 0, + end: text.text.chars().count() + 1, + url: None, + color: None, + blog: None, + }; + match text.formatting { + Some(ref mut f) => f.push(formatting), + None => text.formatting = Some(vec![formatting]), + }; + } else { + text.subtype = Some(Subtypes::UnorderedListItem); + } + + npf.borrow_mut().content.push(ContentType::Text(text)); + } _ => (), });