DanielNewby edited this page Sep 13, 2010 · 12 revisions
Clone this wiki locally

listalyze helps you convert a list of “numbers” into a CSS style and a list of integers.

“Numbers” is in scare quotes because it includes both proper numbers (1, 2, 3, …) and other ordered sequences used to number lists (such as A, B, C, …).

A typical use looks like this:

>>> from listalyze import *
>>> listalyze( [u’A.‘, u’B.‘, u’D.‘] )
(u’upper-alpha’, [1, 2, 4], False)

Which you could turn into HTML code something like this:

    <OL STYLE="list-style-type: upper-alpha;">
        <LI VALUE="1">Item labeled "A."</LI>
        <LI VALUE="2">Item labeled "B."</LI>
        <LI VALUE="4">Item labeled "D."</LI>

listalyze insists on all-Unicode for its strings: u’example’ instead of ‘example’. The reason is to prevent runtime errors from suddenly appearing when someone starts feeding in text with an unexpected encoding. You are forced to use proper decoding from the start.