anaconda / nbpresent

next generation slides for Jupyter Notebooks
BSD 3-Clause "New" or "Revised" License
161 stars 23 forks source link

avoid using "colour" module in Importing%20revealjs%20themes.ipynb #77

Open jason-s opened 8 years ago

jason-s commented 8 years ago

The colour module doesn't appear to be part of the standard conda installation. Please consider rewriting the Importing%20revealjs%20themes.ipynb notebook not to use it. If you are only dealing with #abc and #aabbcc style RGB specs, you could just use a simple function like

c_re = re.compile('^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$')

def repeat_chars(s,k):
    return ''.join(c*k for c in s)

def v2color(v):
    m = c_re.search(v)
    if not m:
        return None
    rgb = m.group(1)
    if len(rgb) == 3:
        rgb = repeat_chars(rgb,2)
    return tuple(int(rgb[k:k+2],16) for k in xrange(0,6,2))