Implement blockquote token
This commit is contained in:
parent
aa41e33ced
commit
260610c4a0
11 changed files with 263 additions and 120 deletions
|
|
@ -2,11 +2,11 @@ use std::collections::HashMap;
|
|||
|
||||
use crate::syntax::content::parser::{
|
||||
Token,
|
||||
context::{Block, Context, Inline},
|
||||
token::{Anchor, Item, List},
|
||||
context::Context,
|
||||
token::{Anchor, Item, List, Quote},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct State {
|
||||
pub context: Context,
|
||||
pub dom_ids: HashMap<String, Vec<String>>,
|
||||
|
|
@ -15,7 +15,7 @@ pub struct State {
|
|||
pub format_tokens: Vec<Token>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Switches {
|
||||
pub bold: bool,
|
||||
pub oblique: bool,
|
||||
|
|
@ -23,10 +23,11 @@ pub struct Switches {
|
|||
pub underline: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Buffers {
|
||||
pub anchor: AnchorBuffer,
|
||||
pub list: ListBuffer,
|
||||
pub quote: QuoteBuffer,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
|
|
@ -43,6 +44,12 @@ pub struct AnchorBuffer {
|
|||
pub destination: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct QuoteBuffer {
|
||||
pub candidate: Quote,
|
||||
pub in_citation: bool,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for AnchorBuffer {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
let display_text = if self.text.is_empty() {
|
||||
|
|
@ -67,37 +74,6 @@ impl std::fmt::Display for AnchorBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
fn default() -> State {
|
||||
State {
|
||||
context: Context {
|
||||
inline: Inline::None,
|
||||
block: Block::None,
|
||||
},
|
||||
dom_ids: HashMap::default(),
|
||||
switches: Switches {
|
||||
bold: false,
|
||||
crossout: false,
|
||||
oblique: false,
|
||||
underline: false,
|
||||
},
|
||||
buffers: Buffers {
|
||||
anchor: AnchorBuffer {
|
||||
candidate: Anchor::default(),
|
||||
text: String::default(),
|
||||
destination: String::default(),
|
||||
},
|
||||
list: ListBuffer {
|
||||
candidate: List::default(),
|
||||
item_candidate: Item::default(),
|
||||
depth: 0,
|
||||
},
|
||||
},
|
||||
format_tokens: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue