Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5847439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:43:07+00:00 2026-05-22T12:43:07+00:00

I am using the Syntax highlighter library to display code on a webpage. I

  • 0

I am using the Syntax highlighter library to display code on a webpage. I would like to highlight certain sections of code in response to various events on the page. It may be a single character, or a multiple line section, but it will always be a contiguous section of text.

I know that SyntaxHighlighter has functionality to highlight individual lines, but I need a little more fine grained control than that.

I know the selection start and selection length points in the original source code, but the highlighter has inserted a lot of html elements, so it is a bit difficult to find those indexes again to wrap them in another tag.

Is there a good way I can override existing formatting, and apply my own css to a specific portion of the text? Is there a different syntax highlighting plugin that may give me what I need?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:43:08+00:00Added an answer on May 22, 2026 at 12:43 pm

    How about running the generated markup through a function that searches and replaces the specific ‘programmatic word’ with,

    <span class="customHighlight">word</span>
    

    ..and you can style it as follows,

    span.customHighlight {
      background:#FAFAD2;
      color:#000;
    }
    

    I sort of worry about the efficiency of this though.

    EDIT: I’ve got something, if you look at the source of the script relative to the highlighter for a language (here, CSS), http://alexgorbatchev.com.s3.amazonaws.com/pub/sh/3.0.83/scripts/shBrushCss.js,

            { regex: /!important/g,
              css: 'color3' },  // !important
    

    ..which renders as,

    <code class="css color3">!important</code>
    

    ..so, just define your ‘word’ as a rule with an equivalent CSS declaration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the syntax highlighter plugin and I want to always have it
I would like to ask is there any software or script able to do
I am using syntax checking to see whether my Perl script is being used
I have a file that contains parameters using this syntax RANGE {<value> | <value>-<value>}
I am trying to convert the following SQL into Subsonic syntax using the SqlQuery
Like lots of you guys on SO, I often write in several languages. And
I have been recently working on an easy to use Syntax Highlighting system for
I was wondering if there was a tag that auto-highlights the syntax of HTML
Say, I have a script nicely formatted in SSMS and it's annotated with all
I maintain a Django project with a database that has several model constraints that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.