From 03c3b887b178482f4d1e25884044c61e10dd715b Mon Sep 17 00:00:00 2001 From: Bram Dingelstad Date: Sun, 14 Apr 2024 17:21:04 +0200 Subject: [PATCH] feat: added support for links in RichText and Embeds --- src/lib.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 00b92d6..11ec212 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,10 @@ use notion::BlockType; pub fn convert_rich_text(text: ¬ion::RichText) -> String { match text { notion::RichText::Text { - text, annotations, .. + text, + annotations, + href, + .. } => { let mut string = text.content.to_owned(); @@ -25,6 +28,10 @@ pub fn convert_rich_text(text: ¬ion::RichText) -> String { string = format!("`{string}`"); } + if let Some(url) = href { + string = format!("[{string}]({url})"); + } + string } _ => "".to_string(), @@ -214,6 +221,13 @@ pub async fn convert_blocks( } } + BlockType::Embed { embed } => { + let url = &embed.url; + Some(format!( + r#""# + )) + } + BlockType::Column { .. } | BlockType::Table | BlockType::Bookmark { .. } @@ -226,7 +240,6 @@ pub async fn convert_blocks( | BlockType::Template | BlockType::Toggle | BlockType::Breadcrumb - | BlockType::Embed { .. } | BlockType::Equation { .. } | BlockType::LinkPreview { .. } | BlockType::TableRow