Skip to content

Fix syntax highlighting of code fences #5110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2020
Merged

Fix syntax highlighting of code fences #5110

merged 3 commits into from
Jan 30, 2020

Conversation

Aloso
Copy link
Contributor

@Aloso Aloso commented Jan 30, 2020

The documentation for RESULT_EXPECT_USED includes this code:

let res: Result<usize, ()> = Ok(1);
res?;
# Ok::<(), ()>(())

Because the code fence didn't start with rust, the code wasn't highlighted and the line starting with # was displayed on the website. This is now fixed.

EDIT: I noticed that highlighting for some other lints is broken as well. It only works if the code fence looks like this:

```rust
// ..
```

However, many code blocks were ignored. I un-ignored most code blocks and made them compile by adding hidden code with #. While doing so, I found two mistakes:

opt.map_or(None, |a| a + 1)
// instead of
opt.map_or(None, |a| Some(a + 1))

and

fn as_str(self) -> &str
// instead of
fn as_str(self) -> &'static str

changelog: none

Aloso and others added 2 commits January 30, 2020 21:55
The documentation for RESULT_EXPECT_USED includes this code:

    let res: Result<usize, ()> = Ok(1);
    res?;
    # Ok::<(), ()>(())

Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.
@flip1995
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 30, 2020

📌 Commit f0dc981 has been approved by flip1995

bors added a commit that referenced this pull request Jan 30, 2020
Fix syntax highlighting of code fence

The documentation for RESULT_EXPECT_USED includes this code:

    let res: Result<usize, ()> = Ok(1);
    res?;
    # Ok::<(), ()>(())

Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.

changelog: none
@bors
Copy link
Contributor

bors commented Jan 30, 2020

⌛ Testing commit f0dc981 with merge 56f9395...

@Aloso Aloso changed the title Fix syntax highlighting of code fence Fix syntax highlighting of code fences Jan 30, 2020
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Jan 30, 2020

📌 Commit 1f600f3 has been approved by flip1995

@bors
Copy link
Contributor

bors commented Jan 30, 2020

⌛ Testing commit 1f600f3 with merge 8e9089e...

bors added a commit that referenced this pull request Jan 30, 2020
Fix syntax highlighting of code fences

The documentation for RESULT_EXPECT_USED includes this code:

    let res: Result<usize, ()> = Ok(1);
    res?;
    # Ok::<(), ()>(())

Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.

EDIT: I noticed that highlighting for some other lints is broken as well. It only works if the code fence looks like this:

````markdown
```rust
// ..
```
````

However, many code blocks were ignored. I un-ignored most code blocks and made them compile by adding hidden code with `#`. While doing so, I found two mistakes:

```rust
opt.map_or(None, |a| a + 1)
// instead of
opt.map_or(None, |a| Some(a + 1))
```
and

```rust
fn as_str(self) -> &str
// instead of
fn as_str(self) -> &'static str
```

changelog: none
@bors
Copy link
Contributor

bors commented Jan 30, 2020

☀️ Test successful - checks-travis, status-appveyor
Approved by: flip1995
Pushing 8e9089e to master...

@bors bors merged commit 1f600f3 into rust-lang:master Jan 30, 2020
@Aloso Aloso deleted the patch-1 branch January 31, 2020 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants