summaryrefslogtreecommitdiffstats
path: root/t/fmt-txt-markdown.t
blob: dcc2347058f14e0d642a46433df93ce7833097c5 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
# Text module tester.

#########################

use strict;
use warnings;

use lib q(t);
use Testhelper;

my @tests;

# Generic tests

foreach my $t (qw(Basic Rules)) {
    push @tests, { 'format' => 'text', 'options' => '-o markdown', 'input' => "fmt/txt-markdown/$t.md" };
}

push @tests,
  {
    'format'  => 'text',
    'options' => "-o markdown --master-charset UTF-8 --wrap-po=newlines -o neverwrap",
    'input'   => "fmt/txt-markdown/NoWrap.md",
  },
  {
    'format'  => 'text',
    'options' => '-o markdown',
    'input'   => "fmt/txt-markdown/NestedLists.md",
  },
  {
    'doc'     => "Rewrap output of a Markdown file to the given width",
    'format'  => 'text',
    'options' => '-o markdown -w 40',
    'input'   => "fmt/txt-markdown/Width.md",
    'skip'    => { 'updatepo' => 1 }
  };

# Some tests specific to the Pandoc dialect of Markdown
# In particular regarding the headers

foreach my $pandoc (
    qw(HeaderTitle HeaderTitleMultilines HeaderTitleAuthors HeaderTitleDate HeaderOnlyAuthor HeaderTitleMultipleAuthors
    FencedCodeBlocks)
  )
{
    push @tests, { 'format' => 'text', 'options' => '-o markdown', 'input' => "fmt/txt-markdown/Pandoc$pandoc.md" };
}

# Some tests around the YAML Front Matter feature

push @tests,
  {
    'format'  => 'text',
    'options' => '-o markdown',
    'input'   => 'fmt/txt-markdown/YamlFrontMatter.md'
  },
  {
    'doc'     => "That the yfm_keys and yfm_skip_array options actually work",
    'format'  => 'text',
    'options' => "-o markdown -o yfm_skip_array -o yfm_keys='title , subtitle,paragraph'",
    'input'   => "fmt/txt-markdown/YamlFrontMatter_Options.md",
  },
  {
    'doc'     => "That the yfm_keys and yfm_paths options actually work",
    'format'  => 'text',
    'options' => "-o markdown -o yfm_skip_array -o yfm_keys='   subtitle     ,paragraph' -o yfm_paths='people title' ",
    'input'   => "fmt/txt-markdown/YamlFrontMatter_KeysPaths.md",
  },
  {
    'doc'     => "Allow markdown files to contain two horizontal rulers that do not denote a YFM.",
    'format'  => 'text',
    'options' => "-o markdown -o yfm_lenient ",
    'input'   => "fmt/txt-markdown/YamlFrontMatter_fake.md",
  },
  {
    'doc'     => "Handle tables in markdown files, even if it's a GitHub extension.",
    'skip'    => { 'updatepo' => 1 },
    'format'  => 'text',
    'options' => "-o markdown ",
    'input'   => "fmt/txt-markdown/Tables.md",
  };

run_all_tests(@tests);
0;