View Issue Details

IDProjectCategoryView StatusLast Update
0004762mantisbtbugtrackerpublic2005-05-31 11:34
ReporterEric Seppanen Assigned Tothraxisp  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.19.0 
Fixed in Version1.0.0a3 
Summary0004762: Preformatted text is misbehaving.
Description

Here's a block of text enclosed in (pre) tags. It won't render properly on my installation: it's not displayed how I expected it, lots of html tags are generated and some of the data is damaged. I can't figure out why.


5:631 190 838 Parameter:00000000 T
5:631 190 850 Parameter:00000000 T
5:631 190 857 1024 bytes
BF D5 93 15 .... .Nl. w0000 T
5:631 190 869 1024 bytes
BF D5 93 15 .... .Nl. w0000 T
5:631 190 876 7F AB 26 2B .... .... w0001 T
5:631 190 888 7F AB 26 2B .... .... w0001 T
5:631 190 894 FF 56 4C 57 .VLW .... w0002 T

TagsNo tags attached.

Activities

Eric Seppanen

Eric Seppanen

2004-10-22 18:42

reporter   ~0008147

The text should look like this:

http://www.reric.net/mantis4762.txt

polzin

polzin

2004-10-25 05:47

reporter   ~0008161

Last edited: 2004-10-25 06:04

I had the same problem. Mantis 0.19.0 does a word wrap even in PRE texts and I don´t know why. Isn't preformated text ment to be displayed without word-wrap?

The function nl2br has a parameter "p_warp=100" (I conjecture) to prevent very long lines from destroying Mantis´ page layout. But there are two problems with Spaces being replaced by "&nbsp":

  1. The word-wrap counts the "&nbsp" and wraps to early.
  2. The word-wrap my wrap inside of " " commands -The result of this are the "&nbs---p;" in your example.

Uncommenting line 70 in core/string_api.php switches off the word-wrapping.

The other possibility is to replace the   inside of preformatted text, but there are still > and similar things in the text (as you can see below :-))

I prefer not using word-wrapping at all, although the page layout can suffer from this. If one really wants (needs) to write something with very long lines (code-snippets, ascii-art, etc.), he or she should be allowed to do so.

Better Word-Wrap:


* 67,72 **
--- 67,73 ----
preg_match_all("/<pre[^>]?>(.|\n)?<\/pre>/", $p_string, $pre1);
for ( $x = 0; $x < count($pre1[0]); $x++ ) {
$pre2[$x] = preg_replace("/<br[^>]*?>/", "", $pre1[0][$x]);

  • $pre2[$x] = preg_replace("/ /", " ", $pre2[$x]);
    $pre2[$x] = preg_replace("/([^\n]{".$p_wrap."})(?!<\/pre>)/", "$1\n", $pre2[$x]);
    $pre1[0][$x] = "/" . preg_quote($pre1[0][$x], "/") . "/";
    }

Or: No-Word-Wrap:


* 67,73 **
preg_match_all("/<pre[^>]?>(.|\n)?<\/pre>/", $p_string, $pre1);
for ( $x = 0; $x < count($pre1[0]); $x++ ) {
$pre2[$x] = preg_replace("/<br[^>]*?>/", "", $pre1[0][$x]);

  • $pre2[$x] = preg_replace("/([^\n]{".$p_wrap."})(?!<\/pre>)/", "$1\n", $pre2[$x]);
    $pre1[0][$x] = "/" . preg_quote($pre1[0][$x], "/") . "/";
    }

--- 67,72 ----

Correlated to : 0001146

edited on: 10-25-04 06:01

edited on: 10-25-04 06:03

edited on: 10-25-04 06:04

thraxisp

thraxisp

2005-04-25 21:50

reporter   ~0009910

Fixed in CVS.

config_defaults_inc.php -> 1.258
core/string_api.php -> 1.70