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

Different styles on the same page #862

Closed
starikovs opened this issue Jun 2, 2015 · 5 comments
Closed

Different styles on the same page #862

starikovs opened this issue Jun 2, 2015 · 5 comments

Comments

@starikovs
Copy link

Hello,

Is it possible to use different styles on the same page? I want to specify style the same way that the language is specified:

<pre><code class="html solarized_dark">...</code></pre>

Thanks!

@isagalaev
Copy link
Member

Hi!

No, it won't work like that. We don't generate inline styling in the code blocks, instead we generate markup with pre-defined class names, like <span class="hljs-keyword">, and then rely on CSS to provide actual colors and styles for those.

It may be possible though to create a Web component for highlight.js that would use a scoped stylesheets for individual code blocks.

@starikovs
Copy link
Author

Ok, thanks for the explanation.

BTW, it could be done like this, for example in highlight.js/src/styles/solarized_dark.css:

.hljs-comment,
.solarized-dark .hljs-comment /* to override default */ {
  color: #586e75;
}

@Sannis
Copy link
Collaborator

Sannis commented Jun 3, 2015

We have some plans to generate stylesheets in uniform way, but only after #348.

@starikovs
Copy link
Author

Ok, that's cool :-)

@starikovs
Copy link
Author

BTW, there's a way to prefix styles if you with help of LESS:

.atelier-seaside-light {
  @import (less) 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/atelier-seaside.light.min.css';
}

As a result you'll get:

.atelier-seaside-light .hljs-comment {
  color: #687d68;
}
.atelier-seaside-light .hljs-variable,
...
.atelier-seaside-light .css .hljs-pseudo {
  color: #e6193c;
}
...

That works perfectly! :)

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

No branches or pull requests

3 participants