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 8740807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:11:48+00:00 2026-06-13T11:11:48+00:00

SyntaxHighlighter displays lines without linebreaks. Long lines are display in one line and a

  • 0

SyntaxHighlighter displays lines without linebreaks. Long lines are display in one line and a horizontal scrollbar is added to the container.

I don’t want that scrollbar and I’m able to force line breaks in SyntaxHighlighter with some enforcing but simple CSS rules.

The problem is that content and line numbers are not displayed in the same container and therefor the line numbers won’t match the right lines if lines get split that way.

Is there any chance to get it working without to much trouble? Any ideas welcome..!

  • 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-06-13T11:11:49+00:00Added an answer on June 13, 2026 at 11:11 am

    This is the way I finally did it:

        // return a jQuery object listing all highlighted lines as divs
                // sh: SyntaxHighlighter
                // alias: brush alias
                // content: the code to highlight
        getHighlightedLines = function (sh, alias, content) {
    
            var brushes = sh.vars.discoveredBrushes,
                Brush, brush;
    
            if (!brushes) {
                brushes = {};
    
                _.each(sh.brushes, function (info, brush) {
    
                    var aliases = info.aliases;
    
                    if (aliases) {
                        info.brushName = brush.toLowerCase();
    
                        for (var i = 0; i < aliases.length; i += 1) {
                            brushes[aliases[i]] = brush;
                        }
                    }
                });
    
                sh.vars.discoveredBrushes = brushes;
            }
    
            Brush = sh.brushes[brushes[alias || 'plain']];
    
            if (!Brush) {
                return $();
            }
    
            brush = new Brush();
            brush.init({toolbar: false, gutter: false});
    
            return $(brush.getHtml(content)).find('.line');
        },
    

    use it like this:

    var $table = $('<table/>');
    
    getHighlightedLines(sh, settings.types[current.type], content).each(function (i) {
        $('<tr/>')
            .append($('<td/>').addClass('nr').append(i + 1))
            .append($('<td/>').addClass('line').append(this))
            .appendTo($table);
    });
    

    now you have line numbers and line content on the same row, even if code gets wrapped. Anything else can be done with CSS.

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

Sidebar

Related Questions

As is asked and answered in this post , one can use SyntaxHighlighter for
I'm using a javascript syntax highlighter ( http://alexgorbatchev.com/SyntaxHighlighter/ ). I think this one is
In SyntaxHighlighter , is it possible to highlight lines with different colors (say, some
I am using the Syntax highlighter library to display code on a webpage. I
Im using the js SyntaxHighlighter 3.0.83 from http://alexgorbatchev.com/SyntaxHighlighter/ I've been googling the entire world
I'm having some problems with the BBCode I created to use with the SyntaxHighlighter
I'm trying to post-process content that is added to the DOM via the excellent
I am using SyntaxHighlighter on my website and it is acting very strange. I
I've just started using SyntaxHighlighter . I looked at their HTML source code for
Looking at some sample javascript code at http://alexgorbatchev.com/SyntaxHighlighter/manual/api/autoloader.html I see: <script src=shCore.js type=text/javascript></script> <script

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.