moinwiki / moin-1.9

MoinMoin Wiki (1.9, also: 1.5a ... 1.8), stable, for production wikis
https://moinmo.in/
Other
140 stars 51 forks source link

bash lexer: don't include final newline in single line comments. #86

Closed emanuele6 closed 2 years ago

emanuele6 commented 2 years ago

Since the final newline character was included in Comment.Single, code blocks that ended in a comment like the following

{{{#!highlight bash
echo hello # this command writes "hello" to stdout
}}}

were getting an extra line at the end.

Using a lookhead assertion instead of matching \n literally fixed the issue.


before applying this patch: without_patch

after applying this patch: with_patch

emanuele6 commented 2 years ago

I have noticed that this also needs to be changed in the regular expression for Comment.Hashbang; otherwise, the following code block still gets an extra newline:

{{{#!highlight bash
#!/bin/bash
}}}
ThomasWaldmann commented 2 years ago

This file is from the pygments project.

As most other files in the support directory, we just use them "as is". Any changes / fixes have to be done upstream, so please contribute this to the pygments FOSS project.