Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlightjs custom highlighting config ignored in production #960

Closed
chenglou opened this issue Sep 14, 2018 · 3 comments
Closed

Highlightjs custom highlighting config ignored in production #960

chenglou opened this issue Sep 14, 2018 · 3 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@chenglou
Copy link
Contributor

🐛 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.

@chenglou chenglou added the bug An error in the Docusaurus core causing instability or issues with its execution label Sep 14, 2018
@endiliey
Copy link
Contributor

endiliey commented Sep 14, 2018

As a matter of fact, siteConfig.hightlight.hljs is never called anywhere in prod!

As far as I'm aware, the only place where we define the highlightjs is only on that file. I checked the git blame and it seems that it has been like this since the initial release.

This patch works, but I'm not too sure this is the right way to go

I think the patch is the correct way to do it.

Thanks for reporting :)

@endiliey endiliey added help wanted Asking for outside help and/or contributions to this particular issue or PR. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. labels Sep 14, 2018
@rishacha
Copy link

Hi, can I attempt this ?

@endiliey
Copy link
Contributor

@rishacha sure, send a PR in 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

No branches or pull requests

3 participants