Php code highlighting in Jekyll kramdown not working

I am using Jekyll with kramdown and pygments, it works 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 represents one range with a class x

:

<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 don't I have tokens with different classes for php code?

+3


source to share


2 answers


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

{% highlight php startinline=true %}

      



See Pigments Documentation

+8


source


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

We no longer support Pyigs. We are using Rouge.



The new syntax looks like this:

```php?start_inline=true

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

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

```

      

+2


source







All Articles