diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-11-24 23:12:35 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-12-07 23:56:21 +0100 |
| commit | eb84f4243fa7e18f97ee39f6c0b751f4c329a4ee (patch) | |
| tree | 59789077a3e195107d1879f99e113d9c50ceda0a | |
| parent | 8b1fc4b842929961f2f6a09d7c44ec010150ed77 (diff) | |
| download | rust-eb84f4243fa7e18f97ee39f6c0b751f4c329a4ee.tar.gz rust-eb84f4243fa7e18f97ee39f6c0b751f4c329a4ee.zip | |
fix markdown file differences
| -rw-r--r-- | src/doc/not_found.md | 14 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 17 | ||||
| -rw-r--r-- | src/librustdoc/markdown.rs | 16 |
3 files changed, 22 insertions, 25 deletions
diff --git a/src/doc/not_found.md b/src/doc/not_found.md index ebe7c59313f..f404aa046c1 100644 --- a/src/doc/not_found.md +++ b/src/doc/not_found.md @@ -13,20 +13,20 @@ Some things that might be helpful to you though: # Search -* <form action="https://duckduckgo.com/"> +<form action="https://duckduckgo.com/"> <input type="text" id="site-search" name="q" size="80"></input> - <input type="submit" value="Search DuckDuckGo"> -</form> -* Rust doc search: <span id="core-search"></span> + <input type="submit" value="Search DuckDuckGo"></form> + +Rust doc search: <span id="core-search"></span> # Reference -* [The Rust official site](https://www.rust-lang.org) -* [The Rust reference](https://doc.rust-lang.org/reference/index.html) + * [The Rust official site](https://www.rust-lang.org) + * [The Rust reference](https://doc.rust-lang.org/reference/index.html) # Docs -* [The standard library](https://doc.rust-lang.org/std/) +[The standard library](https://doc.rust-lang.org/std/) <script> function get_url_fragments() { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 8478fd6c5fd..5292e643b0a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -424,6 +424,16 @@ thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> = thread_local!(pub static USED_ID_MAP: RefCell<FxHashMap<String, usize>> = RefCell::new(init_ids())); +pub fn render_text<F: FnMut(RenderType) -> String>(mut render: F) -> (String, String) { + // Save the state of USED_ID_MAP so it only gets updated once even + // though we're rendering twice. + let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); + let hoedown_output = render(RenderType::Hoedown); + USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); + let pulldown_output = render(RenderType::Pulldown); + (hoedown_output, pulldown_output) +} + fn init_ids() -> FxHashMap<String, usize> { [ "main", @@ -1856,12 +1866,7 @@ fn render_markdown(w: &mut fmt::Formatter, prefix: &str, scx: &SharedContext) -> fmt::Result { - // Save the state of USED_ID_MAP so it only gets updated once even - // though we're rendering twice. - let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); - let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown)); - USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); - let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown)); + let (hoedown_output, pulldown_output) = render_text(|ty| format!("{}", Markdown(md_text, ty))); let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output); differences.retain(|s| { match *s { diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 1fdfa17a8dd..9b94e9918f8 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -25,9 +25,9 @@ use externalfiles::{ExternalHtml, LoadStringError, load_string}; use html_diff; -use html::render::reset_ids; +use html::render::{render_text, reset_ids}; use html::escape::Escape; -use html::render::{USED_ID_MAP, render_difference}; +use html::render::render_difference; use html::markdown; use html::markdown::{Markdown, MarkdownWithToc, find_testable_code, old_find_testable_code}; use html::markdown::RenderType; @@ -101,19 +101,11 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, let (hoedown_output, pulldown_output) = if include_toc { // Save the state of USED_ID_MAP so it only gets updated once even // though we're rendering twice. - let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); - let hoedown_output = format!("{}", MarkdownWithToc(text, RenderType::Hoedown)); - USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); - let pulldown_output = format!("{}", MarkdownWithToc(text, RenderType::Pulldown)); - (hoedown_output, pulldown_output) + render_text(|ty| format!("{}", MarkdownWithToc(text, ty))) } else { // Save the state of USED_ID_MAP so it only gets updated once even // though we're rendering twice. - let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); - let hoedown_output = format!("{}", Markdown(text, RenderType::Hoedown)); - USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); - let pulldown_output = format!("{}", Markdown(text, RenderType::Pulldown)); - (hoedown_output, pulldown_output) + render_text(|ty| format!("{}", Markdown(text, ty))) }; let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output); |
