HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Lines Breaks

Mike.XIIIMike.XIII New
edited August 2009 in Feedback
Is anyone else bothered by requiring a <br /> to get to a new line?

I shouldn't need to use HTML just to start a new line like this...

Having to have a space between my lines (like this ^) making it a new paragraph when it isn't, is annoying.
Tagged:
«1

Comments

  • ToddTodd Chief Product Officer Vanilla Staff
    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.
  • edited August 2009
    What is http://htmlpurifier.org/live/configdoc/plain.html#AutoFormat.AutoParagraph set to?

    As it defaults to false i think you may need to set it to true.
  • No I think it's already set to true, because a double newline already creates a new paragraph, which is fine.

    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.
  • 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.
  • That would probably create large gaps of whitespace if multi-lined html is used (the Vanilla1 addon does this)
  • MarkMark Vanilla Staff
    We definitely need some kind of fix here. We should consult the htmlpurifier folks. Anyone want to take lead?

    http://htmlpurifier.org/phorum/
  • 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.
  • edited August 2009
    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.
  • Has this been fixed?

    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).
  • edited September 2009
    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.

    Any idea?
  • Found my bug. It was not related. Imported data had "\n" but to display properly, one needs "\r\n".

    Could we make sure that both "\n" and "\r\n" get replaced in the future? Makes the code portable...

    Thanks.
  • MarkMark Vanilla Staff
    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.
  • Though, it's something really counter-intuitive.
    Strange folks :)
  • AutoP is a good addon to have...
  • @yann: This is about vanilla2, no AutoP there.
  • @beam My mistake. Sorry.
  • LincLinc Detroit Admin
    edited September 2009
    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?
  • Mike.XIIIMike.XIII New
    edited October 2009
    @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.
  • lucluc ✭✭
    I think that @Mark put in a fix a few days ago.
  • just
    testing
    the

    lines
    breaks


    ;)
Sign In or Register to comment.