#!perl BEGIN { chdir 't' if -d 't' } use strict; use warnings; use Test::More tests => 16; use Test::NoWarnings; use_ok 'Text::MediawikiFormat', as => 'wf', process_html => 0; my $wikitext = <unordered!, 'ensure that lists followed by paragraphs are included correctly'; package Baz; use Text::MediawikiFormat as => 'wf', process_html => 0; ::can_ok( 'Baz', 'wf' ); package main; ## ## make sure tag overrides work for Kake ## $wikitext = < qr/^(?:\t+|\s{4,}|(?=\*+))/, blocks => { unordered => qr/^\s*\*+\s*/ }, nests => { unordered => 1 }, ); $htmltext = wf( $wikitext, \%format_tags ); like $htmltext, qr/
  • foo<\/li>/, "first level of unordered list"; like $htmltext, qr/
  • bar<\/li>/, "nested unordered lists OK"; ## ## Check that blocks not in blockorder are not fatal ## %format_tags = ( blocks => { definition => qr/^:\s*/ }, definition => [ "
    \n", "
    \n", '
    ', "\n" ], blockorder => ['definition'], ); my $warning; local $SIG{__WARN__} = sub { $warning = shift }; eval { wf( $wikitext, \%format_tags ) }; is $@, '', 'format() should not die if a block is missing from blockorder'; like $warning, qr/No order specified/, '... warning instead'; my $foo = 'x'; $foo .= '' unless $foo =~ /x/; my $html = wf('test'); is $html, "

    test

    \n", 'successful prior match should not whomp format()'; $wikitext = <<'WIKI'; Here is some example code: sub example_code { my ($foo) = @_; my $this = call_that $foo; } Isn't it nice? WIKI $htmltext = wf( $wikitext, { blocks => { code => qr/^\t/ } } ); like $htmltext, qr!
    sub example_code[^<]+}\s*
    !m, 'pre tags should work'; like $htmltext, qr!^\tmy \(\$foo\)!m, '... not removing further indents'; $wikitext = < 1 } ); like $htmltext, qr!CamelCase!, 'parse actual CamelCase words into links'; like $htmltext, qr!CamooseCase!, '... not repeating if using link as title'; like $htmltext, qr!^NOTCAMELCASE!m, '... but not words in all uppercase'; my @processed = Text::MediawikiFormat::_nest_blocks( [] ); is @processed, 0, '_nest_blocks() should not autovivify empty blocks array';