The counter intuitive removal of first newline immediately after the regular comment closing #}
The doc/templates.rst states: "... default removal of the first newline inherited from PHP".
What are you talking about? Where PHP removes the first newline? I cannot google up anything like such a newline removal of PHP.
I think, this "default removal of the first newline" should be removed both from the Lexer class and from the doc.
Yeah I never understood that sentence either. PHP as a language doesn't enforce anything about the first newline - it would not make any sense - and PHP as a runtime doesn't remove any line either - that would make even less sense.
https://3v4l.org/1YtvO
I get your point and I agree: PHP removes the first new line after a PHP tag, which is what Twig also does.
Note however that it does not inherit this behavior from PHP since Twig is not a subset of PHP. This is a deliberate choice from Twig maintainers. Actually I think this is inherited from Jinja, not PHP, since Twig is a Jinja subset, which syntax is inspired by Python.
Also note that Jinja documentation actually uses a more correct wording that Twig documentation - like instead of inherited from:
If an application configures Jinja to trim_blocks, the first newline after a template tag is removed automatically (like in PHP).
https://jinja.palletsprojects.com/en/stable/templates/#
@ericmorand feel free to send a PR to improve the wording of the documentation.