about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-10-14 17:02:04 +0200
committerPietro Albini <pietro@pietroalbini.org>2020-11-17 12:42:47 +0100
commitf7886a62772dc571f8ad266561f267d5f88a819d (patch)
tree587e2e0cd14cd96f8f7327ca56667fe15d4a5b66
parent2f3b6e132044ddd7c72553380c5cc0f062d65357 (diff)
downloadrust-f7886a62772dc571f8ad266561f267d5f88a819d.tar.gz
rust-f7886a62772dc571f8ad266561f267d5f88a819d.zip
Ensure that the source code display is working with DOS backline
-rw-r--r--src/librustdoc/html/highlight.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index 4769edc50ff..98633733654 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -21,6 +21,8 @@ pub fn render_with_highlighting(
     playground_button: Option<&str>,
     tooltip: Option<(&str, &str)>,
 ) -> String {
+    // This replace allows to fix how the code source with DOS backline characters is displayed.
+    let src = src.replace("\r\n", "\n");
     debug!("highlighting: ================\n{}\n==============", src);
     let mut out = String::with_capacity(src.len());
     if let Some((tooltip, class)) = tooltip {