3

I'm using Jekyll with kramdown and pygments, it work fine for javascript or python code but When I create php like:

{% highlight php %}
header('Content-Type: application/json');

echo json_encode(array(
    'jsonrpc' => "2.0",
    'result' => $result,
    'id' => $request->id,
    'error' => null
));
{% endhighlight %}

Each line is one span with x class:

<code class="language-php" data-lang="php"><span class="x">header('Content-Type: application/json');</span>
<span class="x">echo json_encode(array(</span>
<span class="x">    'jsonrpc' =&gt; "2.0",</span>
<span class="x">    'result' =&gt; $result,</span>
<span class="x">    'id' =&gt; $request-&gt;id,</span>
<span class="x">    'error' =&gt; null</span>
<span class="x">));</span></code>

Why I don't have tokens with different classes for php code?

jcubic
  • 61,973
  • 54
  • 229
  • 402

2 Answers2

8

If you want to forget the php opening tag at the beginning of you code block, you have to set the Pygments startinline parameter to true.

{% highlight php startinline=true %}

See Pygments documentation

David Jacquel
  • 51,670
  • 6
  • 121
  • 147
2

As of Aug 8, 2016, From https://github.com/jekyll/jekyll/issues/1633#issuecomment-238383509

We don't support Pygments anymore. We use Rouge.

The new syntax is as follows:

```php?start_inline=true

header('Content-Type: application/json');

echo json_encode(array(
    'jsonrpc' => "2.0",
    'result' => $result,
    'id' => $request->id,
    'error' => null
));

```
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • Unfortunately it does not work. The ```php?start_inline=true``` is printed within the code block. – JCarlosR Apr 15 '17 at 14:35
  • @JCarlos you must have some other plugins interfering. Try the default jekyll example on gitlab pages https://gitlab.com/pages/jekyll – Jeff Puckett Apr 15 '17 at 15:41
  • I don't remember me adding plugins. And my project doesn't have a ```_plugins``` folder. Can I use the Gitlab example in Github pages? Thank you. – JCarlosR Apr 15 '17 at 16:46