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): |
| 153 | 153 | '"--" in htmlcomment wiki code block')) |
| 154 | 154 | return Markup('<!--\n%s-->\n' % text) |
| 155 | 155 | |
| 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 {})) |
| 159 | 160 | if not WikiSystem(self.env).render_unsafe_content: |
| 160 | 161 | sanitized_elt = getattr(tag, eltname) |
| 161 | 162 | for (k, data, pos) in (Stream(elt) | self._sanitizer): |
| … |
… |
class WikiProcessor(object): |
| 170 | 171 | self.args = {} |
| 171 | 172 | if 'class' not in self.args: |
| 172 | 173 | 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) |
| 174 | 175 | |
| 175 | 176 | 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) |
| 179 | 181 | |
| 180 | 182 | def _td_processor(self, text): |
| 181 | 183 | return self._tablecell_processor('td', text) |
| … |
… |
class WikiProcessor(object): |
| 185 | 187 | |
| 186 | 188 | def _tr_processor(self, text): |
| 187 | 189 | try: |
| 188 | | elt = self._elt_processor('tr', self._format_row, text, self.args) |
| | 190 | elt = self._elt_processor('tr', self._format_row, text) |
| 189 | 191 | self.formatter.open_table() |
| 190 | 192 | return elt |
| 191 | 193 | except ProcessorError, e: |
| … |
… |
class WikiProcessor(object): |
| 197 | 199 | if 'class' not in self.args: |
| 198 | 200 | self.args['class'] = 'wiki' |
| 199 | 201 | try: |
| 200 | | return self._elt_processor('table', self._format_table, text, |
| 201 | | self.args) |
| | 202 | return self._elt_processor('table', self._format_table, text) |
| 202 | 203 | except ProcessorError, e: |
| 203 | 204 | return system_message(e) |
| 204 | 205 | |
| 205 | 206 | def _tablecell_processor(self, eltname, text): |
| 206 | 207 | 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) |
| 208 | 209 | |
| 209 | 210 | _has_multiple_tables_re = re.compile(r"</table>.*?<table", |
| 210 | 211 | re.MULTILINE | re.DOTALL) |
diff --git a/trac/wiki/tests/wiki-tests.txt b/trac/wiki/tests/wiki-tests.txt
|
a
|
b
|
Done. |
| 750 | 750 | ------------------------------ |
| 751 | 751 | […] |
| 752 | 752 | Done. |
| | 753 | ============================== span wiki processor |
| | 754 | {{{ |
| | 755 | #!span style="background: #ffd" |
| | 756 | This is a multiline span |
| | 757 | - only ''inline'' wiki formatting here, of course |
| | 758 | - this is only a span after all! |
| | 759 | }}} |
| | 760 | TODO: 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> |
| | 765 | TODO: should be expanded in inline mode |
| | 766 | </p> |
| | 767 | ------------------------------ |
| | 768 | […] |
| | 769 | TODO: should be expanded in inline mode |
| 753 | 770 | ============================== div and Span wiki processors |
| 754 | 771 | {{{ |
| 755 | 772 | #!div ; style="background: #aeaeae" |