Implement escaping
This commit is contained in:
parent
0d910634c6
commit
c6b43b2c48
4 changed files with 18 additions and 2 deletions
|
|
@ -31,6 +31,13 @@ fn lex(text: &str, map: LexMap, config: &Config) -> Vec<Token> {
|
|||
|
||||
let mut iterator = lexemes.iter().peekable();
|
||||
while let Some(lexeme) = iterator.next() {
|
||||
if lexeme.match_as_char('\\') {
|
||||
if let Some(next) = iterator.next() {
|
||||
tokens.push(Token::Literal(Literal::lex(next)));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if context::block::parse(
|
||||
lexeme,
|
||||
&mut state,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
Inline, context,
|
||||
lexeme::Lexeme,
|
||||
state::{AnchorBuffer, State},
|
||||
token::{Token, anchor::Anchor, code::Code},
|
||||
token::{Token, anchor::Anchor, code::Code, literal::Literal},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -48,6 +48,9 @@ pub fn parse(
|
|||
state.context.inline = Inline::None;
|
||||
tokens.push(Token::Code(Code::new(false)));
|
||||
return true;
|
||||
} else {
|
||||
tokens.push(Token::Literal(Literal::lex(lexeme)));
|
||||
return true;
|
||||
}
|
||||
},
|
||||
Inline::Anchor => {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ pub fn parse(
|
|||
tokens: &mut Vec<Token>,
|
||||
iterator: &mut Peekable<Iter<'_, Lexeme>>,
|
||||
) -> bool {
|
||||
if let super::context::Block::PreFormat = state.context.block {
|
||||
return false;
|
||||
} else if let super::context::Inline::Code = state.context.inline {
|
||||
return false;
|
||||
}
|
||||
|
||||
if Underline::probe(lexeme) {
|
||||
log!("Underline probed: {lexeme}");
|
||||
tokens
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub mod delimiter {
|
|||
impl Default for Delimiters {
|
||||
fn default() -> Self {
|
||||
Delimiters {
|
||||
atomic: vec!['`', '|'],
|
||||
atomic: vec!['`', '|', '\\'],
|
||||
double: vec!['_', '~'],
|
||||
flanking: vec!['_', '*', '~', '(', ')', '\'', '"'],
|
||||
punctuation: vec![',', '.', ';', ':', '?', '!'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue