PHP syntax highlighting without opening tag

Hello,

When using Markdown in Gitlab (Omnibus, version 8.2.2), PHP code is only syntax-highlighted when it starts with a PHP opening tag <?php,

I looked for help about this problem and found a bug report from last year, which was closed due to a syntax highlighting library change.

Could anyone tell me if there’s a fix for this now?

Currently, GitLab uses the rouge ruby library to highlight code and redcarpet to parse Markdown. There is a closed issue within the rouge project page to fix it, but it seems that is intended behaviour.

In order to get it working, you have to use the start_inline option provided by pygments:

``` php?start_inline=1
$foo = new Bar;
echo $foo->name();
```

This will produce this output:

$foo = new Bar;
echo $foo->name();

You can see it working in this snippet.

Hope this helps.

1 Like

Excellent, Felipe! Thank you.