@@ -20,7 +20,7 @@ use externalfiles::ExternalHtml;
20
20
21
21
use html:: escape:: Escape ;
22
22
use html:: markdown;
23
- use html:: markdown:: { MarkdownWithToc , find_testable_code, reset_headers} ;
23
+ use html:: markdown:: { Markdown , MarkdownWithToc , find_testable_code, reset_headers} ;
24
24
use test:: Collector ;
25
25
26
26
/// Separate any lines at the start of the file that begin with `%`.
@@ -42,7 +42,7 @@ fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
42
42
/// Render `input` (e.g. "foo.md") into an HTML file in `output`
43
43
/// (e.g. output = "bar" => "bar/foo.html").
44
44
pub fn render ( input : & str , mut output : Path , matches : & getopts:: Matches ,
45
- external_html : & ExternalHtml ) -> int {
45
+ external_html : & ExternalHtml , include_toc : bool ) -> int {
46
46
let input_p = Path :: new ( input) ;
47
47
output. push ( input_p. filestem ( ) . unwrap ( ) ) ;
48
48
output. set_extension ( "html" ) ;
@@ -80,6 +80,12 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
80
80
81
81
reset_headers ( ) ;
82
82
83
+ let rendered = if include_toc {
84
+ format ! ( "{}" , MarkdownWithToc ( text) )
85
+ } else {
86
+ format ! ( "{}" , Markdown ( text) )
87
+ } ;
88
+
83
89
let err = write ! (
84
90
& mut out,
85
91
r#"<!DOCTYPE html>
@@ -113,7 +119,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
113
119
css = css,
114
120
in_header = external_html. in_header,
115
121
before_content = external_html. before_content,
116
- text = MarkdownWithToc ( text ) ,
122
+ text = rendered ,
117
123
after_content = external_html. after_content,
118
124
playground = playground,
119
125
) ;
0 commit comments