HomePhabricator

Fix an issue with highlighting PHP snippets with leading whitespace using XHPAST

Description

Fix an issue with highlighting PHP snippets with leading whitespace using XHPAST

Summary:
Ref T10576. In the test case there, XHPAST has incorrectly emitted an extra newline at the top of the output.

This cascades downward and throws every line off by one, highlighting the wrong lines in the output.

Fix this issue by stripping the prefix more carefully, so the input source is preserved accurately.

Test Plan:

  • Added tests; ran tests.
  • Verified that the snippet now highlights correctly.

Screen Shot 2016-03-13 at 7.05.29 AM.png (890×2 px, 195 KB)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10576

Differential Revision: https://secure.phabricator.com/D15469