A PHP snippet is not highlighted unless starts with <?php.

Create issue
Issue #1012 resolved
Filippo Fadda created an issue

A PHP snippet is not highlighted unless starts with <?php, even providing the right lexer name with the option -l. I think the snippet should be highlighted according to the specified lexer (the language), in any case, because, as you know, not always the user includes the open tag.

This is not highlighted:

class Doc {
  private $id;

  public function setId($value) {
    $this->id = $value;
  }
}

This snippet instead it is:

<?php

class Doc {
  private $id;

  public function setId($value) {
    $this->id = $value;
  }
}

Comments (4)

  1. Tim Hatch

    This is the intended behavior, there's an option called 'startinline' that does what you want if you're the user of Pygments directly.

  2. Log in to comment