Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

how do i fix this text BlogEntry formatting issue?


Go to End


2 Posts   1627 Views

Avatar
iandouglas736

Community Member, 8 Posts

12 January 2008 at 7:37am

Edited: 12/01/2008 7:39am

When building a blog entry, if i use the 'code' element (or others that I've added to the mix), any double carriage-return gets parsed into a closing paragraph tag and a new opening paragraph tag.

(i've had to replace the [ and ] marks and < and > tags but you'll see what I mean)

So doing something like:
{code}my first line of code

second line{/code}

This obviously causes XML errors, since the parsed content looks something like:

(pre)my first line of code(/p)(p)second line(/pre)

How would I 'fix' this, where the line feeds are all just interpreted as break tags instead of paragraph tags, only when in a 'code' element?

Avatar
iandouglas736

Community Member, 8 Posts

12 January 2008 at 7:45am

Found it ... sapphire/parsers/BBCodeParser.php

Commented out this line around line 107 or so:

$this->content = str_replace("\n\n", "</p><p>", $this->content);