|
-
Jun 5th, 2003, 12:01 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] Creating a [list] tag?
I'm creating some sort of bbcode for one of the projects I'm working on, and am running into a bit of trouble with a [list] tag.
The list tag was supposed to look like this:
[list=#]
[*]ListItem
[/list]
Where # is the type of list.
This is what I started with:
Code:
$tags = array("/\[list=1\](.*)\[\/list\]/siU", "/\[list=2\](.*)\[\/list\]/siU",
"/\[list=3\](.*)\[\/list\]/siU", "/\[\*\](.*)/siU");
$html = array("<ol>\\1</ol>", "<ol type=\"a\">\\1</ol>",
"<ul>\\1</ul>", "<li>\\1");
$msg = preg_replace($tags, $html, $msg);
Now, since I also run nl2br() on the $msg, it replaces newlines with <br /> tags. So my list ends up looking like this:
Code:
<ol><br />
<li>Testing<br />
<li>The<br />
<li>Numbered<br />
<li>List</ol><br />
The <br />'s in there create a lot of problems with spacing and margins.
So my question is: how can I remove the newlines with my expression?
Last edited by The Hobo; Jun 5th, 2003 at 01:00 PM.
-
Jun 5th, 2003, 12:44 PM
#2
Thread Starter
Stuck in the 80s
This works:
Code:
$tags = array("/\[list=1\](.*)\[\/list\]/siU", "/\[list=2\](.*)\[\/list\]/siU",
"/\[list=3\](.*)\[\/list\]/siU", "/\[\*\](.*)(\n\r|\r\n)/siU");
$html = array("<ol $lststyle>\\1</ol>", "<ol $lststyle type=\"a\">\\1</ol>",
"<ul $lststyle>\\1</ul>", "<li>\\1");
$msg = preg_replace($tags, $html, $msg);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|