Compare commits
4 Commits
11af6d0511
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b1e822580 | |||
| 2e226eb7cb | |||
| f6d87eb878 | |||
| b2969d8f47 |
@@ -30,7 +30,7 @@ chmod +x m2h.pl
|
|||||||
Convert a markdown file to HTML:
|
Convert a markdown file to HTML:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
perl -Ilibm2h.pl input.md > output.html
|
perl -Ilib m2h.pl input.md > output.html
|
||||||
```
|
```
|
||||||
|
|
||||||
Or read from stdin:
|
Or read from stdin:
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
2
m2h.pl
2
m2h.pl
@@ -1,4 +1,4 @@
|
|||||||
#!perl -w
|
#!/usr/bin/env perl -w
|
||||||
use strict;
|
use strict;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use MarkdownParser;
|
use MarkdownParser;
|
||||||
|
|||||||
@@ -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"
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user