Show
Ignore:
Timestamp:
03/25/08 09:24:47 (2 years ago)
Author:
JensDiemer
Message:

move the automatic headline anchor function from tinyTextile markup ( changeset:1500 ) into a middleware. So every markups becomes headline anchors. See also: ticket:46

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/system/tinyTextile.py

    r1500 r1503  
    2828__version__ = "$Rev$" 
    2929 
    30 import sys, re, string 
     30import sys, re 
    3131 
    3232from PyLucid.tools.utils import escape 
     
    3434 
    3535 
    36 HEADLINE = ( 
    37     '<h%(no)s id="%(anchor)s">' 
    38     '<a title="Link to this section" href="%(link)s#%(anchor)s" class="anchor">' 
    39     '%(txt)s</a>' 
    40     '</h%(no)s>\n' 
    41 ) 
    42  
    43  
    4436class TinyTextileParser: 
    45     def __init__(self, out_obj, permalink, context): 
     37    def __init__(self, out_obj, context): 
    4638        self.out = out_obj 
    47         self.permalink = permalink 
    4839        self.context = context 
    4940        self.page_msg   = context["page_msg"] 
     
    5344            [ # <h1>-Headlines 
    5445                r"\Ah(\d)\. (.+)(?usm)", 
    55                 self.headline 
     46                r"<h\1>\2</h\1>" 
    5647            ], 
    5748        ]) 
     
    165156    def escaping(self, matchobj): 
    166157        return escape(matchobj.group(1)) 
    167  
    168     def headline(self, matchobj): 
    169         """ 
    170         Insert a html headline with a anchor. 
    171         """ 
    172         text = matchobj.group(2) 
    173         anchor = "".join( 
    174             [char for char in text if char in string.ascii_letters] 
    175         ) 
    176         result = HEADLINE % { 
    177             "no": matchobj.group(1), 
    178             "txt": text, 
    179             "link": self.permalink, 
    180             "anchor": anchor, 
    181         } 
    182         return result 
    183158 
    184159    def shortcutLink(self, matchobj):