consume utf8 bom in parser, not lexer
This commit is contained in:
parent
c19eda6f89
commit
5bf03c15d6
@ -40,12 +40,7 @@ impl<'a> Iterator for Lexer<'a> {
|
||||
impl<'a> Lexer<'a> {
|
||||
pub fn new(file: &'a Arc<File>) -> Lexer<'a> {
|
||||
Lexer {
|
||||
buf: file
|
||||
.source()
|
||||
.trim_start_matches("\u{ef}\u{bb}\u{bf}")
|
||||
.trim_start_matches("\u{feff}")
|
||||
.chars()
|
||||
.peekable(),
|
||||
buf: file.source().chars().peekable(),
|
||||
pos: 0,
|
||||
file,
|
||||
}
|
||||
|
@ -96,6 +96,9 @@ impl<'a> Parser<'a> {
|
||||
pub fn parse(&mut self) -> SassResult<Vec<Stmt>> {
|
||||
let mut stmts = Vec::new();
|
||||
|
||||
// Allow a byte-order mark at the beginning of the document.
|
||||
self.consume_char_if_exists('\u{feff}');
|
||||
|
||||
self.whitespace();
|
||||
stmts.append(&mut self.load_modules()?);
|
||||
|
||||
|
@ -101,8 +101,3 @@ test!(
|
||||
"\u{feff}a {\n color: red\n}\n",
|
||||
"a {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
file_begins_with_bom,
|
||||
"\u{ef}\u{bb}\u{bf}a {\n color: red\n}\n",
|
||||
"a {\n color: red;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user