예제 #1
0
def annotate_highlight(filenode,
                       annotate_from_changeset_func=None,
                       order=None,
                       headers=None,
                       **options):
    """
    Returns html portion containing annotated table with 3 columns: line
    numbers, changeset information and pygmentized line of code.

    :param filenode: FileNode object
    :param annotate_from_changeset_func: function taking changeset and
      returning single annotate cell; needs break line at the end
    :param order: ordered sequence of ``ls`` (line numbers column),
      ``annotate`` (annotate column), ``code`` (code column); Default is
      ``['ls', 'annotate', 'code']``
    :param headers: dictionary with headers (keys are whats in ``order``
      parameter)
    """
    from rhodecode.lib.utils import get_custom_lexer
    options['linenos'] = True
    formatter = AnnotateHtmlFormatter(
        filenode=filenode,
        order=order,
        headers=headers,
        annotate_from_changeset_func=annotate_from_changeset_func,
        **options)
    lexer = get_custom_lexer(filenode.extension) or filenode.lexer
    highlighted = highlight(filenode.content, lexer, formatter)
    return highlighted
예제 #2
0
def pygmentize(filenode, **kwargs):
    """
    pygmentize function using pygments

    :param filenode:
    """
    lexer = get_custom_lexer(filenode.extension) or filenode.lexer
    return literal(code_highlight(filenode.content, lexer,
                                  CodeHtmlFormatter(**kwargs)))
예제 #3
0
def pygmentize(filenode, **kwargs):
    """
    pygmentize function using pygments

    :param filenode:
    """
    lexer = get_custom_lexer(filenode.extension) or filenode.lexer
    return literal(
        code_highlight(filenode.content, lexer, CodeHtmlFormatter(**kwargs)))
예제 #4
0
def annotate_highlight(filenode, annotate_from_changeset_func=None,
        order=None, headers=None, **options):
    """
    Returns html portion containing annotated table with 3 columns: line
    numbers, changeset information and pygmentized line of code.

    :param filenode: FileNode object
    :param annotate_from_changeset_func: function taking changeset and
      returning single annotate cell; needs break line at the end
    :param order: ordered sequence of ``ls`` (line numbers column),
      ``annotate`` (annotate column), ``code`` (code column); Default is
      ``['ls', 'annotate', 'code']``
    :param headers: dictionary with headers (keys are whats in ``order``
      parameter)
    """
    from rhodecode.lib.utils import get_custom_lexer
    options['linenos'] = True
    formatter = AnnotateHtmlFormatter(filenode=filenode, order=order,
        headers=headers,
        annotate_from_changeset_func=annotate_from_changeset_func, **options)
    lexer = get_custom_lexer(filenode.extension) or filenode.lexer
    highlighted = highlight(filenode.content, lexer, formatter)
    return highlighted