This is an html purifier thing. There might be a config setting to change the behavior, but I couldn't seem to find it. Anyone else? I can also check for an update to the library.
I think $config->set('Output', 'Newline', "<br />"); Might help, the only problem is that that line will currently break the script as i think the whole page gets rendered with html purifier. If it were just the posts being purified it should work fine.
Hey i have found a fix, all it requires is you add
$FormPostValues['Body'] = nl2br($FormPostValues['Body']); on line 281 of the class.commentmodel.php in vanilla. As the function suggests it takes new lines and replaces them with break lines.
There is probably other places where it needs to be added. Or done in a better place.
Also add $this->Comment->Body = preg_replace('/<br\\s*?\/??>/i', '', $this->Comment->Body); on line 306 of the post.php controller in vanilla. So it is displayed normally in the edit box. Again both code samples just get the job done, there may be more cases that it is needed it. A nice function to do it, new location of code samples or something.
Yeah i was being a plonk, you don't need all that i blame it on it being late. All you need to do is have this line <div class="Body"><?php echo nl2br(Format::To($Comment->Body, $Comment->Format)); ?></div> on line 80 of helper_functions.php in discussion folder of views and line breaks will work normally as you would expect.
I am having a related (maybe) bug. When I moved data from punBB to Vanilla 1.1.9, comments containing "\n" do not show a new line when displayed -- the database show those are having newlines. However, when I "edit" the comment, I get the newlines back. Saving it does not change anything in the database (that I can see via mysql) but now the newlines are replaced by " " in the html.
I was really hoping that htmlpurifier could handle all of the formatting - that is it's purpose, after all. But they are very stern about this point for some reason.
So where do we stand on this? Is @Immersion's fix something that can get incorporated into Garden, is there some other fix for HTMLPurifier, or do we need to hack this ourselves after we grab it from Git?
@Immersion's fix works, but it also causes line-breaks to happen when it shouldn't, for example, inside <pre> tags.
It also makes things looks bad when creating a new paragraph because a new paragraph requires 2 line-breaks, which ends up looking like:
<p>old paragraph</p> <br /> <br /> <p>
Edit: Just did some testing and noticed line-breaks work as expected when HTML Purifier if disabled, so the fix should probably be within the plugin rather than using a dirty workaround in the Vanilla application.
Though I almost feel as if this needs to be a per-post option, like how you could select what editor to use in Vanilla 1. This way the parsing is done when a post is made, and the HTML could be cached. And this means if an addon for whatever reason is using Html() for output, it will know whether or not line breaks are enabled. Any thoughts, @Mark?
Comments
Vanilla co-founder
As it defaults to false i think you may need to set it to true.
What's I'm saying is, a single newline doesn't create a line break unless you force it using the <br /> tag, it just continues the previous line.
$config->set('Output', 'Newline', "<br />");Might help, the only problem is that that line will currently break the script as i think the whole page gets rendered with html purifier. If it were just the posts being purified it should work fine.
http://htmlpurifier.org/phorum/
$FormPostValues['Body'] = nl2br($FormPostValues['Body']);on line 281 of the class.commentmodel.php in vanilla.
As the function suggests it takes new lines and replaces them with break lines.
There is probably other places where it needs to be added. Or done in a better place.
$this->Comment->Body = preg_replace('/<br\\s*?\/??>/i', '', $this->Comment->Body);on line 306 of the post.php controller in vanilla. So it is displayed normally in the edit box. Again both code samples just get the job done, there may be more cases that it is needed it. A nice function to do it, new location of code samples or something.
Yeah i was being a plonk, you don't need all that i blame it on it being late. All you need to do is have this line
<div class="Body"><?php echo nl2br(Format::To($Comment->Body, $Comment->Format)); ?></div>on line 80 of helper_functions.php in discussion folder of views and line breaks will work normally as you would expect.
Because I've cloned 2 days ago, and it still does not get on a new line in my test forum (except if I put 2 line break).
" in the html.
Any idea?
Could we make sure that both "\n" and "\r\n" get replaced in the future? Makes the code portable...
Thanks.
Strange folks :)
Vanilla developer [GitHub, Twitter]
It also makes things looks bad when creating a new paragraph because a new paragraph requires 2 line-breaks, which ends up looking like: Edit: Just did some testing and noticed line-breaks work as expected when HTML Purifier if disabled, so the fix should probably be within the plugin rather than using a dirty workaround in the Vanilla application.
testing
the
lines
breaks
;)
$Mixed = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $Mixed);Wonder to move it to config or param to Html().
Though I almost feel as if this needs to be a per-post option, like how you could select what editor to use in Vanilla 1. This way the parsing is done when a post is made, and the HTML could be cached. And this means if an addon for whatever reason is using Html() for output, it will know whether or not line breaks are enabled. Any thoughts, @Mark?