Highlighting using NullFormatter and TextLexer adds new line character

Issue #492 resolved
Former user created an issue

Hi, I have tried to highlight code that does not end with a new line, using pygments.highlight in combination with the NullFormatter and the TextLexer. I have expected this to be a no-operation, yet the formatted text unexpectingly ends with a new line character! I am not completely sure whether this behaviour is a bug or an intended feature. I will attach a unit test describing the setup.

(Pygments version 1.0, Python 2.6.4)

Reported by lts4life

Comments (2)

  1. gbrandl

    Yes, adding the newline is intended since many line-based lexers rely on the text ending in a newline. If it is essential that no newlines are added, use the (fairly new) "ensurenl=False" lexer option.

  2. Log in to comment