~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/highlight.py

  • Committer: Max Bowsher
  • Date: 2011-03-04 15:49:43 UTC
  • mfrom: (431 trunk-rich)
  • mto: This revision was merged to the branch mainline in revision 432.
  • Revision ID: maxb@f2s.com-20110304154943-zrtlx1ipy49xc8u0
Merge trunk.

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
19
20
import cgi
20
21
 
21
22
from pygments import highlight as _highlight_func
36
37
    """
37
38
 
38
39
    if len(text) > MAX_HIGHLIGHT_SIZE:
39
 
        return map(cgi.escape, text.split('\n'))
 
40
        return map(cgi.escape,  bzrlib.osutils.split_lines(text))
40
41
 
41
42
    formatter = HtmlFormatter(style=style, nowrap=True, classprefix='pyg-')
42
43
 
48
49
        except (ClassNotFound, ValueError):
49
50
            lexer = TextLexer(encoding=encoding)
50
51
 
51
 
    hl_lines = _highlight_func(text, lexer, formatter).split('\n')
 
52
    hl_lines = _highlight_func(text, lexer, formatter)
 
53
    hl_lines = bzrlib.osutils.split_lines(hl_lines)
52
54
 
53
55
    return hl_lines