Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - inline PHP #80

Closed
martinbdz opened this issue Oct 26, 2017 · 1 comment
Closed

Feature request - inline PHP #80

martinbdz opened this issue Oct 26, 2017 · 1 comment

Comments

@martinbdz
Copy link

Currently it is not possible to highlight PHP code that does not start with either <?php or <?. Pygments has the option startinline to indicate this exact case. Would it be possible for chroma to support a similar feature? This is essential for PHP snippet highlighting.

I am happy to provide a PR and already had a quick look at the code. One solution might be to change the starting state in the TokeniseOptions for the Tokenise function from "root" (the default) to "php" in the client application. This inline starting rule could be a new configuration parameter in the lexer. It would not change the external API much but would still provide a relatively easy and generalized way of dealing with such cases.

@alecthomas
Copy link
Owner

Yes, this is definitely something I'd like to support. I have some code that is somewhat working. Pygments uses a DelegatingLexer to implement this feature. The logic to achieve this is actually quite complex, so my code isn't working correctly yet, and I haven't had the time to debug it.

If you'd like to take a crack at it, I'd be happy to accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants