@content boilerplate
This commit is contained in:
parent
3181d58441
commit
84e402023a
@ -28,6 +28,7 @@ pub(crate) enum AtRule {
|
|||||||
Function(String, Box<Function>),
|
Function(String, Box<Function>),
|
||||||
Return(Vec<Token>),
|
Return(Vec<Token>),
|
||||||
Charset,
|
Charset,
|
||||||
|
Content,
|
||||||
Unknown(UnknownAtRule),
|
Unknown(UnknownAtRule),
|
||||||
For(Vec<Stmt>),
|
For(Vec<Stmt>),
|
||||||
}
|
}
|
||||||
@ -213,6 +214,7 @@ impl AtRule {
|
|||||||
scope,
|
scope,
|
||||||
super_selector,
|
super_selector,
|
||||||
)?),
|
)?),
|
||||||
|
AtRuleKind::Content => AtRule::Content,
|
||||||
_ => todo!("encountered unimplemented at rule"),
|
_ => todo!("encountered unimplemented at rule"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -232,6 +234,7 @@ pub enum AtRuleKind {
|
|||||||
/// and variables from other stylesheets
|
/// and variables from other stylesheets
|
||||||
Import,
|
Import,
|
||||||
Mixin,
|
Mixin,
|
||||||
|
Content,
|
||||||
Include,
|
Include,
|
||||||
/// Defines custom functions that can be used in SassScript
|
/// Defines custom functions that can be used in SassScript
|
||||||
/// expressions
|
/// expressions
|
||||||
@ -335,6 +338,7 @@ impl From<&str> for AtRuleKind {
|
|||||||
"viewport" => Self::Viewport,
|
"viewport" => Self::Viewport,
|
||||||
"document" => Self::Document,
|
"document" => Self::Document,
|
||||||
"counterstyle" => Self::CounterStyle,
|
"counterstyle" => Self::CounterStyle,
|
||||||
|
"content" => Self::Content,
|
||||||
s => Self::Unknown(s.to_owned()),
|
s => Self::Unknown(s.to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,6 +380,7 @@ impl Display for AtRuleKind {
|
|||||||
Self::Viewport => write!(f, "@viewport"),
|
Self::Viewport => write!(f, "@viewport"),
|
||||||
Self::Document => write!(f, "@document"),
|
Self::Document => write!(f, "@document"),
|
||||||
Self::CounterStyle => write!(f, "@counterstyle"),
|
Self::CounterStyle => write!(f, "@counterstyle"),
|
||||||
|
Self::Content => write!(f, "@content"),
|
||||||
Self::Unknown(s) => write!(f, "@{}", s),
|
Self::Unknown(s) => write!(f, "@{}", s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,8 @@ impl Function {
|
|||||||
super_selector,
|
super_selector,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => todo!("unimplemented at rule in function body"),
|
AtRule::For(..) => todo!("@for in function"),
|
||||||
|
_ => return Err("This at-rule is not allowed here.".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -502,6 +502,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
return Err("This at-rule is not allowed here.".into())
|
return Err("This at-rule is not allowed here.".into())
|
||||||
}
|
}
|
||||||
AtRule::For(s) => rules.extend(s),
|
AtRule::For(s) => rules.extend(s),
|
||||||
|
AtRule::Content => return Err("@content is only allowed within mixin declarations.".into()),
|
||||||
u @ AtRule::Unknown(..) => rules.push(Stmt::AtRule(u)),
|
u @ AtRule::Unknown(..) => rules.push(Stmt::AtRule(u)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,6 +528,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
||||||
Expr::AtRule(a) => match a {
|
Expr::AtRule(a) => match a {
|
||||||
AtRule::For(s) => stmts.extend(s),
|
AtRule::For(s) => stmts.extend(s),
|
||||||
|
AtRule::Content => return Err("@content is only allowed within mixin declarations.".into()),
|
||||||
r => stmts.push(Stmt::AtRule(r)),
|
r => stmts.push(Stmt::AtRule(r)),
|
||||||
},
|
},
|
||||||
Expr::Styles(s) => stmts.extend(s.into_iter().map(Box::new).map(Stmt::Style)),
|
Expr::Styles(s) => stmts.extend(s.into_iter().map(Box::new).map(Stmt::Style)),
|
||||||
@ -692,6 +694,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
|||||||
AtRule::Warn(a, b) => Ok(Some(Expr::Warn(a, b))),
|
AtRule::Warn(a, b) => Ok(Some(Expr::Warn(a, b))),
|
||||||
AtRule::Error(pos, err) => Err(SassError::new(err, pos)),
|
AtRule::Error(pos, err) => Err(SassError::new(err, pos)),
|
||||||
AtRule::Return(_) => todo!("@return in unexpected location!"),
|
AtRule::Return(_) => todo!("@return in unexpected location!"),
|
||||||
|
AtRule::Content => return Err("@content is only allowed within mixin declarations.".into()),
|
||||||
f @ AtRule::For(..) => Ok(Some(Expr::AtRule(f))),
|
f @ AtRule::For(..) => Ok(Some(Expr::AtRule(f))),
|
||||||
u @ AtRule::Unknown(..) => Ok(Some(Expr::AtRule(u))),
|
u @ AtRule::Unknown(..) => Ok(Some(Expr::AtRule(u))),
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ use std::iter::Peekable;
|
|||||||
use std::vec::IntoIter;
|
use std::vec::IntoIter;
|
||||||
|
|
||||||
use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs};
|
use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs};
|
||||||
|
use crate::atrule::AtRule;
|
||||||
use crate::common::{Scope, Symbol};
|
use crate::common::{Scope, Symbol};
|
||||||
use crate::error::{SassError, SassResult};
|
use crate::error::{SassError, SassResult};
|
||||||
use crate::selector::Selector;
|
use crate::selector::Selector;
|
||||||
@ -95,7 +96,10 @@ impl Mixin {
|
|||||||
let mut stmts = Vec::new();
|
let mut stmts = Vec::new();
|
||||||
while let Some(expr) = eat_expr(&mut self.body, &mut self.scope, super_selector)? {
|
while let Some(expr) = eat_expr(&mut self.body, &mut self.scope, super_selector)? {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::AtRule(a) => stmts.push(Stmt::AtRule(a)),
|
Expr::AtRule(a) => match a {
|
||||||
|
AtRule::Content => todo!("@content in mixin"),
|
||||||
|
_ => stmts.push(Stmt::AtRule(a))
|
||||||
|
},
|
||||||
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
||||||
Expr::Styles(s) => stmts.extend(s.into_iter().map(Box::new).map(Stmt::Style)),
|
Expr::Styles(s) => stmts.extend(s.into_iter().map(Box::new).map(Stmt::Style)),
|
||||||
Expr::Include(s) => stmts.extend(s),
|
Expr::Include(s) => stmts.extend(s),
|
||||||
|
@ -47,7 +47,7 @@ impl Add for Value {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Self::List(..) => todo!(),
|
// Self::List(..) => todo!(),
|
||||||
Self::Color(c) => match dbg!(&other) {
|
Self::Color(c) => match other {
|
||||||
Self::Ident(s, QuoteKind::Double) | Self::Ident(s, QuoteKind::Single) => {
|
Self::Ident(s, QuoteKind::Double) | Self::Ident(s, QuoteKind::Single) => {
|
||||||
Value::Ident(format!("{}{}", c, s), QuoteKind::Double)
|
Value::Ident(format!("{}{}", c, s), QuoteKind::Double)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user