1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #9501 open

Pygments is terrible at properly detecting and/or highlighting Javascript (BB-10687)

Niels
created an issue

Javascript syntax highlighting seems broken in the source viewer, for the following lines:

var matches = body.match(/name='csrfmiddlewaretoken' value='([^']+)'/);

And

var downloadLinkMatch = body.match(new RegExp('<a href="([^"]+)">'+filename+'</a>'));

As seen in http://i.imgur.com/sMPuKNl.png line 72 and 113.

Comments (5)

  1. Jonathan Mooring staff

    If you specify javascript as the language for your code block, it should render correctly.

    var matches = body.match(/name='csrfmiddlewaretoken' value='([^']+)'/);
    
    var downloadLinkMatch = body.match(new RegExp('<a href="([^"]+)">'+filename+'</a>'));
    

    You can do this like so:

        ```javascript
        var matches = body.match(/name='csrfmiddlewaretoken' value='([^']+)'/);
        ```
    
  2. Niels reporter

    This isn't about a code block, it's the source browser. As far as I can see, there are no options to set the source language. See attached screenshot in my original post.

  3. Addison Miller

    Same issue with...

    app.directive('capitalizeFirst', ['$parse', function($parse) {
        return {
            require: 'ngModel',
            link: function(scope, element, attrs, modelCtrl) { }
        }
    }]);
    

    Shouldn't Pygments consider the file extension?

  4. Log in to comment