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

  • SEARCH
  • Home
  • 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 7005005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:16:24+00:00 2026-05-27T21:16:24+00:00

I am using the Syntax Highlighter built with Javascript by Alex Gorbatchev (http://alexgorbatchev.com/SyntaxHighlighter/download/) The

  • 0

I am using the Syntax Highlighter built with Javascript by Alex Gorbatchev (http://alexgorbatchev.com/SyntaxHighlighter/download/)

The Javascript has separate “brush” js file for each language that it has syntax support for, these brush file are just regex for all the syntax matching for that particular language, it matches items and then wraps them in CSS classes.

Currently the PHP brush file matches pretty much everything but lacks 1 thing, PHPDoc comment variables.

/**
* @author Jason Davis
* @copyright 2011
*/

the @author and @copyright are what I am talking about in this example.

So I now have some regex that will match these however it is not working because the current comment regex is stopping it…

Here is a snippet of the regex code that matches the PHP comments

SyntaxHighlighter.brushes.Php = function ()
{
    this.regexList = [

        // Multi Line Comments
        { regex: /\/\*[\s\S]*?\*\//gm,
            css: 'php-comment comments' },

        // More regex for all the other stuff is below here.......
    ];
};

Now if I add in my NEW code for PHPDoc comment variables…

// PHPDoc Comment Variables (ie @author)
{ regex: /@[a-z]+/g,
    css: 'php-phpdoc phpdoc' }

It will not work, even though my new regex works. If I disable the comment regex above my new code then it works and wraps my PHPDoc comment variables with the CSS class.

So I am thinking, maybe if I can modify my PHPDoc regex to rest inside of a comment regex maybe that would work? IF you have any ideas or can help I could really use it and appreciate it


UPDATE

I think I found the code that is preventing it from working…
My code is nested inside of a Comment match and this code’s note says that it prevents this, maybe this can be modified to allow my PHPDoc to remain nested instead of removing it

It is found here https://github.com/alexgorbatchev/SyntaxHighlighter/blob/master/scripts/shCore.js on line 1318

/**
 * Checks to see if any of the matches are inside of other matches. 
 * This process would get rid of highligted strings inside comments, 
 * keywords inside strings and so on.
 */
removeNestedMatches: function(matches)
{
    // Optimized by Jose Prado (http://joseprado.com)
    for (var i = 0; i < matches.length; i++) 
    { 
        if (matches[i] === null)
            continue;

        var itemI = matches[i],
            itemIEndPos = itemI.index + itemI.length
            ;

        for (var j = i + 1; j < matches.length && matches[i] !== null; j++) 
        {
            var itemJ = matches[j];

            if (itemJ === null) 
                continue;
            else if (itemJ.index > itemIEndPos) 
                break;
            else if (itemJ.index == itemI.index && itemJ.length > itemI.length)
                matches[i] = null;
            else if (itemJ.index >= itemI.index && itemJ.index < itemIEndPos) 
                matches[j] = null;
        }
    }

    return matches;
},
  • 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-27T21:16:25+00:00Added an answer on May 27, 2026 at 9:16 pm

    You could match a @foo string inside of a comment block by asserting that a */ will follow it (and do so before any following /* appears):

    regex: /@[a-z]+\b(?=(?:(?!\/\*)[\s\S])*\*\/)/g
    

    Explanation:

    @[a-z]+     # Match a PHPDoc comment variable.
    \b          # Assert position at the end of the variable.
    (?=         # Assert that the following can be matched from here:
     (?:        # Try to match...
      (?!       #  (unless the next thing that follows is...
       \/\*     #  /* )
      )         #  (end of negative lookahead)
      [\s\S]    #  any character
     )*         # any number of times
     \*\/       # until a */ occurs.
    )           # (end of positive lookahead)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a javascript syntax highlighter ( http://alexgorbatchev.com/SyntaxHighlighter/ ). I think this one is
Im using the js SyntaxHighlighter 3.0.83 from http://alexgorbatchev.com/SyntaxHighlighter/ I've been googling the entire world
I'm using a content-editable iframe to create a syntax-highlighter in javascript and one of
Does anyone know of any C# syntax highlighter plugins for Confluence? Using the default
What syntax highlighter is GitHub using on their site to display the code when
Is there a good php syntax highlighter for Emacs? I'm using Emacs 23. I've
I am using these 2 plugins: HTML Page Sitemap http://wordpress.org/extend/plugins/html-sitemap/installation/ SyntaxHighlighter Evolved http://wordpress.org/extend/plugins/syntaxhighlighter/ When
I am creating a in browser HTML editor. I am using the syntax highlighter
I'm trying to use Syntax Highlighter with my blog at http://a.shinynew.me . This is
I am using the Syntax highlighter library to display code on a webpage. I

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.