Skip to content

Code highlighting #12

@thomasheartman

Description

@thomasheartman

Hi,

Thanks for the work on the package; it's the one thing that made it a viable choice for me to switch over to Gatsby, so I'm very grateful.

I've got a question about code highlighting. In the example, the first JS example is highlighted. The gatsby-config file in this repo also seems to indicate that highlighting should be automatic:

        // if you don't want to have server side prism code highlight
        // noHighlight: true,

However, it doesn't seem to work for me, so I'm wondering how it's supposed to work? I tried both with and without :exports code, with rust, toml, and js, but there's no highlighting going on.

I was able to make prismjs work by using the remark plugin as below, though:

    {
      resolve: `gatsby-transformer-orga`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-prismjs`,
            options: {
              aliases: { sh: "bash" },
              showLineNumbers: true,
            },
          },
        ],
      },
    },

but the root pre tags don't have the right class attached, so I need to manually set their background color. It's a hack, but it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions