Skip to content

Highlightjs custom highlighting config ignored in production #960

@chenglou

Description

@chenglou

🐛 Bug Report

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. In siteConfig.js, in the highlight field, add this:
    hljs: function(hljs) {
      hljs.registerLanguage('reason', reasonHighlightJs)
    }
    where reasonHighlightJs is an existing callback that adds a new highlighter.
  2. Run dev, see that the custom highlighting works

Expected behavior

Run prod, see that the custom highlighting should be picked up

Actual Behavior

Highlighting isn't picked up =(

Reproducible Demo

Check out reasonml/reasonml.github.io@2c7b36f then cd website && yarn && yarn start, compare some resulting highlighting html against yarn docusaurus-build in the generated docs folder.

Solution

This is caused by dev & prod not sharing the same code path. They have diverged quite a bit from what I'm seeing. I've patched this like so: chenglou@bade05e
As a matter of fact, siteConfig.hightlight.hlgs is never called anywhere in prod!
This patch works, but I'm not too sure this is the right way to go. The dev & prod flow should probably be much closer. There are likely other hidden bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiongood first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.help wantedAsking for outside help and/or contributions to this particular issue or PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions