10
10
extern crate phf_codegen;
11
11
extern crate string_cache_codegen;
12
12
13
- use std:: collections:: BTreeMap ;
14
13
use std:: env;
15
14
use std:: fs:: File ;
16
15
use std:: io:: { BufRead , BufReader , BufWriter , Write } ;
17
16
use std:: path:: Path ;
18
17
19
- mod entities;
20
-
21
18
static NAMESPACES : & [ ( & str , & str ) ] = & [
22
19
( "" , "" ) ,
23
20
( "*" , "*" ) ,
@@ -33,8 +30,6 @@ fn main() {
33
30
let generated = Path :: new ( & env:: var ( "OUT_DIR" ) . unwrap ( ) ) . join ( "generated.rs" ) ;
34
31
let mut generated = BufWriter :: new ( File :: create ( generated) . unwrap ( ) ) ;
35
32
36
- named_entities_to_phf ( & Path :: new ( & env:: var ( "OUT_DIR" ) . unwrap ( ) ) . join ( "named_entities.rs" ) ) ;
37
-
38
33
// Create a string cache for local names
39
34
let local_names = Path :: new ( & env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) . join ( "local_names.txt" ) ;
40
35
let mut local_names_atom = string_cache_codegen:: AtomType :: new ( "LocalName" , "local_name!" ) ;
@@ -65,7 +60,7 @@ fn main() {
65
60
writeln ! (
66
61
generated,
67
62
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
69
64
/// the output of [`namespace_url!`](macro.namespace_url.html).
70
65
///
71
66
#[macro_export] macro_rules! ns {{
@@ -81,50 +76,3 @@ fn main() {
81
76
}
82
77
writeln ! ( generated, "}}" ) . unwrap ( ) ;
83
78
}
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