diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index ef7d5b5ff84..6cbbe1fdf44 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -35,6 +35,7 @@ use std::path::PathBuf; use visit_ast::RustdocVisitor; use clean; use clean::Clean; +use html::markdown::RenderType; use html::render::RenderInfo; pub use rustc::session::config::Input; @@ -54,6 +55,8 @@ pub struct DocContext<'a, 'tcx: 'a> { pub renderinfo: RefCell, /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY` pub external_traits: RefCell>, + /// Which markdown renderer to use when extracting links. + pub render_type: RenderType, // The current set of type and lifetime substitutions, // for expanding type aliases at the HIR level: @@ -104,7 +107,8 @@ pub fn run_core(search_paths: SearchPaths, triple: Option, maybe_sysroot: Option, allow_warnings: bool, - force_unstable_if_unmarked: bool) -> (clean::Crate, RenderInfo) + force_unstable_if_unmarked: bool, + render_type: RenderType) -> (clean::Crate, RenderInfo) { // Parse, resolve, and typecheck the given crate. @@ -207,6 +211,7 @@ pub fn run_core(search_paths: SearchPaths, access_levels: RefCell::new(access_levels), external_traits: Default::default(), renderinfo: Default::default(), + render_type, ty_substs: Default::default(), lt_substs: Default::default(), }; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 2e2dba7681c..01c2a5620da 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -503,6 +503,11 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R { let crate_name = matches.opt_str("crate-name"); let crate_version = matches.opt_str("crate-version"); let plugin_path = matches.opt_str("plugin-path"); + let render_type = if matches.opt_present("enable-commonmark") { + RenderType::Pulldown + } else { + RenderType::Hoedown + }; info!("starting to run rustc"); let display_warnings = matches.opt_present("display-warnings"); @@ -517,7 +522,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R { let (mut krate, renderinfo) = core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot, - display_warnings, force_unstable_if_unmarked); + display_warnings, force_unstable_if_unmarked, render_type); info!("finished with rustc");