Get your own copy
Don't hesitate! Just download and test it all by yourself for free!
If you set this option to true, TinyMCE will force BR elements on newlines instead of inserting paragraphs. This option is set to false by default since paragraphs is a much better concept. BR elements should only be used when you really have to (mostly never). Also as of 3.x the forced_root_block option is enabled by default so if you really want to disable paragraphs disable that one as well.
tinyMCE.init({
...
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : '' // Needed for 3.x
});
This CSS will reduce the space between (lines) paragraphs to zero. It will look more like the default line spacing in popular Word processors.
p {margin: 0; padding: 0;}
See also: Reasons why not to use BR elements for linebreaks
Note that this code does not rely upon regular expressions for processing the HTML, since you really cannot rely upon them to do the job. For a detailed discussion, see How do I remove HTML from a string? in perlfaq9; at the terminal of a machine with Perl, type perldoc -q html.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TokeParser;
use CGI ();
my $cgi = CGI->new;
# Test by uncommenting next line and changing the value:
# $cgi->param(content => "your html here for testing only");
# Replace 'content' with name of your TinyMCE-edited field:
my $p = HTML::TokeParser->new( $cgi->param('content') );
my $output = "";
while (my $token = $p->get_token){
if ($token->[0] eq 'S'){
if ($token->[1] eq 'p'){
$output .= '<br/>';
} else {
$output .= $token->[4];
}
}
elsif ($token->[0] eq 'E'){
if ($token->[1] eq 'p'){
$output .= '<br/>';
} else {
$output .= $token->[2];
}
}
elsif ($token->[0] eq 'PI'){
$output .= $token->[2];
}
else {
$output .= $token->[1];;
}
}
# Your new doc is in $output
warn $output;
__END__
// Get content from TinyMCE
$content = $_REQUEST['content'];
$content = preg_replace('/<p[^>]*>/', '', $content); // Remove the start <p> or <p attr="">
$content = preg_replace('/</p>/', '<br />', $content); // Replace the end
echo $content; // Output content without P tags
AceT
Isn't this Perl-section (extremely) outdated? Suggestion:
[code]
#!/usr/bin/perl
use strict; # write clean code
use CGI qw(:standard); # for processing the POST
my $query = CGI->new;
my $content = $query->param('content');
$content =~ s/<p[^>]*>//gim; # g = every instance | i = ignore case | m = multiline
$content =~ s/</p[^>]*>/<br\/>/gim;
print $content
[/code]