Does the source code syntax highlighter support highlighting a subset of lines?
-
Hey Chris / other CP staff, I was wondering if there was a way to highlight a few lines from a source code block? A few WordPress plugins support it and it's quite handy when you want to call out modifications. The current alternative is to use line-numbers and then call that out (example : see lines 7 to 9).
Nish Nishant
-
Hey Chris / other CP staff, I was wondering if there was a way to highlight a few lines from a source code block? A few WordPress plugins support it and it's quite handy when you want to call out modifications. The current alternative is to use line-numbers and then call that out (example : see lines 7 to 9).
Nish Nishant
Looks like there's a workaround for this, and it's one I had used 10+ years ago. Also, I did work on the original syntax coloring code 20-ish years ago, not sure if the current version has any remnants from those days though. The workaround is to use
<span class='highlight'>
inside the<pre>
block.Example
class Program
{
static void Main()
{
Console.WriteLine("Sup?");
}
}Nish Nishant
-
Looks like there's a workaround for this, and it's one I had used 10+ years ago. Also, I did work on the original syntax coloring code 20-ish years ago, not sure if the current version has any remnants from those days though. The workaround is to use
<span class='highlight'>
inside the<pre>
block.Example
class Program
{
static void Main()
{
Console.WriteLine("Sup?");
}
}Nish Nishant
Hi Nish, It's lovely to see you active on the site. Every time I use <span class="hightlight"> in <pre> an article, it doesn't work. But if you let me know what part of your code you'd like highlighted in an article, I'd be happy to try again to see if this is still the case.
Thanks, Sean Ewington CodeProject
-
Hi Nish, It's lovely to see you active on the site. Every time I use <span class="hightlight"> in <pre> an article, it doesn't work. But if you let me know what part of your code you'd like highlighted in an article, I'd be happy to try again to see if this is still the case.
Thanks, Sean Ewington CodeProject
Thanks Sean. Yeah, after a bit of a break, I've resumed posting some content here. I did get it working. The trick is to be minimalistic in using it. Just highlight a few specific lines. If there are line-breaks in between, that seems to mess it up.
Nish Nishant
-
Thanks Sean. Yeah, after a bit of a break, I've resumed posting some content here. I did get it working. The trick is to be minimalistic in using it. Just highlight a few specific lines. If there are line-breaks in between, that seems to mess it up.
Nish Nishant
Thank you for the secret sauce! I will remember it for the future.
Thanks, Sean Ewington CodeProject