1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
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 2 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, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDWeb::Include;
25 use CGI qw/:standard/;
27 our @ISA = qw/Exporter/;
29 our @EXPORT = qw/parseMarkup
31 comma_value array_expand/;
34 return CGI::escapeHTML @_;
39 $v =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;
44 my $bbc = Parse::BBCode->new({
46 Parse::BBCode::HTML->defaults,
49 $e =~ s/\r?\n|\r/<br>\n/g;
52 url => 'url:<a href="%{link}A" rel="external">%s</a>',
53 quote => 'block:<div class="bbcode-quote">
54 <div class="bbcode-quote-head"><b>%{html}a wrote:</b></div>
55 <div class="bbcode-quote-body">%s</div></div>',
56 code => 'block:<div class="bbcode-quote"><pre class="bbcode-code">%{html}s</pre></div>',
57 img => 'url:<a href="%{link}A" rel="external">%s</a>',
58 li => 'block:<li>%{parse}s</li>',
59 size => '<span style="font-size: %{num}a%">%s</span>',
68 $text = $bbc->render($text);
70 my $tree = $bbc->get_tree;
71 $text = $tree->raw_text;
72 $text = $bbc->render($text);
74 $text =~ s/\x{3}\d\d?//g; #mirc color TODO: possibly match until \x{0F} and change to [color] block
75 $text =~ s/[^\x{9}\x{A}\x{D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]//g;
79 sub array_expand ($) {
83 for my $string (@{$array}){
84 $string =~ s/^\((.*)\)$/$1/;
86 my @array = split /,/, $string;