#![doc = include_str!("readme.md")]
mod escaped;
mod external;
mod normal;
mod options;
mod traits;
mod xml;
pub use self::xml::{XMLCommand, XMLCommandMarks};
use crate::{
command::{escaped::EscapedCommand, external::ExternalCommand, normal::NormalCommand},
nodes::Literal,
traits::IntoASTNode,
value::*,
ASTKind, ASTNode,
};
use notedown_error::MaybeRanged;
use std::ops::Range;
#[derive(Clone, Eq, PartialEq)]
pub enum Command {
Normal(NormalCommand),
Escaped(EscapedCommand),
XML(XMLCommand),
External(ExternalCommand),
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct CommandArguments {
pub positional: SparseArray,
pub optional: OrderedMap,
pub pattern: LiteralPattern,
}
impl Command {
#[inline]
pub fn is(&self, rhs: impl AsRef<str>) -> bool {
self.command().eq(rhs.as_ref())
}
#[inline]
pub fn command(&self) -> &str {
match self {
Self::Normal(v) => v.cmd.as_str(),
Self::Escaped(v) => v.cmd.as_str(),
Self::XML(v) => v.cmd.as_str(),
Self::External(v) => v.cmd.as_str(),
}
}
}
impl CommandArguments {
pub fn is_empty(&self) -> bool {
self.positional.is_empty() && self.optional.is_empty() && self.pattern.is_empty()
}
}