Changeset 118

Show
Ignore:
Timestamp:
20-01-2008 22:26:28 (10 months ago)
Author:
s0undt3ch
Message:

Made lineanchor links unique, that was they can also be used on the paste's listing, no need to create seperate caches.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pastie/lib/highlight.py

    r117 r118  
    33from pygments.formatters import HtmlFormatter 
    44from genshi import XML 
    5 import operator 
    65import StringIO 
    76from pylons.decorators.cache import beaker_cache 
     
    9392                    num += 1 
    9493 
     94 
    9595formatter = PastieHtmlFormatter(linenos=True, cssclass="syntax", 
    9696                                encoding='utf-8', lineanchors='line', 
     
    103103    else: 
    104104        diff_to_id = None 
     105 
    105106    @beaker_cache(type='memory', expire='never') 
    106107    def cached_wrapper(paste_id=None, truncate_lines=None, diff_to_id=None): 
     
    118119        if diff_to: 
    119120            lexex = get_lexer_by_name('diff') 
     121 
     122        formatter.lineanchors='paste-%d-line' % paste_id 
    120123        return XML(highlight(source, lexer, formatter).decode('utf-8')) 
    121124    return cached_wrapper(code.id, truncate_lines, diff_to_id)