2 # Copyright (C) 2006, 2007 Alex Schroeder <alex@gnu.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 use Test
::More tests
=> 18;
22 add_module
('portrait-support.pl');
25 update_page
('headers', "[new]foo\n== no header ==\n\ntext\n");
26 test_page
(get_page
('headers'),
27 '<div class="color one level0"><p>foo == no header ==</p><p>text</p></div>');
30 add_module
('usemod.pl');
31 update_page
('headers', "[new]foo\n== is header ==\n\ntext\n");
32 test_page
(get_page
('headers'), '<div class="color one level0"><p>foo </p></div><h2>is header</h2>');
36 test_page
(update_page
('headers', "[new]foo\n== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n"),
37 # default to before the header
38 '<div class="content browse"><div class="color one level0"><p>foo </p></div>',
39 '<div class="toc"><h2>Contents</h2><ol>',
40 qq{<li
><a href
="#${TocAnchorPrefix}1">one
</a></li>},
41 qq{<li
><a href
="#${TocAnchorPrefix}2">two
</a></li>},
42 qq{<li
><a href
="#${TocAnchorPrefix}3">three
</a></li></ol></div
>},
43 qq{<h2 id
="${TocAnchorPrefix}1">one
</h2><p>text </p>},
44 qq{<h2 id
="${TocAnchorPrefix}2">two
</h2
>}, );
46 remove_module
('toc.pl');
47 # The next two are necessary so that toc.pl can be reloaded safely later!
48 *ApplyRules
= *OldTocApplyRules
;
49 *RunMyRules
= *RunMyRulesTocOld
;
50 remove_rule
(\
&TocRule
);
51 remove_module
('usemod.pl');
52 remove_rule
(\
&UsemodRule
);
55 add_module
('headers.pl');
56 update_page
('headers', "[new]foo\nis header\n=========\n\ntext\n");
57 test_page
(get_page
('headers'), '<div class="color one level0"><p>foo </p></div><h2>is header</h2>');
58 remove_module
('headers.pl');
59 remove_rule
(\
&HeadersRule
);
61 # portrait-support, toc, and usemod
63 add_module
('usemod.pl');
65 test_page
(update_page
('headers', "[new]foo\n== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n"),
66 qq{<li
><a href
="#${TocAnchorPrefix}1">one
</a></li>},
67 qq{<li
><a href
="#${TocAnchorPrefix}2">two
</a></li>},
68 '<div class="color one level0"><p>foo </p></div>',
69 qq{<h2 id
="${TocAnchorPrefix}1">one
</h2
>},
70 qq{<h2 id
="${TocAnchorPrefix}2">two
</h2
>}, );
72 run_tests
(split('\n',<<'EOT'));
74 <div class="color one level0"><p> foo</p></div>
76 <div class="color two level1"><p> foo</p></div>
78 <div class="color one level2"><p> foo</p></div>