Skip to content

Ability to highlight lines in code blocks #9

Open

Description

@seancdavis

It would be great to be able to highlight lines in code blocks to help focus readers in the documentation.

Tailwind's docs show a nice example of this.

Activity

  1. seancdavis commented on Feb 23, 2022

    @seancdavis
    ContributorAuthor

    I did some research and couldn't find anything that will do this right out of the box.

    I found an example of building a custom rehype plugin. There's a lot more going on here than is necessary. May not be all that difficult to do.

  2. MiryangJung commented on Apr 12, 2022

    @MiryangJung

    How about using https://github.com/timlrx/rehype-prism-plus

    export default makeSource({
      ...
      mdx: { rehypePlugins: [highlight, rehypePrism] },
    })
    

    I tested it and it looks like this.
    스크린샷 2022-04-13 오전 1 54 56

  3. seancdavis commented on Apr 29, 2022

    @seancdavis
    ContributorAuthor

    @MiryangJung This could definitely work! I'm going to spend some time with the docs site next week and I'll take a look. Thanks for sharing!

  4. added
    documentation
    enhancement
    page: docs
    and removed
    documentation
    on May 18, 2022
  5. nkilm commented on Jan 19, 2023

    @nkilm

    @seancdavis You can make use of Rehype Pretty Code, it can also be used to highlight lines in a code snippet. It also has some advantages over prism e.g, build-time highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpage: docs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions