Changeset 684

Show
Ignore:
Timestamp:
04/21/06 07:20:54 (3 years ago)
Author:
athomas
Message:

AcronymsPlugin:

Fix for acronyms without IDs (eg. URIs).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • acronymsplugin/0.9/tracacronyms/acronyms.py

    r680 r684  
    77class Acronyms(Component): 
    88    """ Automatically generates HTML acronyms from definitions in tables in a 
    9     Wiki page (AcronymDefinitions by default). 
    10      
    11     Acronyms are in the form `<acronym>[<id>]` and are defined in a table with 
    12     four columns: 
    13      
    14         `Acronym, Description [, URL [, ID URL]]` 
    15  
    16     Only the first two columns are required. 
    17      
    18     If an `<id>` is provided, the ID URL is used and any occurrences of the symbol 
    19     `$1` in the description and the ID URL are substituted with the `<id>`. 
    20  
    21     Rows starting with `||'` are ignored. 
    22  
    23     eg. The following acronym definition table: 
    24  
    25     {{{ 
    26     ||'''Acronym'''||'''Description'''||'''URL'''||'''ID URL'''|| 
    27     ||RFC||Request For Comment $1||http://www.ietf.org/rfc.html||http://www.ietf.org/rfc/rfc$1.txt|| 
    28     }}} 
    29  
    30     Has the following effect: 
    31      
    32     `RFC` becomes 
    33     {{{ 
    34         <a href="http://www.ietf.org/rfc.html"> 
    35          <acronym title="Request For Comment"> 
    36           RFC 
    37          </acronym> 
    38         </a> 
    39     }}} 
    40  
    41     `RFC2315` becomes 
    42     {{{ 
    43         <a href="http://www.ietf.org/rfc/rfc2315.txt"> 
    44          <acronym title="Request For Comment 2315"> 
    45           RFC 2315 
    46          </acronym> 
    47         </a> 
    48     }}} 
    49     """ 
     9    Wiki page (AcronymDefinitions by default).  """ 
    5010 
    5111    implements(IWikiSyntaxProvider, IWikiChangeListener) 
     
    7030                    a, d, u, s = ([i.strip() for i in line.strip('||').split('||')] + ['', ''])[0:4] 
    7131                    assert self.valid_acronym.match(a), "Invalid acronym %s" % a 
    72                     self.acronyms[a] = (d, u, s
     32                    self.acronyms[a] = (escape(d), escape(u), escape(s)
    7333                except Exception, e: 
    7434                    self.env.log.warning("Invalid acronym line: %s (%s)", line, e) 
     
    9151            acronym += ' ' + match.group('acronymselector') 
    9252 
    93         href, title, acronym = escape(href), escape(title), escape(acronym) 
    9453        if href: 
    9554            return Markup('<a class="acronym" href="%s"><acronym title="%s">%s</acronym></a>'