News:

Wondering if this will always be free?  See why free is better.

Main Menu

Numbered list

Started by b0x, December 18, 2004, 06:09:50 AM

Previous topic - Next topic

b0x

Is it possible to have a numbered list instead of this:
  • test
  • testtest

Peter Duggan

Not as standard, but it would be an easy mod (trivial if you want ordered lists *instead* of unordered, but not hard to offer both).

Peter Duggan

#2
For a quick hack, search Subs.php for:

// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['list']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',


And add after:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => isset($disabled['olist']) || isset($disabled['li']) ? '' : '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[/olist\](?:<br />)?~i' => isset($disabled['olist']) || isset($disabled['li']) ? '' : '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['olist']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',


And type 'olist' instead of 'list' for the tags.

b0x


Peter Duggan

PS Needs a little tweaking because some of the alternate list style tags (eg #) still produce their unordered bullet styles, but it's fine with 'li' and I'll sort the others soon.

Peter Duggan

Don't think it's worth modifying further because that'd involve the 'li' as well as 'list' tags so, on second thoughts (and because the results of # etc. are hardly catastrophic), I'd just stick to posting with the valid opening and closing 'li' tags.

b0x

Thanks for the help Peter!

Peter Duggan

#7
Just realised (after deciding to upload this to one of my sites) that I've inadvertently posted CVS code where things have been changed. So the equivalent hack for RC2 should be to search Subs.php for:

// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


And add after:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[/olist\](?:<br />)?~i' => '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


Sorry about that!

Peter Duggan

Also just discovered that the new 'olist' tag isn't recognised by the 'printpage' action, but I did say it was a *quick* hack. So you might be interested in Anguz's Custom BB Code mod, but I might equally well finish the ordered list tag properly sometime (which should also mean including some alternative list styles) because it's something I've always missed too.

Peter Duggan

#9
Quote from: Peter Duggan on December 18, 2004, 02:57:09 PM
which should also mean including some alternative list styles

Here we go again:

// Lists... [olist][*]First, ...[o]Second![li]THIRD!!![/li][/olist]
'~\[olist\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0;">',
'~\[olist style=la\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: lower-alpha;">',
'~\[olist style=ua\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: upper-alpha;">',
'~\[olist style=lr\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: lower-roman;">',
'~\[olist style=ur\](?:<br />)?~i' => '<ol style="margin-top: 0; margin-bottom: 0; list-style-type: upper-roman;">',
'~\[/olist\](?:<br />)?~i' => '</ol>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => '<li>$1</li>',


Lower/upper alpha and lower/upper roman styles (haven't bothered with decimal because you'll get that by default with no 'style=' attribute). So type

[olist style=la]

For lower alpha,

[olist style=ua]

For upper alpha,

[olist style=lr]

For lower roman and

[olist style=ur]

For upper roman.

b0x


Sandwich

Sorry to bump this, but is there any chance of getting an updated and working version of this? Perhaps make it into a MOD?

Advertisement: