Allow for no prefix in the comment filter (#17421)
In the 'comment' filter, if the 'prefix' parameter is set as empty, don't add an empty line before the comment. To get the previous behaviour (empty line before comment), set the prefix to '\n'.
This commit is contained in:
parent
23f78efd74
commit
f5a4677680
1 changed files with 8 additions and 2 deletions
|
@ -336,8 +336,14 @@ def comment(text, style='plain', **kw):
|
||||||
str_beginning = ''
|
str_beginning = ''
|
||||||
if p['beginning']:
|
if p['beginning']:
|
||||||
str_beginning = "%s%s" % (p['beginning'], p['newline'])
|
str_beginning = "%s%s" % (p['beginning'], p['newline'])
|
||||||
str_prefix = str(
|
str_prefix = ''
|
||||||
"%s%s" % (p['prefix'], p['newline'])) * int(p['prefix_count'])
|
if p['prefix']:
|
||||||
|
if p['prefix'] != p['newline']:
|
||||||
|
str_prefix = str(
|
||||||
|
"%s%s" % (p['prefix'], p['newline'])) * int(p['prefix_count'])
|
||||||
|
else:
|
||||||
|
str_prefix = str(
|
||||||
|
"%s" % (p['newline'])) * int(p['prefix_count'])
|
||||||
str_text = ("%s%s" % (
|
str_text = ("%s%s" % (
|
||||||
p['decoration'],
|
p['decoration'],
|
||||||
# Prepend each line of the text with the decorator
|
# Prepend each line of the text with the decorator
|
||||||
|
|
Loading…
Reference in a new issue