added html generation
All checks were successful
Test the running changes / Test (push) Successful in 40s
All checks were successful
Test the running changes / Test (push) Successful in 40s
This commit is contained in:
55
src/ast.rs
55
src/ast.rs
@@ -1,21 +1,4 @@
|
||||
// Grammar rules:
|
||||
//
|
||||
// Markdown ::= Block Markdown | Block
|
||||
//
|
||||
// Block ::= (Heading | CodeBlock | Quote | Paragraph) "\n\n"
|
||||
// Heading ::= "#{1,6}\s" Inline
|
||||
// CodeBlock ::= "```.*\n" "(.*?\n)*" "```"
|
||||
// Quote ::= ">" Block
|
||||
// Paragraph ::= Inline
|
||||
//
|
||||
// Inline ::= InlineElem Inline | InlineElem
|
||||
// InlineElem ::= Bold | Italic | Code | Link | Text
|
||||
// Bold ::= "\*" Inline "\*"
|
||||
// Italic ::= "_" Inline "_"
|
||||
// Code ::= "`" "[.^`]*" "`"
|
||||
// Link ::= "\[" Inline "\]\(" Href "\)"
|
||||
// Href ::= "[.^\)]*"
|
||||
// Text ::= "[.^`*_\[]*"
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Inline {
|
||||
@@ -36,34 +19,16 @@ impl Href {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub struct Markdown {
|
||||
block: Block,
|
||||
rest: Option<Box<Markdown>>,
|
||||
impl Display for Href {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Block {
|
||||
Heading(HeadingBlock),
|
||||
Code(CodeBlock),
|
||||
Quote(QuoteBlock),
|
||||
Paragraph(ParagraphBlock),
|
||||
Heading { inner: Vec<Inline>, level: u8 },
|
||||
Code { content: String, lang: String },
|
||||
Quote { inner: Box<Block> },
|
||||
Paragraph { inner: Vec<Inline> },
|
||||
}
|
||||
|
||||
pub struct HeadingBlock {
|
||||
level: u8,
|
||||
content: Inline,
|
||||
}
|
||||
|
||||
pub struct CodeBlock {
|
||||
lang: String,
|
||||
content: String,
|
||||
}
|
||||
|
||||
pub struct QuoteBlock {
|
||||
content: Box<Block>,
|
||||
}
|
||||
|
||||
pub struct ParagraphBlock {
|
||||
content: String,
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user