Lines Breaks
  • 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:
  • ToddTodd
    Posts: 1,436
    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.

    Vanilla co-founder

  • 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
    Posts: 4,880
    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.
  • 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.
  • lucluc
    Posts: 983
    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).
  • yannyann
    Posts: 59
    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?
  • yannyann
    Posts: 59
    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
    Posts: 4,880
    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.
  • lucluc
    Posts: 983
    Though, it's something really counter-intuitive.
    Strange folks :)
  • yannyann
    Posts: 59
    AutoP is a good addon to have...
  • lucluc
    Posts: 983
    @yann: This is about vanilla2, no AutoP there.
  • yannyann
    Posts: 59
    @beam My mistake. Sorry.
  • LincolnLincoln
    Posts: 2,016
    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?

    Vanilla developer [GitHub, Twitter]

  • @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
    Posts: 983
    I think that @Mark put in a fix a few days ago.
  • just
    testing
    the

    lines
    breaks


    ;)
  • awesome, seems to be working nicely here ;)
  • SS
    Posts: 453
    How to disable that?
  • SS
    Posts: 453
    I found it: Format::Html()
    $Mixed = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $Mixed);
    Wonder to move it to config or param to Html().
  • LouisLouis
    Posts: 88
    @S - I totally bought this up in my CKEditor plugin for v2: http://vanillaforums.org/discussion/10711/very-alpha-ckeditor-in-vanilla-2/

    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?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

Who's Online 4

Idannjumarawhu606xvik