Skip to content

Allow case-insensitivity for code block language #9012

Description

@igormalaes

Have you read the Contributing Guidelines on issues?

Description

Hey, I tried to add PHP for code highlighting in the code blocks and according to the doc for this PHP needs to be added in the prism array.
After running the command:

npm run swizzle @docusaurus/theme-classic prism-include-languages

And adding 'PHP' to the array, it didn't work; I still had no code highlighting.
After a few minutes troubleshooting, I wrote PHP in lower case (because out of habit I write it in upper case) and it worked.

I'm unsure this is a bug or not. In Markdown, it functions correctly, and no distinction is made as to whether the programming language is written in upper case or lower case (as shown below). If it's not a bug, I believe it's worth mentioning in the documentation to avoid confusion for future users.

const prismIncludeLanguages = (Prism) => {
  // ...

  additionalLanguages.forEach((lang) => {
    require(`prismjs/components/prism-${lang}`);
  });

  require('/path/to/your/prism-language-definition');

  // ...
};
const prismIncludeLanguages = (Prism) => {
  // ...

  additionalLanguages.forEach((lang) => {
    require(`prismjs/components/prism-${lang}`);
  });

  require('/path/to/your/prism-language-definition');

  // ...
};

Self-service

  • I'd be willing to address this documentation request myself.

Activity

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

    featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions