This is an archive of the discontinued LLVM Phabricator instance.

opt-viewer: Fix syntax highlighting
ClosedPublic

Authored by bcain on Feb 17 2017, 8:32 PM.

Details

Reviewers
anemet
fhahn
Summary

Syntax highlighting has been done line-at-a-time. Done this way, the lexer resets the context at each line, distorting the formatting.

This change will render the whole file at once and feed the highlighted text line-at-a-time to be wrapped by the SourceFileRenderer.

Leading/trailing newlines were being ignored by Pygments but since each line was rendered in its own row, it didn't matter. This bug was masked by the line-at-a-time algorithm. So now we need to add "stripnl=False" to the CppLexer to change its behavior to match the expectation.

Diff Detail

Repository
rL LLVM

Event Timeline

bcain created this revision.Feb 17 2017, 8:32 PM
anemet accepted this revision.Feb 17 2017, 11:24 PM

LGTM, thanks!

This revision is now accepted and ready to land.Feb 17 2017, 11:24 PM
bcain closed this revision.Feb 19 2017, 1:26 PM