Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for code blocks #35

Merged
merged 2 commits into from Jan 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions 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,
jakeswenson marked this conversation as resolved.
Show resolved Hide resolved
}

#[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 @@ -297,6 +308,7 @@ impl AsIdentifier<BlockId> for Block {
| ToDo { common, .. }
| Toggle { common, .. }
| ChildPage { common, .. } => &common.id,
| Code { common, .. } => &common.id,
jakeswenson marked this conversation as resolved.
Show resolved Hide resolved
jakeswenson marked this conversation as resolved.
Show resolved Hide resolved
Unsupported {} => {
panic!("Trying to reference identifier for unsupported block!")
}
Expand Down