diff --git a/src/theme/css/general.css b/src/theme/css/general.css index 5f11fd5b..531a8e5f 100644 --- a/src/theme/css/general.css +++ b/src/theme/css/general.css @@ -190,9 +190,10 @@ blockquote { font-style: italic; } -pre.syntect { +code.syntect { color: var(--syntect-fg); background: var(--syntect-bg); padding: 0.5em; overflow-y: auto; + display: block; } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 84dc69f0..2c917045 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -338,7 +338,7 @@ impl<'a> SyntaxHighlighter<'a> { } self.is_playground = true; return Event::Html(CowStr::from(format!( - r#"
"#,
+                                r#"
"#,
                                 classes.join(" ")
                             )));
                         } else {
@@ -355,7 +355,7 @@ impl<'a> SyntaxHighlighter<'a> {
                     Event::Html(CowStr::from("
"))
                 } else {
                     Event::Html(CowStr::from(format!(
-                        r#"
"#,
+                        r#"
"#,
                         classes.join(" ")
                     )))
                 }
@@ -578,7 +578,7 @@ more text with spaces
 "#;
 
             let expected = r#"

some text with spaces

-
fn main() {
+
fn main() {
 // code inside is unchanged
 }
 
@@ -613,7 +613,7 @@ more text with spaces ``` "#; - let expected = r#"
"#; + let expected = r#"
"#; assert_eq!( render_markdown( input, @@ -643,7 +643,7 @@ more text with spaces ``` "#; - let expected = r#"
"#; + let expected = r#"
"#; assert_eq!( render_markdown( input, @@ -674,7 +674,7 @@ more text with spaces "#; let expected = - r#"
"#; + r#"
"#; assert_eq!( render_markdown( input, @@ -705,19 +705,19 @@ more text with spaces fn add_playground() { let inputs = [ ("```rust\nx()\n```", - "
fn main() {\nx()\n}\n
"), + "
fn main() {\nx()\n}\n
"), ("```rust\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust editable\nlet s = \"foo\n # bar\n\";\n```", - "
let s = "foo\n bar\n";\n
"), + "
let s = "foo\n bar\n";\n
"), ("```rust editable\nlet s = \"foo\n ## bar\n\";\n```", - "
let s = "foo\n # bar\n";\n
"), + "
let s = "foo\n # bar\n";\n
"), ("```rust editable\nlet s = \"foo\n # bar\n#\n\";\n```", - "
let s = "foo\n bar\n\n";\n
"), + "
let s = "foo\n bar\n\n";\n
"), ("```rust ignore\nlet s = \"foo\n # bar\n\";\n```", - "
let s = "foo\n bar\n";\n
"), + "
let s = "foo\n bar\n";\n
"), ("```rust editable\n#![no_std]\nlet s = \"foo\";\n #[some_attr]\n```", - "
#![no_std]\nlet s = "foo";\n #[some_attr]\n
"), + "
#![no_std]\nlet s = "foo";\n #[some_attr]\n
"), ]; for (src, should_be) in &inputs { let got = render_markdown( @@ -737,13 +737,13 @@ more text with spaces fn add_playground_edition2015() { let inputs = [ ("```rust\nx()\n```", - "
fn main() {\nx()\n}\n
"), + "
fn main() {\nx()\n}\n
"), ("```rust\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2015\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2018\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ]; for (src, should_be) in &inputs { let got = render_markdown( @@ -763,13 +763,13 @@ more text with spaces fn add_playground_edition2018() { let inputs = [ ("```rust\nx()\n```", - "
fn main() {\nx()\n}\n
"), + "
fn main() {\nx()\n}\n
"), ("```rust\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2015\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2018\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ]; for (src, should_be) in &inputs { let got = render_markdown( @@ -789,13 +789,13 @@ more text with spaces fn add_playground_edition2021() { let inputs = [ ("```rust\nx()\n```", - "
fn main() {\nx()\n}\n
"), + "
fn main() {\nx()\n}\n
"), ("```rust\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2015\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ("```rust edition2018\nfn main() {}\n```", - "
fn main() {}\n
"), + "
fn main() {}\n
"), ]; for (src, should_be) in &inputs { let got = render_markdown( @@ -815,9 +815,9 @@ more text with spaces fn no_add_playground_to_other_languages() { let inputs = [ ("```html,testhtml\n

\n```", - "

<p>\n
"), + "
<p>\n
"), ("```js es7\nf()\n```", - "
f()\n
"), + "
f()\n
"), ]; for (src, should_be) in &inputs { let got = render_markdown( diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 9825fc26..282930a4 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -144,7 +144,7 @@ fn rendered_code_has_playground_stuff() { md.build().unwrap(); let nested = temp.path().join("book/first/nested.html"); - let playground_class = vec![r#"class="syntect playground""#]; + let playground_class = vec![r#"class="playground""#]; assert_contains_strings(nested, &playground_class); @@ -392,7 +392,7 @@ fn able_to_include_playground_files_in_chapters() { let second = temp.path().join("book/second.html"); let playground_strings = &[ - r#"class="syntect playground""#, + r#"class="playground""#, r#"println!("Hello World!"#, ];