Fix lexer list parsing on Windows

When using a non-bundled Pygments (which is required on Windows, as the
bundled version is an ELF binary), we call into the Pygments executable
to generate the list of supported languages (lexers). This list seems to
occasionally include carraige returns, causing some languages to not be
processed correctly. Trim those CRs out so the language list is
accurate.

Bug: T336087
Change-Id: If8b1f145dd10e2c4707d6d32927e85d1d2459f15
(cherry picked from commit 2ae82c7fb7)
This commit is contained in:
Ryan Schmidt 2022-11-20 22:46:55 -07:00 committed by Reedy
parent e5a9cd32d3
commit 90bf39a264

View file

@ -211,7 +211,7 @@ class Pygmentize {
$lexers = [];
foreach ( explode( "\n", $output ) as $line ) {
if ( substr( $line, 0, 1 ) === '*' ) {
$newLexers = explode( ', ', trim( $line, "* :\n" ) );
$newLexers = explode( ', ', trim( $line, "* :\r\n" ) );
// Skip internal, unnamed lexers
if ( $newLexers[0] !== '' ) {