1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-01 00:35:06 +02:00

Ensure a newline exists at the end of files.

Fixes #42.
This commit is contained in:
Alec Thomas
2017-09-29 21:59:52 +10:00
parent 528bed2b60
commit 573c1d157d
13 changed files with 34 additions and 27 deletions

View File

@ -300,6 +300,9 @@ func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string) (Iterator,
if options == nil {
options = defaultOptions
}
if !r.config.DontEnsureNL && !strings.HasSuffix(text, "\n") {
text += "\n"
}
state := &LexerState{
Lexer: r,
Text: []rune(text),