Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Partial line highlighting #19

Open
kmckee opened this issue Nov 17, 2018 · 2 comments
Open

Partial line highlighting #19

kmckee opened this issue Nov 17, 2018 · 2 comments

Comments

@kmckee
Copy link

kmckee commented Nov 17, 2018

Could we add support for partial line highlighting?

Suppose I had the following code block...

for(var i = 0; i<= 10; i++) {
}

I'd like to be able to highlight just the initializer (var i = 0;) using something like this:

<p class="fragment" data-code-focus="1" data-code-focus-columns="4-13">
  Commentary on initializer goes here
</p>
@kmckee
Copy link
Author

kmckee commented Nov 17, 2018

Or, perhaps the data-code-focus string just becomes a little more complex instead:

<p class="fragment" data-code-focus="1[4-13]">
  Commentary on initializer goes here
</p>

1[4-13] = Columns 4 thru 13 on row 1

@bnjmnt4n
Copy link
Owner

This seems like a useful feature - but we'll have to rework a lot of the internals and the CSS styling. Currently we just wrap each line with a <span>, and do minimal work on the HTML to avoid messing up highlight.js's own <span> tags. To enable selective highlighting of specific ranges, we'll have to figure out a clean and minimal method of detecting tags and opening them where necessary to avoid overlapping.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants