Skip to content

Commit d457a37

Browse files
committed
Merge pull request #30 from SimonSapin/line-numbers
Fix #27: line number tracking inside url()
2 parents 4b2d1c3 + 832c900 commit d457a37

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

css-parsing-tests/README.rst

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ The upstream repository for these tests is at
1010
https://github.com/SimonSapin/css-parsing-tests
1111

1212

13+
Projects using this
14+
===================
15+
16+
CSS parsers using these tests:
17+
18+
* `tinycss2 <https://github.com/SimonSapin/tinycss2>`_ (Python)
19+
* `rust-cssparser <https://github.com/mozilla-servo/rust-cssparser>`_
20+
(Rust, used in `Servo <https://github.com/mozilla/servo/>`_)
21+
* `Crass <https://github.com/rgrove/crass/>`_ (Ruby)
22+
23+
1324
Importing
1425
=========
1526

css-parsing-tests/component_value_list.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162

163163
"url('a\nb') url('c\n", [["error", "bad-url"], " ", ["error", "bad-url"]],
164164

165-
"url() url( \t) url( Foô\\030\n!\n) url(a b) url(a\\ b) url(a(b) url(a\\(b) url(a'b) url(a\\'b) url(a\"b) url(a\\\"b) url(a\nb) url(a\\\nb) url(a\\a b) url(a\\", [
165+
"url() url( \t) url(\n Foô\\030\n!\n) url(\na\nb\n) url(a\\ b) url(a(b) url(a\\(b) url(a'b) url(a\\'b) url(a\"b) url(a\\\"b) url(a\nb) url(a\\\nb) url(a\\a b) url(a\\", [
166166
["url", ""], " ",
167167
["url", ""], " ",
168168
["url", "Foô0!"], " ",

tokenizer.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,11 @@ fn consume_url(tokenizer: &mut Tokenizer) -> ComponentValue {
461461
tokenizer.position += 1; // Skip the ( of url(
462462
while !tokenizer.is_eof() {
463463
match tokenizer.current_char() {
464-
'\t' | '\n' | ' ' => tokenizer.position += 1,
464+
' ' | '\t' => tokenizer.position += 1,
465+
'\n' => {
466+
tokenizer.position += 1;
467+
tokenizer.new_line();
468+
},
465469
'"' => return consume_quoted_url(tokenizer, false),
466470
'\'' => return consume_quoted_url(tokenizer, true),
467471
')' => { tokenizer.position += 1; break },

0 commit comments

Comments
 (0)