From dcf4654715ae46a07a295a5d0276a1978ef17657 Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Tue, 11 Jan 2022 08:17:52 -0800 Subject: Add support for code blocks (#35) * Add support for code blocks * Update src/models.rs Co-authored-by: Jake Swenson --- src/models.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/models.rs b/src/models.rs index 0007cfb..dd886ac 100644 --- a/src/models.rs +++ b/src/models.rs @@ -228,6 +228,12 @@ pub struct ChildPageFields { pub title: String, } +#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] +pub struct CodeFields { + pub text: Vec, + pub language: String, +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] #[serde(tag = "type")] #[serde(rename_all = "snake_case")] @@ -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 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!") } -- cgit v1.2.3