Compare commits

...

2 Commits

Author SHA1 Message Date
f6d87eb878 test: add regression test 2026-02-19 17:53:25 +01:00
b2969d8f47 fix(parser): close fenced code blocks at EOF 2026-02-19 17:53:14 +01:00
2 changed files with 7 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ my %CLOSING_TAGS = (
olist => "</ol>", olist => "</ol>",
blockquote => "</blockquote>", blockquote => "</blockquote>",
table => "</table>", table => "</table>",
code_block => "</code></pre>",
); );
sub new { sub new {
@@ -166,7 +167,6 @@ sub handle_code_block_line {
my ( $self, $line ) = @_; my ( $self, $line ) = @_;
if ( $line =~ /^```/ ) { if ( $line =~ /^```/ ) {
$self->{output} .= "</code></pre>\n";
$self->transition_to_state('paragraph'); $self->transition_to_state('paragraph');
} }
else { else {

View File

@@ -2,7 +2,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 6;
use MarkdownParser; use MarkdownParser;
my $parser = MarkdownParser->new(); my $parser = MarkdownParser->new();
@@ -32,4 +32,8 @@ is(
"<pre><code>\n</code></pre>\n", "<pre><code>\n</code></pre>\n",
"Empty code block" "Empty code block"
); );
is(
$parser->parse("```\nunterminated"),
"<pre><code>\nunterminated\n</code></pre>\n",
"Unclosed code block is closed at EOF"
);