File tree Expand file tree Collapse file tree 6 files changed +25
-35
lines changed
theme/copy_fonts_false_with_fonts_css Expand file tree Collapse file tree 6 files changed +25
-35
lines changed Original file line number Diff line number Diff line change @@ -305,38 +305,3 @@ fn summary_with_markdown_formatting() {
305
305
"# <escaped tag>\n "
306
306
) ;
307
307
}
308
-
309
- #[ test]
310
- fn custom_fonts ( ) {
311
- // Tests to ensure custom fonts are copied as expected.
312
- let actual_files = |path : & Path | -> Vec < String > {
313
- let mut actual: Vec < _ > = path
314
- . read_dir ( )
315
- . unwrap ( )
316
- . map ( |entry| entry. unwrap ( ) . file_name ( ) . into_string ( ) . unwrap ( ) )
317
- . collect ( ) ;
318
- actual. sort ( ) ;
319
- actual
320
- } ;
321
- let has_fonts_css = |path : & Path | -> bool {
322
- let contents = fs:: read_to_string ( path. join ( "book/index.html" ) ) . unwrap ( ) ;
323
- contents. contains ( "fonts/fonts.css" )
324
- } ;
325
-
326
- // copy-fonts=false with fonts theme
327
- let temp = TempFileBuilder :: new ( ) . prefix ( "mdbook" ) . tempdir ( ) . unwrap ( ) ;
328
- let p = temp. path ( ) ;
329
- MDBook :: init ( p) . build ( ) . unwrap ( ) ;
330
- write_file ( & p. join ( "theme/fonts" ) , "fonts.css" , b"/*custom*/" ) . unwrap ( ) ;
331
- write_file ( & p. join ( "theme/fonts" ) , "myfont.woff" , b"" ) . unwrap ( ) ;
332
- let config = Config :: from_str ( "output.html.copy-fonts = false" ) . unwrap ( ) ;
333
- MDBook :: load_with_config ( p, config)
334
- . unwrap ( )
335
- . build ( )
336
- . unwrap ( ) ;
337
- assert ! ( has_fonts_css( p) ) ;
338
- assert_eq ! (
339
- actual_files( & p. join( "book/fonts" ) ) ,
340
- & [ "fonts.css" , "myfont.woff" ]
341
- ) ;
342
- }
Original file line number Diff line number Diff line change @@ -170,3 +170,24 @@ fn copy_fonts_false_with_empty_fonts_css() {
170
170
. check_file_doesnt_contain ( "book/index.html" , "fonts.css" )
171
171
. check_file_list ( "book/fonts" , str![ [ "" ] ] ) ;
172
172
}
173
+
174
+ // copy-fonts=false, fonts.css has contents
175
+ #[ test]
176
+ fn copy_fonts_false_with_fonts_css ( ) {
177
+ BookTest :: from_dir ( "theme/copy_fonts_false_with_fonts_css" )
178
+ . run ( "build" , |cmd| {
179
+ cmd. expect_stderr ( str![ [ r#"
180
+ [TIMESTAMP] [INFO] (mdbook::book): Book building has started
181
+ [TIMESTAMP] [INFO] (mdbook::book): Running the html backend
182
+
183
+ "# ] ] ) ;
184
+ } )
185
+ . check_file_contains ( "book/index.html" , "fonts.css" )
186
+ . check_file_list (
187
+ "book/fonts" ,
188
+ str![ [ r#"
189
+ book/fonts/fonts.css
190
+ book/fonts/myfont.woff
191
+ "# ] ] ,
192
+ ) ;
193
+ }
Original file line number Diff line number Diff line change
1
+ [output .html ]
2
+ copy-fonts = false
Original file line number Diff line number Diff line change
1
+ - [ Intro] ( index.md )
Original file line number Diff line number Diff line change
1
+ /*custom*/
You can’t perform that action at this time.
0 commit comments