new line fix PLEASE

josh's Avatar

josh

02 Jul, 2009 01:46 PM

I ran across this actually on a rails project I was working on... the simple_format helper doesn't use line breaks properly from text boxes and garbles the hell out of pasted text (for example from a command prompt)... the solution, instead of using simple_format (or whatever helper your using) is to use a regex to replace the line breaks... Its really annoying to have to go back, edit a post, and do this

line 1

line 2

line 3

just so it will format properly; 1 line break = 1 br tag.... 2 \n's != 1 br (you'll have to hit edit to see what im talking about admins, it does it on tender AND lighthouse, lighthouse is the one i'd prefer first fixed)

Thanks, Josh

  1. 1 Posted by josh on 02 Jul, 2009 01:57 PM

    josh's Avatar

    REGEX:

     STRING.gsub(/\n/, '<br>')
    
  2. 2 Posted by rick on 02 Jul, 2009 02:21 PM

    rick's Avatar

    simple_format uses regex actually. We use a modified version of it if you turn plain text formatting on. By default, markdown is used though. You can either put two spaces after lines, or wrap whole paragraphs with the @@@

        @@@
        foo
        bar
        @@@
    
  3. 3 Posted by josh on 02 Jul, 2009 02:29 PM

    josh's Avatar

    Yes but you can't do that on Lighthouse :)

    I dont want to have to 
    type every ticket 
    with AT signs around it
    
  4. 4 Posted by rick on 02 Jul, 2009 02:59 PM

    rick's Avatar

    Oh we're talking about Lighthouse? Lighthouse has no plain text format, sorry.

  5. 5 Posted by josh on 02 Jul, 2009 03:09 PM

    josh's Avatar

    Yes I know it doesnt. Thats the point of this ticket :). It doesn't format line breaks properly.

  6. 6 Posted by rick on 02 Jul, 2009 04:07 PM

    rick's Avatar

    Sure, but this ticket is in the Tender section, right? I get
    confused, sometimes I give people Tender answers to Lighthouse
    questions.

    It's going to require a nasty migration to a table, but I'll be adding
    the option for users to choose plain or markdown formatting for their
    posts. Emails come in plain text by default as well.

Discussions are closed to public comments.
If you need help with Tender please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

05 Dec, 2019 01:11 AM
22 Nov, 2019 01:04 PM
14 Oct, 2019 04:05 AM
14 Oct, 2019 12:43 AM
21 Sep, 2019 02:33 PM