Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 630
Rene Pot Avatar asked Jun 03 '13 10:06

Rene Pot


2 Answers

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.

like image 109
Francis Yaconiello Avatar answered Nov 16 '22 12:11

Francis Yaconiello


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
like image 4
Hugo Delsing Avatar answered Nov 16 '22 13:11

Hugo Delsing