File: HTMLFilter.t

package info (click to toggle)
libmarkdent-perl 0.40-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,368 kB
  • sloc: perl: 5,225; sh: 24; makefile: 13
file content (73 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
use warnings;

use FindBin qw( $Bin );
use lib "$Bin/../../t/lib";

use Data::Dumper;
use Markdent::Handler::HTMLFilter;
use Markdent::Handler::MinimalTree;
use Markdent::Parser;
use Test2::V0;
use Test::Markdent;

{
    my $html = <<'EOF';
EOF

    my $text = <<"EOF";
Some text

<div>
  <p>
    An arbitrary chunk of html.
  </p>
</div>

<!-- a comment -->

Some <span>inline</span> HTML.
EOF

    my $expect = [
        {
            type => 'paragraph',
        },
        [
            {
                type => 'text',
                text => "Some text\n",
            },
        ], {
            type => 'paragraph',
        },
        [
            {
                type => 'text',
                text => 'Some ',
            }, {
                type => 'text',
                text => 'inline',
            }, {
                type => 'text',
                text => " HTML.\n",
            },
        ],
    ];

    my $mt     = Markdent::Handler::MinimalTree->new();
    my $filter = Markdent::Handler::HTMLFilter->new( handler => $mt );

    my $parser = Markdent::Parser->new( handler => $filter );

    $parser->parse( markdown => $text );

    my $results = tree_from_handler($mt);

    diag( Dumper($results) )
        if $ENV{MARKDENT_TEST_VERBOSE};

    is( $results, $expect, 'all HTML events have been dropped' );
}

done_testing();