Skip to content

Commit 51f920d

Browse files
committed
Have UnicodeRange not serialize question marks.
1 parent 91bc2ad commit 51f920d

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.23.3"
3+
version = "0.23.4"
44
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
55

66
description = "Rust implementation of CSS Syntax Level 3"

src/unicode_range.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
use {Parser, ToCss, BasicParseError};
88
use std::char;
9-
use std::cmp;
109
use std::fmt;
1110
use tokenizer::Token;
1211

@@ -166,32 +165,9 @@ impl fmt::Debug for UnicodeRange {
166165

167166
impl ToCss for UnicodeRange {
168167
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
169-
dest.write_str("U+")?;
170-
171-
// How many bits are 0 at the end of start and also 1 at the end of end.
172-
let bits = cmp::min(self.start.trailing_zeros(), (!self.end).trailing_zeros());
173-
174-
let question_marks = bits / 4;
175-
176-
// How many lower bits can be represented as question marks
177-
let bits = question_marks * 4;
178-
179-
let truncated_start = self.start >> bits;
180-
let truncated_end = self.end >> bits;
181-
if truncated_start == truncated_end {
182-
// Bits not covered by question marks are the same in start and end,
183-
// we can use the question mark syntax.
184-
if truncated_start != 0 {
185-
write!(dest, "{:X}", truncated_start)?;
186-
}
187-
for _ in 0..question_marks {
188-
dest.write_str("?")?;
189-
}
190-
} else {
191-
write!(dest, "{:X}", self.start)?;
192-
if self.end != self.start {
193-
write!(dest, "-{:X}", self.end)?;
194-
}
168+
write!(dest, "U+{:X}", self.start)?;
169+
if self.end != self.start {
170+
write!(dest, "-{:X}", self.end)?;
195171
}
196172
Ok(())
197173
}

0 commit comments

Comments
 (0)