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> {
|
impl<'a> Lexer<'a> {
|
||||||
pub fn new(file: &'a Arc<File>) -> Lexer<'a> {
|
pub fn new(file: &'a Arc<File>) -> Lexer<'a> {
|
||||||
Lexer {
|
Lexer {
|
||||||
buf: file
|
buf: file.source().chars().peekable(),
|
||||||
.source()
|
|
||||||
.trim_start_matches("\u{ef}\u{bb}\u{bf}")
|
|
||||||
.trim_start_matches("\u{feff}")
|
|
||||||
.chars()
|
|
||||||
.peekable(),
|
|
||||||
pos: 0,
|
pos: 0,
|
||||||
file,
|
file,
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,9 @@ impl<'a> Parser<'a> {
|
|||||||
pub fn parse(&mut self) -> SassResult<Vec<Stmt>> {
|
pub fn parse(&mut self) -> SassResult<Vec<Stmt>> {
|
||||||
let mut stmts = Vec::new();
|
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();
|
self.whitespace();
|
||||||
stmts.append(&mut self.load_modules()?);
|
stmts.append(&mut self.load_modules()?);
|
||||||
|
|
||||||
|
@ -101,8 +101,3 @@ test!(
|
|||||||
"\u{feff}a {\n color: red\n}\n",
|
"\u{feff}a {\n color: red\n}\n",
|
||||||
"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