wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / anchors.t
blobbc13bf2ee967c68a5bd3dee4099520f777624982
1 # Copyright (C) 2006, 2009  Alex Schroeder <alex@gnu.org>
3 # This program is free software: you can redistribute it and/or modify it under
4 # the terms of the GNU General Public License as published by the Free Software
5 # Foundation, either version 3 of the License, or (at your option) any later
6 # version.
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License along with
13 # this program. If not, see <http://www.gnu.org/licenses/>.
15 require 't/test.pl';
16 package OddMuse;
17 use Test::More tests => 9;
19 clear_pages();
21 do 'modules/anchors.pl';
22 do 'modules/link-all.pl'; # check compatibility
24 xpath_run_tests(split('\n',<<'EOT'));
25 This is a [:day for fun and laughter].
26 //a[@class="anchor"][@name="day_for_fun_and_laughter"]
27 [[#day for fun and laughter]].
28 //a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"]
29 [[2004-08-17#day for fun and laughter]].
30 //a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="2004-08-17#day for fun and laughter"]
31 [[[#day for fun and laughter]]].
32 //text()[string()="["]/following-sibling::a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"]/following-sibling::text()[string()="]."]
33 [[[2004-08-17#day for fun and laughter]]].
34 //a[@class="local anchor number"][@title="2004-08-17#day_for_fun_and_laughter"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
35 [[2004-08-17#day for fun and laughter|boo]].
36 //a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="boo"]
37 EOT
39 my $result = apply_rules('This is a [:day for fun and laughter].');
40 like($result, qr'></a>', 'named anchors are not minimized');
42 $BracketWiki = 0;
44 run_tests(split('\n',<<'EOT'));
45 [[#day for fun and laughter|boo]].
46 [[#day for fun and laughter|boo]].
47 [[2004-08-17#day for fun and laughter|boo]].
48 [[2004-08-17#day for fun and laughter|boo]].
49 EOT