package ONO::Render::Placeholders;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2000-2025 Jos KIRPS [ www.kirps.com | jos_AT_kirps_DOT_com ]
# and The Joopita Project [ www.joopita.org | contact_AT_joopita_DOT_com ]
#
# This file, as well as other parts of the ONO Software Project or related
# elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################
use strict;
#: Parse and replace placeholder tags before sending code to a client.
###############################################################################
# CORNELIOS HTML RENDER ENGINE
###############################################################################
sub parse {
#: This replaces some of the placeholder tags that some ONO modules and
#: functions are using. It may make sense to use this before sending
#: generated code to a client.
#:
#: Note that ONO::Render's render() function automatically uses this
#: function, there's no need to call it manually.
my $data = $_[1];
$data =~ s/>\t/>\n\t/g;
$data =~ s/<br \/><tr/<tr/gi;
$data =~ s/###BREAKHERE###/\n/gi;
$data =~ s/###COMMA###/\,/gi;
$data =~ s/###(SEMI|SEMICOLON)###/;/gi;
$data =~ s/###COLON###/:/gi;
$data =~ s/###EQUAL###/\=/gi;
$data =~ s/###BREAK###/<br>/gi;
$data =~ s/###SHEBANG###/#\!/gi;
$data =~ s/###SMILE-(g|y)###/:$1-/gi;
$data =~ s/\\\[/\[/g;
$data =~ s/\\\]/\]/g;
$data =~ s/\\\<\\/\</g;
$data =~ s/\\\>\\/\>/g;
$data =~ s/\\<tip\\>/<tip>/g;
$data =~ s~</li><br>~</li>~g;
$data =~ s~<br><li>~<li>~g;
$data =~ s~<br></ul>~</ul>~g;
$data =~ s~<ul><br>~<ul>~g;
$data =~ s~</h([A-Za-z0-9])><br(| )(|/)>~</h$1>~gi;
$data =~ s/###OPEN###/\[\[/g;
$data =~ s/###CLOSE###/\]\]/g;
$data =~ s/##OPEN##/\[/g;
$data =~ s/##CLOSE##/\]/g;
$data =~ s~#OPEN##~\[~g;
$data =~ s~##CLOSE#~\]~g;
$data =~ s/##BOPEN##/\(/g;
$data =~ s/##BCLOSE##/\)/g;
$data =~ s/###DOT###/\./g;
$data =~ s/###PIPE###/\|/g;
$data =~ s/###APOST###/\'/g;
$data =~ s/##LT##/\</g;
$data =~ s/##GT##/\>/g;
$data =~ s/###NBSP###/ /gi;
$data =~ s~<\!(table|tr|td)~<$1~g;
$data =~ s~</\!(table|tr|td)~</$1~g;
$data =~ s~\<big\>~<span style="font-size:larger">~g;
$data =~ s~<s>~<span style="text-decoration:line-through">~g;
$data =~ s~<strike>~<span style="text-decoration:line-through">~g;
$data =~ s~\<tt\>~<span style="font-family:monospace">~g;
$data =~ s~\<u\>~<span style="text-decoration:underline">~g;
$data =~ s~</(big|s|strike|tt|u)>~</span>~g;
$data =~ s~\<center\>~<div class="center">~g;
$data =~ s~\</center\>~<div>~g;
# buggy HTML cleanup...
$data =~ s~<br><td~<td~gi;
$data =~ s~</td><br>~</td>~gi;
$data =~ s~<br><tr~<tr~gi;
$data =~ s~<br></tr>~</tr>~gi;
return $data;
}
###############################################################################
# end of script
###############################################################################
1;
__END__