changeset 1786:2c9853dc11f8

new wiki markup for /* inline comments */, support toggling visibility of them
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 22 Feb 2007 12:04:46 +0100
parents e54f99c9beba
children f4a941fe32f8
files MoinMoin/parser/text_moin_wiki.py docs/CHANGES wiki/htdocs/common/js/common.js wiki/htdocs/modern/css/common.css
diffstat 4 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_moin_wiki.py	Wed Feb 21 23:06:46 2007 +0100
+++ b/MoinMoin/parser/text_moin_wiki.py	Thu Feb 22 12:04:46 2007 +0100
@@ -78,6 +78,7 @@
 (?P<small>(\~- ?|-\~))
 (?P<big>(\~\+ ?|\+\~))
 (?P<strike>(--\(|\)--))
+(?P<remark>(/\* ?| ?\*/))
 (?P<rule>-{4,})
 (?P<comment>^\#\#.*$)
 (?P<macro>\[\[(%%(macronames)s)(?:\(.*?\))?\]\]))
@@ -138,6 +139,7 @@
         self.is_strike = False
         self.is_big = False
         self.is_small = False
+        self.is_remark = False
 
         self.lineno = 0
         self.in_list = 0 # between <ul/ol/dl> and </ul/ol/dl>
@@ -235,6 +237,16 @@
         self.is_strike = not self.is_strike
         return self.formatter.strike(self.is_strike)
 
+    def _remark_repl(self, word):
+        """Handle remarks."""
+        # XXX we don't really enforce the correct sequence /* ... */ here
+        self.is_remark = not self.is_remark
+        span_kw = {
+            'style': self.request.user.show_comments and "display:''" or "display:none",
+            'class': "comment",
+        }
+        return self.formatter.span(self.is_remark, **span_kw)
+
     def _small_repl(self, word):
         """Handle small."""
         if word.strip() == '~-' and self.is_small:
--- a/docs/CHANGES	Wed Feb 21 23:06:46 2007 +0100
+++ b/docs/CHANGES	Thu Feb 22 12:04:46 2007 +0100
@@ -308,10 +308,11 @@
       The same thing will work for any other css classes you have.
       If the css classes contain the word "comment", they will trigger some
       special feature, see next item:
+    * New wiki markup for /* inline comments */ - they get rendered as a span
+      with class="comment", see next item:
     * There is a new item in the edit bar: "Comments". If you click it, the
-      visibility of the comment sections will be toggled. A comment section is
-      any div of class "comment". There is a user preferences item
-      "show_comments" to set if the default view shows them or not.
+      visibility of all class "comment" tags will be toggled. There is a user
+      preferences item "show_comments" to set if the default view shows them or not.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page
--- a/wiki/htdocs/common/js/common.js	Wed Feb 21 23:06:46 2007 +0100
+++ b/wiki/htdocs/common/js/common.js	Thu Feb 22 12:04:46 2007 +0100
@@ -169,8 +169,8 @@
 }
 
 function toggleComments() {
-    // Toggle visibility of every div with class == *comment*
-    var all = document.getElementsByTagName('div');
+    // Toggle visibility of every tag with class == *comment*
+    var all = document.getElementsByTagName('*');
     for (i = 0; i < all.length; i++){
         el = all[i];
         if ( el.className.indexOf('comment') >= 0 ){
--- a/wiki/htdocs/modern/css/common.css	Wed Feb 21 23:06:46 2007 +0100
+++ b/wiki/htdocs/modern/css/common.css	Thu Feb 22 12:04:46 2007 +0100
@@ -99,7 +99,7 @@
 .dashed { border: 2px dashed #000000; padding: 2px; }
 .dotted { border: 2px dotted #000000; padding: 2px; }
 
-.comment { color: #555555; }
+.comment { color: #555555; background-color: #DDDDFF; }
 
 table
 {