diff options
author | 2022-01-11 08:17:52 -0800 | |
---|---|---|
committer | 2022-01-11 08:17:52 -0800 | |
commit | dcf4654715ae46a07a295a5d0276a1978ef17657 (patch) | |
tree | 2d475d00ff3f9806a790d828b2e765d2af02c6a5 | |
parent | 31a4ddaa5592cdefae80b716b491691030677413 (diff) | |
download | notion-dcf4654715ae46a07a295a5d0276a1978ef17657.tar.gz notion-dcf4654715ae46a07a295a5d0276a1978ef17657.tar.zst notion-dcf4654715ae46a07a295a5d0276a1978ef17657.zip |
Add support for code blocks (#35)
* Add support for code blocks
* Update src/models.rs
Co-authored-by: Jake Swenson <jakeswenson@users.noreply.github.com>
-rw-r--r-- | src/models.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/models.rs b/src/models.rs index 0007cfb..dd886ac 100644 --- a/src/models.rs +++ b/src/models.rs @@ -229,6 +229,12 @@ pub struct ChildPageFields { } #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] +pub struct CodeFields { + pub text: Vec<RichText>, + pub language: String, +} + +#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] #[serde(tag = "type")] #[serde(rename_all = "snake_case")] pub enum Block { @@ -280,6 +286,11 @@ pub enum Block { common: BlockCommon, child_page: ChildPageFields, }, + Code { + #[serde(flatten)] + common: BlockCommon, + code: CodeFields, + }, #[serde(other)] Unsupported, } @@ -296,7 +307,8 @@ impl AsIdentifier<BlockId> for Block { | NumberedListItem { common, .. } | ToDo { common, .. } | Toggle { common, .. } - | ChildPage { common, .. } => &common.id, + | ChildPage { common, .. } + | Code { common, .. } => &common.id, Unsupported {} => { panic!("Trying to reference identifier for unsupported block!") } |