Set general layout and style properties of text and code cells

def style_layout(style_less,
                 theme='grade3',
                 cursorwidth=2,
                 cursorcolor='default',
                 cellwidth='980',
                 lineheight=170,
                 margins='auto',
                 vimext=False,
                 toolbar=False,
                 nbname=False,
                 kernellogo=False,
                 altprompt=False,
                 altmd=False,
                 altout=False,
                 hideprompt=False):
    """Set general layout and style properties of text and code cells"""

    # write theme name to ~/.jupyter/custom/ (referenced by jtplot.py)
    with fileOpen(theme_name_file, 'w') as f:
        f.write(theme)

    if (os.path.isdir(styles_dir_user) and
            '{}.less'.format(theme) in os.listdir(styles_dir_user)):
        theme_relpath = os.path.relpath(
            os.path.join(styles_dir_user, theme), package_dir)
    else:
        theme_relpath = os.path.relpath(
            os.path.join(styles_dir, theme), package_dir)

    style_less += '@import "{}";\n'.format(theme_relpath)

    textcell_bg = '@cc-input-bg'
    promptText = '@input-prompt'
    promptBG = '@cc-input-bg'
    promptPadding = '.25em'
    promptBorder = '2px solid @prompt-line'
    tcPromptBorder = '2px solid @tc-prompt-std'
    promptMinWidth = 11.5
    outpromptMinWidth = promptMinWidth # remove + 3 since it will overlay output print() text
    tcPromptWidth = promptMinWidth + 3
    tcPromptFontsize = "@prompt-fontsize"
    ccOutputBG = '@cc-output-bg-default'

    if theme == 'grade3':
        textcell_bg = '@notebook-bg'
    if altprompt:
        promptPadding = '.1em'
        promptMinWidth = 8
        outpromptMinWidth = promptMinWidth + 3
        tcPromptWidth = promptMinWidth + 3
        promptText = 'transparent'
        tcPromptBorder = '2px solid transparent'
    if altmd:
        textcell_bg = '@notebook-bg'
        tcPromptBorder = '2px dotted @tc-border-selected'
    if altout:
        ccOutputBG = '@notebook-bg'
    if margins != 'auto':
        margins = '{}px'.format(margins)
    if '%' not in cellwidth:
        cellwidth = str(cellwidth) + 'px'

    style_less += '@container-margins: {};\n'.format(margins)
    style_less += '@cell-width: {}; \n'.format(cellwidth)
    style_less += '@cc-line-height: {}%; \n'.format(lineheight)
    style_less += '@text-cell-bg: {}; \n'.format(textcell_bg)
    style_less += '@cc-prompt-width: {}ex; \n'.format(promptMinWidth)
    style_less += '@cc-prompt-bg: {}; \n'.format(promptBG)
    style_less += '@cc-output-bg: {}; \n'.format(ccOutputBG)
    style_less += '@prompt-text: {}; \n'.format(promptText)
    style_less += '@prompt-padding: {}; \n'.format(promptPadding)
    style_less += '@prompt-border: {}; \n'.format(promptBorder)
    style_less += '@prompt-min-width: {}ex; \n'.format(promptMinWidth)
    style_less += '@out-prompt-min-width: {}ex; \n'.format(outpromptMinWidth)
    style_less += '@tc-prompt-width: {}ex; \n'.format(tcPromptWidth)
    style_less += '@tc-prompt-border: {}; \n'.format(tcPromptBorder)
    style_less += '@cursor-width: {}px; \n'.format(cursorwidth)
    style_less += '@cursor-info: @cursor-width solid {}; \n'.format(
        cursorcolor)
    style_less += '@tc-prompt-fontsize: {}; \n'.format(tcPromptFontsize)
    style_less += '\n\n'

    # read-in notebook.less (general nb style)
    with fileOpen(nb_style, 'r') as notebook:
        style_less += notebook.read() + '\n'

    # read-in cells.less (cell layout)
    with fileOpen(cl_style, 'r') as cells:
        style_less += cells.read() + '\n'

    # read-in extras.less (misc layout)
    with fileOpen(ex_style, 'r') as extras:
        style_less += extras.read() + '\n'

    # read-in codemirror.less (syntax-highlighting)
    with fileOpen(cm_style, 'r') as codemirror:
        style_less += codemirror.read() + '\n'
    with fileOpen(comp_style, 'r') as codemirror:
        style_less += codemirror.read() + '\n'

    style_less += toggle_settings(
        toolbar, nbname, hideprompt, kernellogo) + '\n'
    if vimext:
        set_vim_style(theme)

    return style_less