use crate::model::HasInnerContent;
#[cfg(feature = "fmt_json")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug)]
#[cfg_attr(feature = "fmt_json", derive(Serialize, Deserialize))]
pub enum BlockContent {
Comment(String),
FrontMatter(FrontMatter),
Heading(Heading),
ImageBlock(ImageBlock),
MathBlock(MathBlock),
List(List),
DefinitionList(DefinitionList),
Formatted(Formatted),
CodeBlock(CodeBlock),
Paragraph(Paragraph),
Quote(Quote),
Table(Table),
ThematicBreak,
}
pub trait HasBlockContent: Default + HasInnerContent<BlockContent> {
fn from(inner: BlockContent) -> Self {
let mut new_self = Self::default();
new_self.add_content(inner).unwrap();
new_self
}
fn comment(inner: String) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_comment_str(&inner);
new_self
}
fn front_matter(matter: FrontMatter) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_front_matter(matter);
new_self
}
fn heading(inner: Heading) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_heading(inner);
new_self
}
fn image(inner: ImageBlock) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_image(inner);
new_self
}
fn math(inner: MathBlock) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_math(inner);
new_self
}
fn list(inner: List) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_list(inner);
new_self
}
fn definition_list(inner: DefinitionList) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_definition_list(inner);
new_self
}
fn formatted(inner: Formatted) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_formatted(inner);
new_self
}
fn code_block(inner: CodeBlock) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_code_block(inner);
new_self
}
fn paragraph(inner: Paragraph) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_paragraph(inner);
new_self
}
fn block_quote(inner: Quote) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_block_quote(inner);
new_self
}
fn table(inner: Table) -> Self {
let mut new_self = Self::default();
let _ = new_self.add_table(inner);
new_self
}
fn thematic_break() -> Self {
let mut new_self = Self::default();
let _ = new_self.add_thematic_break();
new_self
}
fn add_comment_str(&mut self, inner: &str) -> &mut Self {
self.add_content(BlockContent::Comment(inner.to_string()))
.unwrap();
self
}
fn add_front_matter(&mut self, matter: FrontMatter) -> &mut Self {
self.add_content(BlockContent::FrontMatter(matter)).unwrap();
self
}
fn add_heading(&mut self, inner: Heading) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_image(&mut self, inner: ImageBlock) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_math(&mut self, inner: MathBlock) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_list(&mut self, inner: List) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_definition_list(&mut self, inner: DefinitionList) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_formatted(&mut self, inner: Formatted) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_code_block(&mut self, inner: CodeBlock) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_paragraph(&mut self, inner: Paragraph) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_block_quote(&mut self, inner: Quote) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_table(&mut self, inner: Table) -> &mut Self {
self.add_content(inner.into()).unwrap();
self
}
fn add_thematic_break(&mut self) -> &mut Self {
self.add_content(BlockContent::ThematicBreak).unwrap();
self
}
}
#[doc(hidden)]
pub mod align;
pub use align::{Alignment, HasAlignment};
#[doc(hidden)]
pub mod caption;
pub use caption::{Caption, HasCaption};
#[doc(hidden)]
pub mod code;
pub use code::{CodeBlock, Formatted};
#[doc(hidden)]
pub mod front_matter;
pub use front_matter::FrontMatter;
#[doc(hidden)]
pub mod heading;
pub use heading::{Heading, HeadingLevel};
#[doc(hidden)]
pub mod label;
pub use label::{AutoLabel, HasLabel, Label};
#[doc(hidden)]
pub mod list;
pub use list::{Item, List, ListItem, ListKind};
#[doc(hidden)]
pub mod definition_list;
pub use definition_list::{Definition, DefinitionList, DefinitionPart};
#[doc(hidden)]
pub mod image;
pub use image::ImageBlock;
#[doc(hidden)]
pub mod math;
pub use math::MathBlock;
#[doc(hidden)]
pub mod paragraph;
pub use paragraph::Paragraph;
#[doc(hidden)]
pub mod quote;
pub use quote::Quote;
#[doc(hidden)]
pub mod table;
pub use table::{Cell, Column, Row, Table};