Rene Pot
Rene Pot

Reputation: 24815

How to syntax highlight PHP in the Github Wiki

So, I know how to do color coding in the github wiki. For example json:

```json
  {}
````

But for PHP this doesn't work

```php
// code here
```

I'll have to do this:

```
<?php
// code here
```

Or this: php <?php // code here

Which looks ugly, because you'll see the <?php in every block of code. Is there a way around this?

Upvotes: 13

Views: 4382

Answers (2)

Francis Yaconiello
Francis Yaconiello

Reputation: 10919

I've encountered this problem before as well. if you use: ```php it isn't enough. it requires a php open block <?php before it starts code highlighting. Its cross browser and is a pygments setting on the github servers. Put a ticket in on github.

Pygments has a "startinline" option which is only relevant for the PhpLexer. It allows syntax highlighting without the opening

You can view the Pygments documentation on it here: http://pygments.org/docs/lexers/ Search the page for startinline to jump right to it.

startinline

If given and True the lexer starts highlighting with php code (i.e.: no starting <?php required). The default is False.

Upvotes: 18

Hugo Delsing
Hugo Delsing

Reputation: 14163

As you can see in this list, that is compiled from this pygments list, you should be able to use ```php without problems. If it doesnt work, try one of the following

  • ```php
  • ```php3
  • ```php4
  • ```php5
  • ```css+php
  • ```html+php
  • ```js+php
  • ```xml+php

Upvotes: 4

Related Questions