Edgewall Software

Ticket #8204: span-blocks-r9193.patch

File span-blocks-r9193.patch, 3.9 KB (added by cboos, 2 years ago)

WikiProcessors: span can be called as a wiki processor.

  • trac/wiki/formatter.py

    WikiProcessors: `span` can be called as a wiki processor.
    
    diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py
    a b class WikiProcessor(object): 
    153153                                    '"--" in htmlcomment wiki code block')) 
    154154        return Markup('<!--\n%s-->\n' % text) 
    155155         
    156     def _elt_processor(self, eltname, format_to, text, args): 
    157         # Note: as long as _processor_param_re is not re.UNICODE, **args is OK 
    158         elt = getattr(tag, eltname)(**(args or {})) 
     156    def _elt_processor(self, eltname, format_to, text): 
     157        # Note: as long as _processor_param_re is not re.UNICODE, **args is OK. 
     158        # Also, parse_args is using strict mode when processing [[span(...)]]. 
     159        elt = getattr(tag, eltname)(**(self.args or {})) 
    159160        if not WikiSystem(self.env).render_unsafe_content: 
    160161            sanitized_elt = getattr(tag, eltname) 
    161162            for (k, data, pos) in (Stream(elt) | self._sanitizer): 
    class WikiProcessor(object): 
    170171            self.args = {} 
    171172        if 'class' not in self.args: 
    172173            self.args['class'] = 'wikipage' 
    173         return self._elt_processor('div', format_to_html, text, self.args) 
     174        return self._elt_processor('div', format_to_html, text) 
    174175     
    175176    def _span_processor(self, text): 
    176         args, kwargs = parse_args(text, strict=True) 
    177         return self._elt_processor('span', format_to_oneliner, ', '.join(args), 
    178                                    kwargs) 
     177        if self.args is None: 
     178            args, self.args = parse_args(text, strict=True) 
     179            text = ', '.join(args) 
     180        return self._elt_processor('span', format_to_oneliner, text) 
    179181 
    180182    def _td_processor(self, text): 
    181183        return self._tablecell_processor('td', text) 
    class WikiProcessor(object): 
    185187     
    186188    def _tr_processor(self, text): 
    187189        try: 
    188             elt = self._elt_processor('tr', self._format_row, text, self.args) 
     190            elt = self._elt_processor('tr', self._format_row, text) 
    189191            self.formatter.open_table() 
    190192            return elt 
    191193        except ProcessorError, e: 
    class WikiProcessor(object): 
    197199        if 'class' not in self.args: 
    198200            self.args['class'] = 'wiki' 
    199201        try: 
    200             return self._elt_processor('table', self._format_table, text, 
    201                                        self.args) 
     202            return self._elt_processor('table', self._format_table, text) 
    202203        except ProcessorError, e: 
    203204            return system_message(e) 
    204205     
    205206    def _tablecell_processor(self, eltname, text): 
    206207        self.formatter.open_table_row() 
    207         return self._elt_processor(eltname, format_to_html, text, self.args) 
     208        return self._elt_processor(eltname, format_to_html, text) 
    208209 
    209210    _has_multiple_tables_re = re.compile(r"</table>.*?<table", 
    210211                                         re.MULTILINE | re.DOTALL) 
  • trac/wiki/tests/wiki-tests.txt

    diff --git a/trac/wiki/tests/wiki-tests.txt b/trac/wiki/tests/wiki-tests.txt
    a b Done. 
    750750------------------------------ 
    751751 […] 
    752752Done. 
     753============================== span wiki processor 
     754{{{ 
     755#!span style="background: #ffd" 
     756This is a multiline span 
     757 - only ''inline'' wiki formatting here, of course 
     758 - this is only a span after all! 
     759}}} 
     760TODO: should be expanded in inline mode 
     761------------------------------ 
     762<span style="background: #ffd">This is a multiline span 
     763 - only <i>inline</i> wiki formatting here, of course 
     764 - this is only a span after all!</span><p> 
     765TODO: should be expanded in inline mode 
     766</p> 
     767------------------------------ 
     768 […] 
     769TODO: should be expanded in inline mode 
    753770============================== div and Span wiki processors 
    754771{{{ 
    755772#!div ; style="background: #aeaeae"