#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum HeadingStyle {
#[default]
Atx,
Setext,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum CodeBlockStyle {
#[default]
Fenced,
Indented,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum Fence {
#[default]
Backtick,
Tilde,
}
impl Fence {
#[must_use]
#[inline]
pub const fn char(self) -> char {
match self {
Self::Backtick => '`',
Self::Tilde => '~',
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum BulletMarker {
#[default]
Dash,
Plus,
Asterisk,
}
impl BulletMarker {
#[must_use]
#[inline]
pub const fn char(self) -> char {
match self {
Self::Dash => '-',
Self::Plus => '+',
Self::Asterisk => '*',
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum EmDelimiter {
#[default]
Asterisk,
Underscore,
}
impl EmDelimiter {
#[must_use]
#[inline]
pub const fn char(self) -> char {
match self {
Self::Asterisk => '*',
Self::Underscore => '_',
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum StrongDelimiter {
#[default]
Asterisks,
Underscores,
}
impl StrongDelimiter {
#[must_use]
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::Asterisks => "**",
Self::Underscores => "__",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum HorizontalRule {
#[default]
Dashes,
Asterisks,
Underscores,
}
impl HorizontalRule {
#[must_use]
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::Dashes => "---",
Self::Asterisks => "***",
Self::Underscores => "___",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum EscapeMode {
#[default]
Basic,
Disabled,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum LinkStyle {
#[default]
Inlined,
Referenced,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum LinkReferenceStyle {
#[default]
Full,
Collapsed,
Shortcut,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct Options {
heading_style: HeadingStyle,
bullet_marker: BulletMarker,
code_block_style: CodeBlockStyle,
fence: Fence,
em_delimiter: EmDelimiter,
strong_delimiter: StrongDelimiter,
horizontal_rule: HorizontalRule,
escape_mode: EscapeMode,
link_style: LinkStyle,
link_reference_style: LinkReferenceStyle,
}
impl Options {
#[inline]
#[must_use]
pub const fn heading_style(&self) -> HeadingStyle {
self.heading_style
}
#[inline]
#[must_use]
pub const fn bullet_marker(&self) -> BulletMarker {
self.bullet_marker
}
#[inline]
#[must_use]
pub const fn code_block_style(&self) -> CodeBlockStyle {
self.code_block_style
}
#[inline]
#[must_use]
pub const fn fence(&self) -> Fence {
self.fence
}
#[inline]
#[must_use]
pub const fn em_delimiter(&self) -> EmDelimiter {
self.em_delimiter
}
#[inline]
#[must_use]
pub const fn strong_delimiter(&self) -> StrongDelimiter {
self.strong_delimiter
}
#[inline]
#[must_use]
pub const fn horizontal_rule(&self) -> HorizontalRule {
self.horizontal_rule
}
#[inline]
#[must_use]
pub const fn escape_mode(&self) -> EscapeMode {
self.escape_mode
}
#[inline]
#[must_use]
pub const fn link_style(&self) -> LinkStyle {
self.link_style
}
#[inline]
#[must_use]
pub const fn link_reference_style(&self) -> LinkReferenceStyle {
self.link_reference_style
}
#[must_use]
pub const fn with_heading_style(mut self, style: HeadingStyle) -> Self {
self.heading_style = style;
self
}
#[must_use]
pub const fn with_bullet_marker(mut self, marker: BulletMarker) -> Self {
self.bullet_marker = marker;
self
}
#[must_use]
pub const fn with_code_block_style(mut self, style: CodeBlockStyle) -> Self {
self.code_block_style = style;
self
}
#[must_use]
pub const fn with_fence(mut self, fence: Fence) -> Self {
self.fence = fence;
self
}
#[must_use]
pub const fn with_em_delimiter(mut self, delim: EmDelimiter) -> Self {
self.em_delimiter = delim;
self
}
#[must_use]
pub const fn with_strong_delimiter(mut self, delim: StrongDelimiter) -> Self {
self.strong_delimiter = delim;
self
}
#[must_use]
pub const fn with_horizontal_rule(mut self, rule: HorizontalRule) -> Self {
self.horizontal_rule = rule;
self
}
#[must_use]
pub const fn with_escape_mode(mut self, mode: EscapeMode) -> Self {
self.escape_mode = mode;
self
}
#[must_use]
pub const fn with_link_style(mut self, style: LinkStyle) -> Self {
self.link_style = style;
self
}
#[must_use]
pub const fn with_link_reference_style(mut self, style: LinkReferenceStyle) -> Self {
self.link_reference_style = style;
self
}
}