#![doc = include_str!("readme.md")]
pub(crate) mod as_element;
pub(crate) mod elements;
pub(crate) mod link;
pub(crate) mod list;
pub(crate) mod literal;
pub(crate) mod quote;
pub(crate) mod table;
pub use self::{
elements::{code_block::*, delimiter::*, header::*, math::*, styled::*, text::*},
link::*,
list::*,
literal::*,
quote::*,
table::*,
};
use crate::{
command::CommandArguments,
traits::{IntoASTNode, Slugify},
Command, Value,
};
use notedown_error::{MaybeRanged, NoteError, Result};
use num::{Signed, Zero};
use std::{
fmt::{self, Debug, Display, Formatter},
hash::{Hash, Hasher},
ops::RangeInclusive,
};
pub type ASTNode = Literal<ASTKind>;
pub type ASTNodes = Vec<Literal<ASTKind>>;
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum ASTKind {
Statements(ASTNodes),
Paragraph(ASTNodes),
Delimiter(Box<Delimiter>),
Header(Box<Header>),
TableView(TableView),
ListView(ListView),
QuoteNode(Box<QuoteBlock>),
CodeNode(Box<CodeNode>),
MathNode(Box<MathNode>),
LinkNode(SmartLink),
TextSpan(Box<TextSpan>),
StyledSpan(Box<StyleNode>),
Command(Box<Command>),
Value(Box<Value>),
}
impl Default for ASTKind {
fn default() -> Self {
Self::Value(Box::new(Value::Null))
}
}
impl ASTKind {
#[inline]
pub fn statements(children: ASTNodes, range: MaybeRanged) -> ASTNode {
ASTNode { value: Self::Statements(children), range }
}
#[inline]
pub fn paragraph(children: ASTNodes, range: MaybeRanged) -> ASTNode {
ASTNode { value: Self::Paragraph(children), range }
}
#[inline]
pub fn hr(range: MaybeRanged) -> ASTNode {
Delimiter::HorizontalRule.into_node(range)
}
}