SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist FCC's Avatar
    Join Date
    May 2006
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    BBcode and the \n function

    Hi All,

    I am making some BBcode for my CMS and I've run into an interesting issue.

    I allow the users to make lists and stuff and when they click on the list button, basically it prompts them for list items and they keep entering until they press cancel. And then the list BBcode apears in the textarea. I've used the javascript code "\n" to make the list items appear on different rows. So an example would be:

    Code:
    [*list]
    [li]item 1[/li]
    [li]item 2[/li]
    [/*list]
    Note: I've added the * because the BBcode on this form converts it to a <ul> tag.

    All fine and dandy. The problem is I use the PHP code nl2br to convert \n into <br> so that when users are typing in content we may allow them to keep paragraphs. So the problem becomes clear now.

    When outputting the list code, I get this code:

    Code:
    <ul><br />
    <li>item 1</li><br />
    <li>item 2</li><br />
    </ul>
    Which is not what I want....any suggestions on how to avoid this?

  2. #2
    SitePoint Evangelist FCC's Avatar
    Join Date
    May 2006
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •