Skip to content

Commit adafaa1

Browse files
authored
Merge pull request #644 from kivikakk/push-uqpuzrsoptql
clean up a little more.
2 parents a8698d5 + d9d0f81 commit adafaa1

File tree

9 files changed

+1469
-1470
lines changed

9 files changed

+1469
-1470
lines changed

fuzz/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.rs

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ use std::cell::RefCell;
55
use std::convert::TryFrom;
66

77
use crate::arena_tree;
8-
pub use crate::parser::alert::{AlertType, NodeAlert};
9-
pub use crate::parser::math::NodeMath;
10-
pub use crate::parser::multiline_block_quote::NodeMultilineBlockQuote;
118
#[cfg(feature = "shortcodes")]
129
pub use crate::parser::shortcodes::NodeShortCode;
1310

@@ -449,6 +446,96 @@ pub struct NodeFootnoteReference {
449446
pub ix: u32,
450447
}
451448

449+
/// The metadata of a multiline blockquote.
450+
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
451+
pub struct NodeMultilineBlockQuote {
452+
/// The length of the fence.
453+
pub fence_length: usize,
454+
455+
/// The indentation level of the fence marker.
456+
pub fence_offset: usize,
457+
}
458+
459+
/// An inline math span
460+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
461+
pub struct NodeMath {
462+
/// Whether this is dollar math (`$` or `$$`).
463+
/// `false` indicates it is code math
464+
pub dollar_math: bool,
465+
466+
/// Whether this is display math (using `$$`)
467+
pub display_math: bool,
468+
469+
/// The literal contents of the math span.
470+
/// As the contents are not interpreted as Markdown at all,
471+
/// they are contained within this structure,
472+
/// rather than inserted into a child inline of any kind.
473+
pub literal: String,
474+
}
475+
476+
/// The metadata of an Alert node.
477+
#[derive(Debug, Clone, PartialEq, Eq)]
478+
pub struct NodeAlert {
479+
/// Type of alert
480+
pub alert_type: AlertType,
481+
482+
/// Overridden title. If `None`, then use the default title.
483+
pub title: Option<String>,
484+
485+
/// Originated from a multiline blockquote.
486+
pub multiline: bool,
487+
488+
/// The length of the fence (multiline only).
489+
pub fence_length: usize,
490+
491+
/// The indentation level of the fence marker (multiline only)
492+
pub fence_offset: usize,
493+
}
494+
495+
/// The type of alert.
496+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
497+
pub enum AlertType {
498+
/// Useful information that users should know, even when skimming content
499+
#[default]
500+
Note,
501+
502+
/// Helpful advice for doing things better or more easily
503+
Tip,
504+
505+
/// Key information users need to know to achieve their goal
506+
Important,
507+
508+
/// Urgent info that needs immediate user attention to avoid problems
509+
Warning,
510+
511+
/// Advises about risks or negative outcomes of certain actions
512+
Caution,
513+
}
514+
515+
impl AlertType {
516+
/// Returns the default title for an alert type
517+
pub fn default_title(&self) -> String {
518+
match *self {
519+
AlertType::Note => String::from("Note"),
520+
AlertType::Tip => String::from("Tip"),
521+
AlertType::Important => String::from("Important"),
522+
AlertType::Warning => String::from("Warning"),
523+
AlertType::Caution => String::from("Caution"),
524+
}
525+
}
526+
527+
/// Returns the CSS class to use for an alert type
528+
pub fn css_class(&self) -> String {
529+
match *self {
530+
AlertType::Note => String::from("markdown-alert-note"),
531+
AlertType::Tip => String::from("markdown-alert-tip"),
532+
AlertType::Important => String::from("markdown-alert-important"),
533+
AlertType::Warning => String::from("markdown-alert-warning"),
534+
AlertType::Caution => String::from("markdown-alert-caution"),
535+
}
536+
}
537+
}
538+
452539
impl NodeValue {
453540
/// Indicates whether this node is a block node or inline node.
454541
pub fn block(&self) -> bool {

src/parser/alert.rs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)