Remark: Ability to highlight selected line(s) in source code

Created on 6 May 2014  路  9Comments  路  Source: gnab/remark

It would be useful to provide a way to highlight selected line(s) in source code to pay audience attention on specific aspect(s).

Most helpful comment

Ok after digging through the code a bit I found that this has to be enabled manually using

      var slideshow = remark.create({
        highlightLines: true
      });

then it works. Leaving it here for anyone else who gets stuck. Thanks!

All 9 comments

I agree. Were you thinking like clicking to toggle highlighting on a per-basis for instance?

Although it could be sometimes useful to toggle highlighting with clicking on the line in the basic case I thought just about static source code and the ability to highlight selected lines in markdown code. Maybe (as an additional feature) it could be merged into a template engine to allow highlight line(s) on the next slide with minimal content duplication.

With the change I've added now, code lines are wrapped in <div class="remark-code-line">...</div>, and if a line has a leading *, it is trimmed and the remark-code-line-highlighted class is added as well.

Example code block snippet:

``````

function add (a, b) {
*  return a + b;
}

``````

The default styling makes the line be yellow with .5 opacity (rgba(255, 255, 0, 0.5)), and can easily be overridden by defining a background for the remark-code-line-highlighted class.

This will be included in the upcoming version 0.6.5.

0.6.5 has now been released.

Highlighting demo: http://jsfiddle.net/96Sws/1/

@gnab, your are really fast, thanks!

I'd like to ask a question.

Is there a way to turn this feature off temporarily?

Sometimes I really need a leading * in my code section. For example,


git branch demo

$ git branch
* master

Thank you!

Currently not, but I'll make it configurable.

Has this feature been disabled now? The demos are not working. How do I bring it back?

Ok after digging through the code a bit I found that this has to be enabled manually using

      var slideshow = remark.create({
        highlightLines: true
      });

then it works. Leaving it here for anyone else who gets stuck. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pinkomeo picture pinkomeo  路  4Comments

anaderi picture anaderi  路  5Comments

peterj picture peterj  路  6Comments

jklymak picture jklymak  路  8Comments

stephentu picture stephentu  路  5Comments