Beispiel #1
0
def prepare_style():
    """ read and process style/ directory """
    config = Config()
    # copy static files
    if not os.path.exists(os.path.join(config.outputdir, 'style')):
        os.makedirs(os.path.join(config.outputdir, 'style'))

    # copy supplementary files to ouput dir
    for filename in os.listdir(config.styledir):
        if os.path.splitext(filename)[1].lower() != '.css':
            shutil.copy(
                os.path.join(config.styledir, filename),
                os.path.join(config.outputdir, 'style')
            )

    # generate syntax highlight css and append all other CSS files
    allcss = HtmlFormatter().get_style_defs('.codehilite')
    for cssfile in glob.iglob(os.path.join(config.styledir, '*.css')):
        allcss = allcss + codecs.open(cssfile, 'r', 'utf-8').read()
    allcss = allcss.replace('{{styleurl}}', "{}style/".format(config.blogurl))

    # minimise css
    return cssmin(allcss, wrap=1000)