Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Site Bugs / Suggestions
  4. Does the source code syntax highlighter support highlighting a subset of lines?

Does the source code syntax highlighter support highlighting a subset of lines?

Scheduled Pinned Locked Moved Site Bugs / Suggestions
phptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • N 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

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • N 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

        S Offline
        S Offline
        Sean Ewington
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • S Sean Ewington

          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

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • N 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

            S Offline
            S Offline
            Sean Ewington
            wrote on last edited by
            #5

            Thank you for the secret sauce! I will remember it for the future.

            Thanks, Sean Ewington CodeProject

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups