@@ -29,7 +29,12 @@ fn collect_title_in_hast(node: &mut hast::Element) -> (String, String) {
29
29
}
30
30
}
31
31
hast:: Node :: Element ( element) => {
32
- if element. tag_name == "code" || element. tag_name == "a" {
32
+ if element. tag_name == "code"
33
+ || element. tag_name == "a"
34
+ || element. tag_name == "strong"
35
+ || element. tag_name == "em"
36
+ || element. tag_name == "del"
37
+ {
33
38
for child in & element. children {
34
39
if let hast:: Node :: Text ( text) = child {
35
40
title. push_str ( & text. value ) ;
@@ -176,6 +181,51 @@ mod tests {
176
181
position : None ,
177
182
} ;
178
183
184
+ let mut element3 = hast:: Element {
185
+ tag_name : "h3" . to_string ( ) ,
186
+ properties : vec ! [ ] ,
187
+ children : vec ! [ Node :: Element ( hast:: Element {
188
+ tag_name: "strong" . to_string( ) ,
189
+ properties: vec![ ] ,
190
+ children: vec![ Node :: Text ( hast:: Text {
191
+ value: "Bold" . to_string( ) ,
192
+ position: None ,
193
+ } ) ] ,
194
+ position: None ,
195
+ } ) ] ,
196
+ position : None ,
197
+ } ;
198
+
199
+ let mut element4 = hast:: Element {
200
+ tag_name : "h4" . to_string ( ) ,
201
+ properties : vec ! [ ] ,
202
+ children : vec ! [ Node :: Element ( hast:: Element {
203
+ tag_name: "em" . to_string( ) ,
204
+ properties: vec![ ] ,
205
+ children: vec![ Node :: Text ( hast:: Text {
206
+ value: "Italic" . to_string( ) ,
207
+ position: None ,
208
+ } ) ] ,
209
+ position: None ,
210
+ } ) ] ,
211
+ position : None ,
212
+ } ;
213
+
214
+ let mut element5 = hast:: Element {
215
+ tag_name : "h5" . to_string ( ) ,
216
+ properties : vec ! [ ] ,
217
+ children : vec ! [ Node :: Element ( hast:: Element {
218
+ tag_name: "del" . to_string( ) ,
219
+ properties: vec![ ] ,
220
+ children: vec![ Node :: Text ( hast:: Text {
221
+ value: "Strikethrough" . to_string( ) ,
222
+ position: None ,
223
+ } ) ] ,
224
+ position: None ,
225
+ } ) ] ,
226
+ position : None ,
227
+ } ;
228
+
179
229
assert_eq ! (
180
230
collect_title_in_hast( & mut element1) ,
181
231
( "HelloWorldWorld" . to_string( ) , "" . to_string( ) )
@@ -184,6 +234,18 @@ mod tests {
184
234
collect_title_in_hast( & mut element2) ,
185
235
( "Hello World" . to_string( ) , "" . to_string( ) )
186
236
) ;
237
+ assert_eq ! (
238
+ collect_title_in_hast( & mut element3) ,
239
+ ( "Bold" . to_string( ) , "" . to_string( ) )
240
+ ) ;
241
+ assert_eq ! (
242
+ collect_title_in_hast( & mut element4) ,
243
+ ( "Italic" . to_string( ) , "" . to_string( ) )
244
+ ) ;
245
+ assert_eq ! (
246
+ collect_title_in_hast( & mut element5) ,
247
+ ( "Strikethrough" . to_string( ) , "" . to_string( ) )
248
+ ) ;
187
249
}
188
250
189
251
#[ test]
0 commit comments