Skip to content

Trouble with adding Scala language for syntax highligh #4799

@majk-p

Description

@majk-p

🐛 Bug Report

Following the documentation (specifically https://docusaurus.io/docs/next/markdown-features/code-blocks#syntax-highlighting) I cannot simply add Scala syntax highlight by setting additionalLanguages: ['scala'].

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Example repository: https://github.com/majk-p/docusaurus-syntax-highlight-issue
Reproduction in sandbox: https://codesandbox.io/s/wandering-cache-lzcj2?file=/docusaurus.config.js (affected resulting website: https://lzcj2.sse.codesandbox.io/docs/intro)

If possible, use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

  1. Initialize docusaurus npx @docusaurus/init@2.0.0-beta.0 init website classic
  2. Add a snippet in a language that's not supported out of the box (as in https://docusaurus.io/docs/next/markdown-features/code-blocks#syntax-highlighting) for example: https://github.com/majk-p/docusaurus-syntax-highlight-issue/blob/master/website/docs/intro.md
  3. Extend themeConfig.prism.additionalLanguages with the languages you have used in intro.md, e.g. additionalLanguages: ['scala'],

Please note that I've used Scala as my main sample, but this seems to also affects other languages e.g php

Expected behavior

  1. The site renders correctly
  2. The snippets are rendered with correct syntax highlight

Actual Behavior

When visiting the site (in the example the intro page) it renders blank. Additionally there's an issue in dev tools:

image

Your Environment

  • Public source code: https://github.com/majk-p/docusaurus-syntax-highlight-issue

  • Public site url: not published, please see reproducible demo below

  • Docusaurus version used: 2.0.0-beta.0

  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0):

  • Browsers tested: 88.0.1 and Chromium 90.0.4430.212 (Official Build) snap (64-bit)

  • Node: v12.22.1 locally and (I guess) v14 in sandbox (latest at the time of writing)

  • Operating system and version (desktop or mobile): Ubuntu 20.04

Reproducible Demo

If possible, use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.
https://codesandbox.io/s/wandering-cache-lzcj2

Extra notes

Specifically for Scala snippets, using:

additionalLanguages: ['java', 'scala'],

Resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed: questionThis issue is a user error/misunderstanding.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions