#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;

# PODNAME: phpbb2md
# ABSTRACT: Quick'n'dirty conversion of phpBB to markdown
our $VERSION = '0.01'; # VERSION


{
    local $/;
    $_ = <>;    # Slurp

    # These aren't strictly phpBB, but I used them to simulate headers

    s{\Q[b][size=18pt]\E\s*=?\s*(.*?)\s*=?\s*\Q[/size][/b]}{## $1}g;        # 18pt
    s{\Q[b][size=14pt]\E\s*=?\s*(.*?)\s*=?\s*\Q[/size][/b]}{### $1}g;       # 14pt

    s{\[/?i\]}{*}g;
    s{\[/?b\]}{**}g;
    s{\[url=(?<url>.*?)\](?<text>.*?)\[/url\]}{[$+{text}]($+{url})}g;
    s{\[/?list\]}{}g;
    s{^\s*\[li\]}{* }mg;
    s{\[/li\]}{}g;
    s{\[img\](.*?)\[/img\]}{![]($1)}g;
}

print;

__END__

=pod

=head1 NAME

phpbb2md - Quick'n'dirty conversion of phpBB to markdown

=head1 VERSION

version 0.01

=head1 DESCRIPTION

This is a quick'n'dirty command that converts phpBB / BBcode into
markdown format.

=head1 SYNPOSIS

    phpbb2md < somefile.bbcode > somefile.md

=head1 BUGS

Plenty. Report them or fix them at
L<http://github.com/pjf/Markdown-phpBB/issues>.

=head1 AUTHOR

Paul Fenwick <pjf@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Paul Fenwick.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
