Skip to content

Commit 82f5952

Browse files
committed
Remove list of named character references from web_atoms
Signed-off-by: Simon Wülker <[email protected]>
1 parent 38bdcf8 commit 82f5952

File tree

4 files changed

+1
-2288
lines changed

4 files changed

+1
-2288
lines changed

markup5ever/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub use web_atoms::{
4444

4545
pub mod data {
4646
pub use web_atoms::C1_REPLACEMENTS;
47-
pub use web_atoms::NAMED_ENTITIES;
4847
}
4948
#[macro_use]
5049
pub mod interface;

web_atoms/build.rs

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010
extern crate phf_codegen;
1111
extern crate string_cache_codegen;
1212

13-
use std::collections::BTreeMap;
1413
use std::env;
1514
use std::fs::File;
1615
use std::io::{BufRead, BufReader, BufWriter, Write};
1716
use std::path::Path;
1817

19-
mod entities;
20-
2118
static NAMESPACES: &[(&str, &str)] = &[
2219
("", ""),
2320
("*", "*"),
@@ -33,8 +30,6 @@ fn main() {
3330
let generated = Path::new(&env::var("OUT_DIR").unwrap()).join("generated.rs");
3431
let mut generated = BufWriter::new(File::create(generated).unwrap());
3532

36-
named_entities_to_phf(&Path::new(&env::var("OUT_DIR").unwrap()).join("named_entities.rs"));
37-
3833
// Create a string cache for local names
3934
let local_names = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("local_names.txt");
4035
let mut local_names_atom = string_cache_codegen::AtomType::new("LocalName", "local_name!");
@@ -65,7 +60,7 @@ fn main() {
6560
writeln!(
6661
generated,
6762
r#"
68-
/// Maps the input of [`namespace_prefix!`](macro.namespace_prefix.html) to
63+
/// Maps the input of [`namespace_prefix!`](macro.namespace_prefix.html) to
6964
/// the output of [`namespace_url!`](macro.namespace_url.html).
7065
///
7166
#[macro_export] macro_rules! ns {{
@@ -81,50 +76,3 @@ fn main() {
8176
}
8277
writeln!(generated, "}}").unwrap();
8378
}
84-
85-
fn named_entities_to_phf(to: &Path) {
86-
let mut entities: BTreeMap<&str, (u32, u32)> = entities::NAMED_ENTITIES
87-
.iter()
88-
.map(|(name, cp1, cp2)| {
89-
assert!(name.starts_with('&'));
90-
(&name[1..], (*cp1, *cp2))
91-
})
92-
.collect();
93-
94-
// Add every missing prefix of those keys, mapping to NULL characters.
95-
for key in entities.keys().cloned().collect::<Vec<_>>() {
96-
for n in 1..key.len() {
97-
entities.entry(&key[..n]).or_insert((0, 0));
98-
}
99-
}
100-
entities.insert("", (0, 0));
101-
102-
let mut phf_map = phf_codegen::Map::new();
103-
for (key, value) in entities {
104-
phf_map.entry(key, &format!("{value:?}"));
105-
}
106-
107-
let mut file = File::create(to).unwrap();
108-
writeln!(
109-
&mut file,
110-
r#"
111-
/// A map of entity names to their codepoints. The second codepoint will
112-
/// be 0 if the entity contains a single codepoint. Entities have their preceding '&' removed.
113-
///
114-
/// # Examples
115-
///
116-
/// ```
117-
/// use web_atoms::NAMED_ENTITIES;
118-
///
119-
/// assert_eq!(NAMED_ENTITIES.get("gt;").unwrap(), &(62, 0));
120-
/// ```
121-
"#
122-
)
123-
.unwrap();
124-
writeln!(
125-
&mut file,
126-
"pub static NAMED_ENTITIES: Map<&'static str, (u32, u32)> = {};",
127-
phf_map.build(),
128-
)
129-
.unwrap();
130-
}

0 commit comments

Comments
 (0)