| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Trac
Revision: 7509
Author: rblank
Date: 04 Sep 2008 13:58:56
Diff at Trac: http://trac.edgewall.org/changeset/7509
Changes:Added a new `htmlcomment` WikiProcessor that allows adding HTML comments to the output of wiki pages.
Closes #6508.
Files:| ... | ...@@ -551,6 +551,66 @@ | |
| 551 | 551 | <div>Click me</div> |
| 552 | 552 | ------------------------------ |
| 553 | 553 | […] |
| 554 | ============================== HTML comment wiki processor | |
| 555 | Before | |
| 556 | {{{ | |
| 557 | #!htmlcomment | |
| 558 | This is a comment <em>with embedded tags & entities</em> | |
| 559 | }}} | |
| 560 | After | |
| 561 | ------------------------------ | |
| 562 | <p> | |
| 563 | Before | |
| 564 | </p> | |
| 565 | <!-- | |
| 566 | This is a comment <em>with embedded tags & entities</em> | |
| 567 | --> | |
| 568 | <p> | |
| 569 | After | |
| 570 | </p> | |
| 571 | ------------------------------ | |
| 572 | Before | |
| 573 | […] | |
| 574 | After | |
| 575 | ============================== HTML comment wiki processor, comment ends with "-" | |
| 576 | Before | |
| 577 | {{{ | |
| 578 | #!htmlcomment | |
| 579 | This comment ends with - | |
| 580 | }}} | |
| 581 | After | |
| 582 | ------------------------------ | |
| 583 | <p> | |
| 584 | Before | |
| 585 | </p> | |
| 586 | <!-- | |
| 587 | This comment ends with - | |
| 588 | --> | |
| 589 | <p> | |
| 590 | After | |
| 591 | </p> | |
| 592 | ------------------------------ | |
| 593 | Before | |
| 594 | […] | |
| 595 | After | |
| 596 | ============================== HTML comment wiki processor, comment contains "--" | |
| 597 | Before | |
| 598 | {{{ | |
| 599 | #!htmlcomment | |
| 600 | The character sequence -- is not allowed in comments | |
| 601 | }}} | |
| 602 | After | |
| 603 | ------------------------------ | |
| 604 | <p> | |
| 605 | Before | |
| 606 | </p> | |
| 607 | <div class="system-message"><strong>Error: Forbidden character sequence "--" in htmlcomment wiki code block</strong></div><p> | |
| 608 | After | |
| 609 | </p> | |
| 610 | ------------------------------ | |
| 611 | Before | |
| 612 | […] | |
| 613 | After | |
| 554 | 614 | ============================== div and span wiki processors |
| 555 | 615 | And now it's [[span('''TIME FOR BED!,class=important)]]. Really. |
| 556 | 616 | {{{ |
| ... | ...@@ -79,6 +79,7 @@ | |
| 79 | 79 | self.macro_provider = None |
| 80 | 80 | |
| 81 | 81 | builtin_processors = {'html': self._html_processor, |
| 82 | 'htmlcomment': self._htmlcomment_processor, | |
| 82 | 83 | 'default': self._default_processor, |
| 83 | 84 | 'comment': self._comment_processor, |
| 84 | 85 | 'div': self._div_processor, |
| ... | ...@@ -131,6 +132,12 @@ | |
| 131 | 132 | return system_message(_('HTML parsing error: %(message)s', |
| 132 | 133 | message=escape(e.msg)), line) |
| 133 | 134 | |
| 135 | def _htmlcomment_processor(self, text): | |
| 136 | if "--" in text: | |
| 137 | return system_message(_('Error: Forbidden character sequence ' | |
| 138 | '"--" in htmlcomment wiki code block')) | |
| 139 | return Markup('<!--\n%s-->\n' % text) | |
| 140 | ||
| 134 | 141 | def _elt_processor(self, eltname, format_to, text, args): |
| 135 | 142 | elt = getattr(tag, eltname)(**args) |
| 136 | 143 | if not WikiSystem(self.env).render_unsafe_content: |