~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/highlight.py

  • Committer: Ian Clatworthy
  • Date: 2010-04-23 00:02:29 UTC
  • mfrom: (407.1.2 loggerhead)
  • Revision ID: ian.clatworthy@canonical.com-20100423000229-ysxj7lzkx6oklt35
Skip syntax highlighting on files over 512K

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
#
18
18
 
19
 
import bzrlib.osutils
20
19
import cgi
21
20
 
22
21
from pygments import highlight as _highlight_func
37
36
    """
38
37
 
39
38
    if len(text) > MAX_HIGHLIGHT_SIZE:
40
 
        return map(cgi.escape,  bzrlib.osutils.split_lines(text))
 
39
        return map(cgi.escape, text.split('\n'))
41
40
 
42
41
    formatter = HtmlFormatter(style=style, nowrap=True, classprefix='pyg-')
43
42
 
49
48
        except (ClassNotFound, ValueError):
50
49
            lexer = TextLexer(encoding=encoding)
51
50
 
52
 
    hl_lines = _highlight_func(text, lexer, formatter)
53
 
    hl_lines = bzrlib.osutils.split_lines(hl_lines)
 
51
    hl_lines = _highlight_func(text, lexer, formatter).split('\n')
54
52
 
55
53
    return hl_lines