View Issue Details

IDProjectCategoryView StatusLast Update
0007166mantisbtbugtrackerpublic2009-06-15 03:25
Reportermose Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version1.0.3 
Summary0007166: spaces and line breaks destroy prety printed
    and
      markup
Description

As I see it

    and
      should be displayed in a similar maner to
      ,
      i.e. without ' ' -> ' ' or '\n' -> '
      ' inside the tag.

Tagspatch

Activities

mose

mose

2006-06-02 09:03

reporter   ~0012931

I fixed it for myself with changing core/string_api.php:68

from:
preg_match_all("/<pre[^>]?>(.|\n)?<\/pre>", $p_string, $pre1);

to:
preg_match_all("/<pre[^>]?>(.|\n)?<\/pre>|<ol[^>]?>(.|\n)?<\/ol>/", $p_string, $pre1);

mose

mose

2006-06-02 09:05

reporter   ~0012932

Description should have been:
As I see it >ol> and >ul> should be displayed in a similar maner to >pre>,
i.e. without ' ' -> '&nbsp;' or '\n' -> '>br>' inside the tag.

mose

mose

2009-06-13 04:51

reporter   ~0022147

Anything I can do to assist?

jreese

jreese

2009-06-13 09:50

reporter   ~0022149

Patches againt Git are welcome. http://docs.mantisbt.org/master/en/developers/dev.contrib.html

siebrand

siebrand

2009-06-13 09:53

developer   ~0022151

Yeah, please attach a patch based on git master. Current code differs.

--------------------

Similar to nl2br, but fixes up a problem where new lines are doubled between

 tags.

additionally, wrap the text an $p_wrap character intervals if the config is set

function string_nl2br( $p_string, $p_wrap = 100 ) {
$output = '';
$pieces = preg_split( '/(<pre[^>]>.?<\/pre>)/is', $p_string, -1, PREG_SPLIT_DELIM_CAPTURE );
if( isset( $pieces[1] ) ) {
foreach( $pieces as $piece ) {
if( preg_match( '/(<pre[^>]>.?<\/pre>)/is', $piece ) ) {
$piece = preg_replace( "/<br[^>]*?>/", "", $piece );

            # @@@ thraxisp - this may want to be replaced by html_entity_decode (or equivalent)
            #     if other encoded characters are a problem
            $piece = preg_replace( "/&nbsp;/", " ", $piece );
            if( ON == config_get( 'wrap_in_preformatted_text' ) ) {
                $output .= preg_replace( '/([^\n]{' . $p_wrap . '})(?!<\/pre>)/', "$1\n", $piece );
            } else {
                $output .= $piece;
            }
        } else {
            $output .= nl2br( $piece );
        }
    }
    return $output;
} else {
    return nl2br( $p_string );
}

}