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

Remove hljs class from blocks of unhighlighted code #71

Merged
merged 1 commit into from
Apr 20, 2021
Merged

Remove hljs class from blocks of unhighlighted code #71

merged 1 commit into from
Apr 20, 2021

Conversation

valtlai
Copy link
Contributor

@valtlai valtlai commented Apr 19, 2021

The HTML spec recommends using a language-* class in the <code> element. Also, I don’t think there should be any class for a block of unhighlighted code.

(Original commit: aff30c3)

@oscarotero
Copy link
Member

Well, it is not exactly a recomendation, only an example.

hljs class is used by highlight syntax highlighting library and it's also a good way to select only pre elements containing hightlighted code (it would be a bit harder with a random variable classname like language-*.

I think a better approach is allow to customize this by the user. Something like:

site.use(markdown({
  config: {
      highlight(code, language) {
        //Here your custom code.
      }
  }
});

In fact, it should work like that, but I just realized that it doesn't because default options are applied after user options, so they are always overrided (https://github.com/lumeland/lume/blob/master/plugins/markdown.js#L43). We should change that.

@valtlai
Copy link
Contributor Author

valtlai commented Apr 19, 2021

Oh, that’s okay. Should we still remove the class from unhighlighted code?

@oscarotero
Copy link
Member

Mmm, maybe yes...?
It would break some existing styles in docs, but it's easy to fix.

@valtlai valtlai changed the title Add language-* class to <code> and remove hljs class Remove hljs class from blocks of unhighlighted code Apr 20, 2021
@valtlai
Copy link
Contributor Author

valtlai commented Apr 20, 2021

I repurposed this PR to just remove the hljs class from the block of unhighlighted code.

@oscarotero oscarotero merged commit c4246ae into lumeland:master Apr 20, 2021
@oscarotero
Copy link
Member

Thanks!

@valtlai valtlai deleted the code-block-class branch April 20, 2021 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants