Skip to content

Commit

Permalink
Add support for code blocks (#35)
Browse files Browse the repository at this point in the history
* Add support for code blocks

* Update src/models.rs

Co-authored-by: Jake Swenson <jakeswenson@users.noreply.github.com>
  • Loading branch information
nxsy and jakeswenson committed Jan 11, 2022
1 parent 31a4dda commit dcf4654
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/models.rs
Expand Up @@ -228,6 +228,12 @@ pub struct ChildPageFields {
pub title: String,
}

#[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")]
Expand Down Expand Up @@ -280,6 +286,11 @@ pub enum Block {
common: BlockCommon,
child_page: ChildPageFields,
},
Code {
#[serde(flatten)]
common: BlockCommon,
code: CodeFields,
},
#[serde(other)]
Unsupported,
}
Expand All @@ -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!")
}
Expand Down

0 comments on commit dcf4654

Please sign in to comment.