Skip to content

rustdoc does not highlight code blocks in other languages #40301

Closed
@jorendorff

Description

@jorendorff

The "Documentation" chapter of the Rust book says:

If you want something that's not Rust code, you can add an annotation:

/// ```c
/// printf("Hello, world\n");
/// ```

This will highlight according to whatever language you're showing off.

This doesn't work for me. I asked Steve about it on IRC:

<jorendorff> steveklabnik: Is this true?
<steveklabnik> jorendorff: as long as highlight.js or whatever knows how to do it, yeah, and
    there's a lot of them. like x86asm.
<jorendorff> steveklabnik: huh. i just tried it out locally and i'm not getting any highlighting...
<steveklabnik> weird
<jorendorff> steveklabnik: My devtools network tab doesn't show it trying to load highlight.js.
<jorendorff> the output HTML does contain `<code class="language-c">` and such...
<steveklabnik> i dunno then, maybe file a bug?
<steveklabnik> my understanding is that it's supposed to
<jorendorff> steveklabnik: a bug against rust, or the book? or both? I'm trying to find
    evidence in librustdoc that this feature exists, no luck
<steveklabnik> file it against rust, becuase we should determine if this feature was intended
    to exist or not first
<steveklabnik> it might end up being one against the book if that was wrong
<steveklabnik> but this might be a regression 
<steveklabnik> i dunno

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions