Edgewall Software

Ticket #2657: div_macro_fix.diff

File div_macro_fix.diff, 1.5 kB (added by cboos, 3 years ago)

Here's a possible solution, patch on top of trunk@2975

  • formatter.py

     
    107107                                  self.error) 
    108108        text = self.processor(req, text) 
    109109        if inline: 
    110             code_block_start = re.compile('^<div class="code-block">') 
     110            code_block_start = re.compile('^<div(?:\s+class="([^"]+)")?>') 
    111111            code_block_end = re.compile('</div>$') 
    112             text, nr = code_block_start.subn('<span class="code-block">', text, 1 ) 
    113             if nr: 
    114                 text, nr = code_block_end.subn('</span>', text, 1 ) 
     112            match = re.match(code_block_start, text) 
     113            if match: 
     114                if match.group(1) and 'code' in match.group(1): 
     115                    text, nr = code_block_start.subn('<span class="code-block">', text, 1 ) 
     116                    if nr: 
     117                        text, nr = code_block_end.subn('</span>', text, 1 ) 
     118                else: 
     119                    text = "</p>%s<p>" % text 
    115120            return text 
    116121        else: 
    117122            return text 
     
    405410        args = fullmatch.group('macroargs') 
    406411        try: 
    407412            macro = WikiProcessor(self.env, name) 
    408             return macro.process(self.req, args, 1) 
     413            return macro.process(self.req, args, True) 
    409414        except Exception, e: 
    410415            self.env.log.error('Macro %s(%s) failed' % (name, args), 
    411416                               exc_info=True)