Browse Source

Markdown.pl: remove following \n with comment

When `--strip-comments` is active, if an XML comment is
immediately followed by optional spaces and/or tabs and
a newline, remove those along with the comment itself.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
master
Kyle J. McKay 4 years ago
parent
commit
c2f72b71a4
  1. 8
      Markdown.pl

8
Markdown.pl

@ -2689,7 +2689,13 @@ sub _SanitizeTags {
my $tstart = pos($text);
if ($text =~ /\G(<!--(?:[^-]|(?:-(?!-)))*-->)/gc) {
# pass "comments" through unless stripping them
$ans .= $1 unless $opt{stripcomments};
if ($opt{stripcomments}) {
# strip any trailing whitespace + \n after comment if present
$text =~ /\G[ \t]*\n/gc;
} else {
# pass the "comment" on through
$ans .= $1;
}
next;
}
if ($text =~ /\G(<[^>]*>)/gc) {

Loading…
Cancel
Save