Render highstate to a text format (default Markdown)

    if `jinja_template_text` is not set, `jinja_template_function` is used.

    jinja_template_text: jinja text that the render uses to create the document.
    jinja_template_function: a salt module call that returns template text.
        options:
            highstate_doc.markdown_basic_jinja_template
            highstate_doc.markdown_default_jinja_template
            highstate_doc.markdown_full_jinja_template

def render(jinja_template_text=None, jinja_template_function='highstate_doc.markdown_default_jinja_template', **kwargs):
    '''
    Render highstate to a text format (default Markdown)

    if `jinja_template_text` is not set, `jinja_template_function` is used.

    jinja_template_text: jinja text that the render uses to create the document.
    jinja_template_function: a salt module call that returns template text.
        options:
            highstate_doc.markdown_basic_jinja_template
            highstate_doc.markdown_default_jinja_template
            highstate_doc.markdown_full_jinja_template
    '''
    config = _get_config(**kwargs)
    lowstates = proccess_lowstates(**kwargs)
    # TODO: __env__,
    context = {
        'saltenv': None,
        'config': config,
        'lowstates': lowstates,
        'salt': __salt__,
        'pillar': __pillar__,
        'grains': __grains__,
        'opts': __opts__,
        'kwargs': kwargs,
    }
    template_text = jinja_template_text
    if template_text is None and jinja_template_function:
        template_text = __salt__[jinja_template_function](**kwargs)
    if template_text is None:
        raise Exception('No jinja template text')

    txt = tpl.render_jinja_tmpl(template_text, context, tmplpath=None)
    # after proccessing the template replace passwords or other data.
    rt = config.get('replace_text_regex')
    for r in rt:
        txt = re.sub(r, rt[r], txt)
    return txt