converting linebreaks to br

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomba

    converting linebreaks to br

    hi there,

    I am looking for a way to convert line breaks that are written in a textarea
    (with an enter) to <br> to create the same line break in html

    is there anyone who can help me with this?
    I can't seem to find a way to recognize the linebreaks in the textarea

    thanks,
    Steven De Groote

    --
    Webmaster of:

    De startpagina Go2 biedt een overzicht van handige internet websites en links in Belgie of Vlaanderen. Handige Go2.be internet diensten zoals horoscoop, domeinnaam, wisselkoers berekenen, gratis muziek downloaden en telefoonnummer zoeken.



  • Shawn Wilson

    #2
    Re: converting linebreaks to br

    Tomba wrote:[color=blue]
    >
    > hi there,
    >
    > I am looking for a way to convert line breaks that are written in a textarea
    > (with an enter) to <br> to create the same line break in html
    >
    > is there anyone who can help me with this?
    > I can't seem to find a way to recognize the linebreaks in the textarea[/color]

    nl2br()

    php.net

    --
    Shawn Wilson
    shawn@glassgian t.com

    Comment

    • Geoff Berrow

      #3
      Re: converting linebreaks to br

      I noticed that Message-ID: <40292AA0.B97D5 2E3@glassgiant. com> from Shawn
      Wilson contained the following:
      [color=blue][color=green]
      >> is there anyone who can help me with this?
      >> I can't seem to find a way to recognize the linebreaks in the textarea[/color]
      >
      >nl2br()[/color]

      But be aware that this replaces line breaks with <br /> which can throw
      up validator errors with some Doctypes.

      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Shawn Wilson

        #4
        Re: converting linebreaks to br

        Geoff Berrow wrote:[color=blue]
        >
        > I noticed that Message-ID: <40292AA0.B97D5 2E3@glassgiant. com> from Shawn
        > Wilson contained the following:
        >[color=green][color=darkred]
        > >> is there anyone who can help me with this?
        > >> I can't seem to find a way to recognize the linebreaks in the textarea[/color]
        > >
        > >nl2br()[/color]
        >
        > But be aware that this replaces line breaks with <br /> which can throw
        > up validator errors with some Doctypes.[/color]

        No.



        :o)
        --
        Shawn Wilson
        shawn@glassgian t.com

        Comment

        • Geoff Berrow

          #5
          Re: converting linebreaks to br

          I noticed that Message-ID: <40294665.2BA9A 5A8@glassgiant. com> from Shawn
          Wilson contained the following:
          [color=blue][color=green]
          >> But be aware that this replaces line breaks with <br /> which can throw
          >> up validator errors with some Doctypes.[/color]
          >
          >No.[/color]

          Ok, you don't want to be a ware. Be a lert instead?

          --
          Geoff Berrow (put thecat out to email)
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          • Andy Hassall

            #6
            Re: converting linebreaks to br

            On Tue, 10 Feb 2004 19:32:05 +0000, Geoff Berrow <blthecat@ckdog .co.uk> wrote:
            [color=blue]
            >I noticed that Message-ID: <40292AA0.B97D5 2E3@glassgiant. com> from Shawn
            >Wilson contained the following:
            >[color=green][color=darkred]
            >>> is there anyone who can help me with this?
            >>> I can't seem to find a way to recognize the linebreaks in the textarea[/color]
            >>
            >>nl2br()[/color]
            >
            >But be aware that this replaces line breaks with <br /> which can throw
            >up validator errors with some Doctypes.[/color]

            Which ones? The space before the / is specifically mentioned for compatibility
            with HTML. (XHTML1.0 Section C.2 <http://www.w3.org/TR/xhtml1/#guidelines>)

            --
            Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
            <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

            Comment

            • Geoff Berrow

              #7
              Re: converting linebreaks to br

              I noticed that Message-ID: <a5qi20pktu7oij qefek78lje112j0 kadng@4ax.com>
              from Andy Hassall contained the following:
              [color=blue][color=green]
              >>But be aware that this replaces line breaks with <br /> which can throw
              >>up validator errors with some Doctypes.[/color]
              >
              > Which ones? The space before the / is specifically mentioned for compatibility
              >with HTML. (XHTML1.0 Section C.2 <http://www.w3.org/TR/xhtml1/#guidelines>)[/color]

              Well, HTML 4.01 transitional for one.

              --
              Geoff Berrow (put thecat out to email)
              It's only Usenet, no one dies.
              My opinions, not the committee's, mine.
              Simple RFDs http://www.ckdog.co.uk/rfdmaker/

              Comment

              • Andy Hassall

                #8
                Re: converting linebreaks to br

                On Tue, 10 Feb 2004 23:48:24 +0000, Geoff Berrow <blthecat@ckdog .co.uk> wrote:
                [color=blue]
                >I noticed that Message-ID: <a5qi20pktu7oij qefek78lje112j0 kadng@4ax.com>
                >from Andy Hassall contained the following:
                >[color=green][color=darkred]
                >>>But be aware that this replaces line breaks with <br /> which can throw
                >>>up validator errors with some Doctypes.[/color]
                >>
                >> Which ones? The space before the / is specifically mentioned for compatibility
                >>with HTML. (XHTML1.0 Section C.2 <http://www.w3.org/TR/xhtml1/#guidelines>)[/color]
                >
                >Well, HTML 4.01 transitional for one.[/color]

                <!DOCTYPE HTML PUBLIC
                "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
                <title>br test</title>
                </head>
                <body>
                <br />
                </body>
                </html>

                validator.w3.or g says:

                'The uploaded file was checked and found to be valid HTML 4.01 Transitional.
                This means that the resource in question identified itself as "HTML 4.01
                Transitional" and that we successfully performed a formal validation using an
                SGML or XML Parser (depending on the markup language used).'

                --
                Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
                <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

                Comment

                • Geoff Berrow

                  #9
                  Re: converting linebreaks to br

                  I noticed that Message-ID: <l0si201c0kdq5s vs0o6tq9joi92oj u7vu1@4ax.com>
                  from Andy Hassall contained the following:
                  [color=blue]
                  >'The uploaded file was checked and found to be valid HTML 4.01 Transitional.[/color]

                  Apologies. I was certain I had had errors using this before.

                  --
                  Geoff Berrow (put thecat out to email)
                  It's only Usenet, no one dies.
                  My opinions, not the committee's, mine.
                  Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                  Comment

                  • Shawn Wilson

                    #10
                    Re: converting linebreaks to br

                    Geoff Berrow wrote:[color=blue]
                    >
                    > I noticed that Message-ID: <40294665.2BA9A 5A8@glassgiant. com> from Shawn
                    > Wilson contained the following:
                    >[color=green][color=darkred]
                    > >> But be aware that this replaces line breaks with <br /> which can throw
                    > >> up validator errors with some Doctypes.[/color]
                    > >
                    > >No.[/color]
                    >
                    > Ok, you don't want to be a ware. Be a lert instead?[/color]

                    No.
                    /Sticks fingers in ears and sings "la la la la la..."


                    :)
                    Shawn
                    --
                    Shawn Wilson
                    shawn@glassgian t.com

                    Comment

                    • Geoff Berrow

                      #11
                      Re: converting linebreaks to br

                      I noticed that Message-ID: <d0ti20159gsguf hh0sbnfbfdth17d 8a5ka@4ax.com>
                      from Geoff Berrow contained the following:
                      [color=blue]
                      >I noticed that Message-ID: <l0si201c0kdq5s vs0o6tq9joi92oj u7vu1@4ax.com>
                      >from Andy Hassall contained the following:
                      >[color=green]
                      >>'The uploaded file was checked and found to be valid HTML 4.01 Transitional.[/color]
                      >
                      >Apologies. I was certain I had had errors using this before.[/color]

                      Ah! Sorted out the confusion now.

                      This validator http://www.htmlhelp.com/tools/validator/ gives errors

                      Document Checked
                      URL: file:///C:\WINDOWS\Desk top\Untitled.ht m
                      Character encoding: ISO-8859-1
                      Level of HTML: HTML 4.01 Transitional
                      Errors and Warnings
                      Line 8, character 5:
                      <br />
                      ^Warning: net-enabling start-tag; possibly missing required quotes
                      around an attribute value



                      --
                      Geoff Berrow (put thecat out to email)
                      It's only Usenet, no one dies.
                      My opinions, not the committee's, mine.
                      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                      Comment

                      • Andy Hassall

                        #12
                        Re: converting linebreaks to br

                        On Wed, 11 Feb 2004 20:29:55 +0000, Geoff Berrow <blthecat@ckdog .co.uk> wrote:
                        [color=blue]
                        >I noticed that Message-ID: <d0ti20159gsguf hh0sbnfbfdth17d 8a5ka@4ax.com>
                        >from Geoff Berrow contained the following:
                        >[color=green]
                        >>I noticed that Message-ID: <l0si201c0kdq5s vs0o6tq9joi92oj u7vu1@4ax.com>
                        >>from Andy Hassall contained the following:
                        >>[color=darkred]
                        >>>'The uploaded file was checked and found to be valid HTML 4.01 Transitional.[/color]
                        >>
                        >>Apologies. I was certain I had had errors using this before.[/color]
                        >
                        >Ah! Sorted out the confusion now.
                        >
                        >This validator http://www.htmlhelp.com/tools/validator/ gives errors
                        >
                        >Document Checked
                        >URL: file:///C:\WINDOWS\Desk top\Untitled.ht m
                        >Character encoding: ISO-8859-1
                        >Level of HTML: HTML 4.01 Transitional
                        >Errors and Warnings
                        >Line 8, character 5:
                        ><br />
                        > ^Warning: net-enabling start-tag; possibly missing required quotes
                        >around an attribute value[/color]

                        Ah, right. A bit of digging around turns up this page with a detailed
                        explanation:



                        My turn to apologise :-)

                        --
                        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
                        <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

                        Comment

                        • John Dunlop

                          #13
                          Re: converting linebreaks to br

                          Geoff Berrow wrote:
                          [color=blue]
                          > This validator http://www.htmlhelp.com/tools/validator/ gives errors
                          >
                          > Document Checked
                          > URL: file:///C:\WINDOWS\Desk top\Untitled.ht m
                          > Character encoding: ISO-8859-1
                          > Level of HTML: HTML 4.01 Transitional
                          > Errors and Warnings
                          > Line 8, character 5:
                          > <br />
                          > ^Warning: net-enabling start-tag; possibly missing required quotes
                          > around an attribute value[/color]

                          That is a warning, not a reportable markup error; i.e. the HTML is
                          valid, but "dangerous" (!). Uncheck the "Include warnings" checkbox
                          to suppress those warnings.



                          In HTML, the notation "<br />" is *valid* everywhere that "<br>" is.
                          But, without fail, such markup doesn't mean what the author thought
                          it meant.

                          In HTML, "<br />" means "<br>>", where the last greater than sign is
                          actual content, not markup. The BR element being an inline element,
                          there exists no situation where "<br />" is invalid and <br> is
                          valid; everywhere BR is allowed, content is allowed too, so a
                          validator won't flag the trailing ">" as an error, although it may
                          give some warning.

                          The reason for the trailing ">" is because HTML permits shorthand
                          markup. "<br /" is actually a complete start-tag, in HTML. The NET-
                          enabling start-tags "<br /" and "<br/" are equivalent to the standard
                          start-tag "<br>". Elements that require end-tags can be shortened
                          too; for example, you could write a TITLE element like

                          <TITLE/Advanced rope jump techniques/

                          The first slash ends the start-tag; the second slash *is* the end-tag
                          (called a null end-tag [NET]), which is only recognised if the
                          corresponding NET-enabling start-tag is used. More information:



                          The HTML4.01 spec. unfortunately doesn't go into detail about
                          shorthand markup; sec. B.3.7 seems to be the only place "NET tags"
                          are mentioned. That may well be the reason behind most browsers
                          getting this wrong. The SGML standard (ISO8879) is the authoritative
                          source for that information, if you're interested. However, if you'd
                          just like to see how some particular markup is parsed, you can enable
                          the "Show Parse Tree" option in the W3C's validator.

                          I'm not sure why nl2br started spitting out "<br />"s instead of
                          "<br>"s. IIRC there is at least some advice given in the user
                          contributed notes about how to get around this. I suspect the X-
                          factor struck again.

                          HTH.

                          --
                          Jock

                          Comment

                          • Geoff Berrow

                            #14
                            Re: converting linebreaks to br

                            I noticed that Message-ID: <ab5l20954o2ris 7rb1qhemgg5pf0s 2n0l2@4ax.com>
                            from Andy Hassall contained the following:
                            [color=blue][color=green]
                            >> ^Warning: net-enabling start-tag; possibly missing required quotes
                            >>around an attribute value[/color]
                            >
                            > Ah, right. A bit of digging around turns up this page with a detailed
                            >explanation:
                            >
                            > http://www.cs.tut.fi/~jkorpela/html/empty.html
                            >
                            > My turn to apologise :-)[/color]

                            Thanks!

                            What a civilised group. ;-)

                            --
                            Geoff Berrow (put thecat out to email)
                            It's only Usenet, no one dies.
                            My opinions, not the committee's, mine.
                            Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                            Comment

                            Working...