Possible to turn off highlighting or have something like class=text?

47 views
Skip to first unread message

Eduard Bardají Puig

unread,
Aug 20, 2016, 3:31:57 PM8/20/16
to highlight.js
I am currently writing my blog using markdown and auto-generating html code using pandoc. The classes on the html code snippets get assigned correctly. However, there are snippets that are not code, yet useful to be presented in the same fashion as code snippets, such as console logs or function signatures.

Is it possible to tell highlight.js to **not** highlight blocks of code that have no class assigned to them, yet preserve the same general CSS asthetics? That is, having something like class=txt or class=text? or just having it automatically style that block of code with the same theme without any of the colors?

Thanks!

Ivan Sagalaev

unread,
Aug 20, 2016, 8:09:10 PM8/20/16
to highl...@googlegroups.com
You want `class="nohighlight hljs"`

- `nohighlight` disables highlighting (it's documented in the readme, by
the way)
- `hljs` will pick up the basic block styling from the style you're using

Eduard Bardají Puig

unread,
Aug 20, 2016, 8:31:53 PM8/20/16
to highlight.js
Hi Ivan,

I did read the docs and do know of `nohighlight`, however, I was trying to mark my markdown code snippets in a more "coloring-framework-agnostic way". That is, it detracts from the simplicity of markdown to have code snippets labeled as "```nohilight" and ties that particular markdown to the expectation of it being processed by hilight.js, unlike leaving off the language, like "```" or have a more generic descriptor such as "```text".

If I were writing pure html, that would not be an issue, but since I'm auto-generating the html, it is not practical to manually edit the class tags, not to mention error prone.

Any suggestions on solutions that would allow me to keep the markdown code clean?

On a side note, how hard would it be to add detection of "text" class that, as I understand, would work as like "nohilight hljs"?

Thanks!

Ivan Sagalaev

unread,
Aug 20, 2016, 9:27:54 PM8/20/16
to highl...@googlegroups.com
We actually have "text", "plain", "nohighlight" and "no-highlight" all
working as synonyms. Changing the semantics of "text" would be backwards
incompatible.

But you can achieve what you want in other ways too. You could simply
mimic the styling in your own stylesheet or you could use additional
scripting to add the "hljs" class to "text" elements.

Eduard Bardají Puig

unread,
Aug 20, 2016, 9:34:14 PM8/20/16
to highl...@googlegroups.com
Ok, thanks for the tips :)

--
You received this message because you are subscribed to a topic in the Google Groups "highlight.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/highlightjs/czxfkpTSRgs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to highlightjs...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages