File: unicode.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 (46 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test2::V0;

use Test::Requires {
    'HTML::Differences' => 0,
};

use HTML::Differences qw( html_text_diff );
use Markdent::Simple::Fragment;

## no critic (InputOutput::RequireCheckedSyscalls)
binmode $_, ':encoding(UTF-8)'
    for map { Test::Builder->new->$_ }
    qw( output failure_output todo_output );
## use critic

my $text = <<"EOF";
# \x{1f600} smiley face

Unicode in span - <span class="foo">\x{1f600} smiley face</span> - works

<h2>\x{1f600} smiley face</h2>
EOF

my $simple = Markdent::Simple::Fragment->new;
my $got    = $simple->markdown_to_html( markdown => $text );

my $expect = <<"EOF";
<h1>\x{1f600} smiley face</h1>

<p>
Unicode in span - <span class="foo">\x{1f600} smiley face</span> - works
</p>

<h2>\x{1f600} smiley face</h2>
EOF

my $diff = html_text_diff( $got, $expect );
ok(
    !$diff,
    'got expected HTML containing Unicode characters as-is (not as entities)'
) or diag($diff);

done_testing;