Markdown file or generated documentation",
"FILES"),
optopt("", "markdown-playground-url",
- "URL to send code snippets to", "URL")
+ "URL to send code snippets to", "URL"),
+ optflag("", "markdown-no-toc", "don't include table of contents")
)
}
return test::run(input, cfgs, libs, externs, test_args)
}
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
- &matches, &external_html),
+ &matches, &external_html,
+ !matches.opt_present("markdown-no-toc")),
(false, false) => {}
}
use html::escape::Escape;
use html::markdown;
-use html::markdown::{MarkdownWithToc, find_testable_code, reset_headers};
+use html::markdown::{Markdown, MarkdownWithToc, find_testable_code, reset_headers};
use test::Collector;
/// Separate any lines at the start of the file that begin with `%`.
/// Render `input` (e.g. "foo.md") into an HTML file in `output`
/// (e.g. output = "bar" => "bar/foo.html").
pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
- external_html: &ExternalHtml) -> int {
+ external_html: &ExternalHtml, include_toc: bool) -> int {
let input_p = Path::new(input);
output.push(input_p.filestem().unwrap());
output.set_extension("html");
reset_headers();
+ let rendered = if include_toc {
+ format!("{}", MarkdownWithToc(text))
+ } else {
+ format!("{}", Markdown(text))
+ };
+
let err = write!(
&mut out,
r#"<!DOCTYPE html>
css = css,
in_header = external_html.in_header,
before_content = external_html.before_content,
- text = MarkdownWithToc(text),
+ text = rendered,
after_content = external_html.after_content,
playground = playground,
);