rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

Support attributes in PHP lexer #1915

Closed tancnle closed 1 year ago

tancnle commented 1 year ago

This PR adds highlight for PHP Attributes.

Screenshot 2023-01-18 at 12 14 32 am

Resolves https://github.com/rouge-ruby/rouge/issues/1759

d9beuD commented 2 months ago

Hey @tancnle, nice work you did here! Wouldn't be great to have syntax highlight inside PHP attributes like VSCode does?

By the way, if an attribute is multiline (see example bellow), it identifies the attribute class name as a function name.

#[ApiResource(
    operations: [
        new GetCollection(),
        new Post(processor: UserPasswordHasher::class, validationContext: ['groups' => ['Default', 'user:create']]),
        new Get(
            uriTemplate: '/users/me',
            security: "is_granted('ROLE_USER') and object == user",
            provider: CurrentUserProvider::class,
            openapi: new Operation(
                summary: 'Retrieves the current user',
            )
        ),
    ],
)]