mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
parser: skip open tags if found after an InlineHtml statement
This commit is contained in:
parent
81af31bf62
commit
fa19d0eb8d
@ -114,6 +114,7 @@ pub fn switch_statement(state: &mut State) -> ParseResult<Statement> {
|
|||||||
let condition = expressions::lowest_precedence(state)?;
|
let condition = expressions::lowest_precedence(state)?;
|
||||||
|
|
||||||
utils::skip_any_of(state, &[TokenKind::Colon, TokenKind::SemiColon])?;
|
utils::skip_any_of(state, &[TokenKind::Colon, TokenKind::SemiColon])?;
|
||||||
|
utils::skip_close_tag(state)?;
|
||||||
|
|
||||||
let mut body = Block::new();
|
let mut body = Block::new();
|
||||||
|
|
||||||
|
@ -149,3 +149,19 @@ pub fn at_least_one_comma_separated<T>(
|
|||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn skip_close_tag(state: &mut State) -> ParseResult<()> {
|
||||||
|
if state.current.kind == TokenKind::CloseTag {
|
||||||
|
state.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn skip_open_tag(state: &mut State) -> ParseResult<()> {
|
||||||
|
if let TokenKind::OpenTag(_) = state.current.kind {
|
||||||
|
state.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -286,6 +286,7 @@ fn statement(state: &mut State) -> ParseResult<Statement> {
|
|||||||
TokenKind::InlineHtml(html) => {
|
TokenKind::InlineHtml(html) => {
|
||||||
let s = Statement::InlineHtml(html.clone());
|
let s = Statement::InlineHtml(html.clone());
|
||||||
state.next();
|
state.next();
|
||||||
|
utils::skip_open_tag(state)?;
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
TokenKind::SingleLineComment(comment) => {
|
TokenKind::SingleLineComment(comment) => {
|
||||||
|
@ -141,6 +141,12 @@ impl State {
|
|||||||
self.update_scope();
|
self.update_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn skip_close_tag(&mut self) {
|
||||||
|
if matches!(self.current.kind, TokenKind::CloseTag) {
|
||||||
|
self.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn skip_comments(&mut self) {
|
pub fn skip_comments(&mut self) {
|
||||||
while matches!(
|
while matches!(
|
||||||
self.current.kind,
|
self.current.kind,
|
||||||
|
Loading…
Reference in New Issue
Block a user