Issue #4007 open

Parsing modelines for syntax highlighting (BB-4159)

Michał Górny
created an issue

One of my projects contains a C++ include file without a suffix (following the scheme used in standard C++ library). Thus, it is impossible to determine the correct syntax highlighting by filename and bitbucket fails to highlight it, as you can see here:

https://bitbucket.org/mgorny/libh2oxx/src/016ef53d5fe3/include/h2o

As you can see, the file ends with a vim modeline specifying the correct syntax. Maybe bitbucket could parse that in order to determine the language for syntax highlighting.

Comments (5)

  1. Dylan Etkin
    • changed status to open

    Hi Michal,

    We use Pygments to do our syntax highlighting. It will try to match on filename but then falls back to looking at the files contents to see if it can match the language based on some syntax rules.

    It would seem it is not picking up the syntax of your specific file.

    I will add this issue to our backlog but I will be honest, we are not likely to get to it anytime soon.

    Cheers,

    Dylan

  2. Michał Górny reporter

    Yes, I've seen information about that. To be honest, I am wondering whether I shouldn't try to get such a functionality into pygments directly. However, I am not sure if it wouldn't require passing a few last lines as well, as modelines are quite common there.

  3. Michał Górny reporter

    What's interesting here, I just found out that 'pygmentize -g' founds out the syntax correctly. It could be related to having an older version of pygments -- 1.4 gives a little weird output for me, while 1.5 works correctly.

  4. Log in to comment