File: filter-html.t

package info (click to toggle)
libpod-simple-perl 3.47-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,760 kB
  • sloc: perl: 7,073; xml: 2,427; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 973 bytes parent folder | download
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
use strict;
use warnings;

use Test::More;
use Pod::Simple::XHTML;

sub convert {
  my ($pod, $select) = @_;

  my $out = '';
  my $parser = Pod::Simple::XHTML->new;
  $parser->html_header('');
  $parser->html_footer('');
  $parser->output_string(\$out);
  $parser->set_heading_select(@$select);

  $parser->parse_string_document($pod);
  return $out;
}

sub compare {
  my ($in, $want, $select, $name) = @_;
  for my $pod ($in, $want) {
    if ($pod =~ /\A([\t ]+)/) {
      my $prefix = $1;
      $pod =~ s{^$prefix}{}gm;
    }
  }
  my $got = convert($in, $select);
  local $Test::Builder::Level = $Test::Builder::Level + 1;
  is $got, $want, $name;
}

compare <<'END_POD', <<'END_HTML', [ 'DESCRIPTION/guff' ];
  =head1 NAME

  NAME content

  =head2 welp

  welp content

  =head3 hork

  hork content

  =head1 DESCRIPTION

  DESCRIPTION content

  =head2 guff

  guff content

  =cut
END_POD
  <h2 id="guff">guff</h2>

  <p>guff content</p>

END_HTML

done_testing;