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

StackOverflow's Highlight.js integration is BROKEN when you manually specify language #3183

Closed
joshgoebel opened this issue May 8, 2021 · 2 comments
Labels
discuss/propose Proposal for a new feature/direction help welcome Could use help from community

Comments

@joshgoebel
Copy link
Member

joshgoebel commented May 8, 2021

Please see: https://meta.stackexchange.com/questions/355852/stop-guessing-auto-detecting-a-language-when-you-know-it-will-be-incorrect/362811#362811

To summarize the issue if someone manually specifies a particular language for a code block: (below ruby is the language specified)

```ruby
def launch
   @rocket.fire!
end
```

Only one of two things should happen.

  1. If the "ruby" grammar is registered with Highlight.js, it should be used.
  2. If not the code block should remain unhighlighted. (operationally an error could be shown)

What actually happens:

StackOverflow RANDOMLY picks a language to use for highlighting, which will always be WRONG and even worse - unpredictable.

What can you do? Post on the linked to thread on StackOverflow... post new threads that bring this to StackOverflows attention(?), contact StackOverflow support... I'm honestly not sure how to get them to fix this. The fix is trivially simple and no one at StackOverflow has yet explained why this cannot or should not be changed.


This thread is created to serve as the primary thread to point people to when they post issues here that are the result of StackOverflows refusal to fix this. Other issues opened will be marked as duplicates and pointed here.

@joshgoebel joshgoebel added bug help welcome Could use help from community parser labels May 8, 2021
@joshgoebel joshgoebel changed the title StackOverflow's Highlight.js integration is broken StackOverflow's Highlight.js integration is BROKEN when you manually specify language May 8, 2021
@joshgoebel joshgoebel added discuss/propose Proposal for a new feature/direction and removed parser bug labels May 8, 2021
@CoconutMacaroon
Copy link

CoconutMacaroon commented Oct 8, 2024

Josh Wolsborn (Stack Overflow staff) posted this here. The post has been edited by Sonic the Anonymous Hedgehog.

The first proposed alternative has been implemented. A change has now been made so Highlight.js will no longer guess the language if the language provided by the user is not currently supported. The highlighting will defer to the default of lang-none in this case. If no language is provided by the user, Highlight.js will still attempt to guess the language based upon the syntax of the code block.

It should be noted that this change only impacts new posts and edited posts. Existing posts have not been rebaked to implement this change.

@joshgoebel
Copy link
Member Author

I'm happy enough with that fix. Marking this finally complete. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss/propose Proposal for a new feature/direction help welcome Could use help from community
Projects
None yet
Development

No branches or pull requests

2 participants