question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Highlight.JS Inline Code Syntax Highlightning

See original GitHub issue

Highlight.js is a great highlightning tool. But now i want to know if it is also possible to make inline highlighting, so not like a block (like at http://tekkkz.com/posts/articles/arch_installation.html) but inside a text paragraph?

If it is possible, how?


The answer, for version 11 and up.

If using version 11 or newer of highlight.js you can use the following to also highlight <code> elements.

hljs.config({ cssSelector: 'code' });;
hljs.highlightAll();

Otherwise, check our README (this can be done with just a few lines of code) or skim below for possibly more specific examples.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
tylerlongcommented, Oct 20, 2015

Problem is:

.hljs {
    display: block;
}

The code won’t be displayed as inline.

Solution is to add the following to your css code:

pre code.hljs {
  display: block;
}

code.hljs {
  display: inline;
}
2reactions
joshgoebelcommented, May 9, 2021

Sounds like a Prismatic problem, maybe. I feel users should actually know and understand their setup and how they are altering it. Far too much harm comes from from people copying and pasting code they don’t understand from one box to another. Perhaps you’ve never been “that user” yet though. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

highlight.js inline mode possible? - Stack Overflow
Since your inline markup is in a <span> tag, that is, the hierarchy is span code , you can achieve inline highlighting with...
Read more >
How to use highlight.js
You can run highlighting inside a web worker to avoid freezing the browser window while dealing with very big chunks of code. In...
Read more >
Syntax Highlight Guide | Visual Studio Code Extension API
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords...
Read more >
Upgrading to Highlight.js v11.0
github includes significant changes to more properly match modern GitHub syntax highlighting. If you desire the old theme you can manually copy it...
Read more >
Is Inline Code Syntax Highlighting Possible - R Markdown
shell is a supported class in highlight.js but not by pandoc's highlighter. Also, since I'm using blogdown, it uses highlight.js by default. How ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found