Re: [Wikiwyg-dev] multi-line <pre> bug



On Thu, 2006-01-05 at 12:09 +0000, Dave Howorth wrote:
> There's a bug to do with multi-line PRE sections that's noted on the
> wikiwyg bugs page on www.kwiki.org (which seems to be down right now).
> 
> I got annoyed enough with it to fix it on my system. I'm not a
> Javascript wiz so there's probably much better ways to do it but here's
> my patch:

junk deleted!

That patch doesn't work when the preformatted text includes HTML
reserved characters :(  Here's another version:

--- Wikitext-orig.js    2005-11-16 17:04:28.000000000 +0000
+++ Wikitext.js 2006-01-05 15:14:27.000000000 +0000
@@ -936,7 +936,29 @@
 }

 proto.handle_start_lines = function (element, markup) {
-    var text = element.firstChild.nodeValue;
+    var text = ''
+    if (element.nodeName.toLowerCase() == 'pre') {
+        var child
+        for (child = element.firstChild; child ; child =
child.nextSibling) {
+           var name = child.nodeName
+           var value
+           if (name == '#text') {
+               value = child.nodeValue
+           }
+           else if (name.toLowerCase() == 'br') {
+               value = "\n"
+           }
+           else {
+             alert('BUG: node type "' + name + '" not expected')
+             return
+           }
+
+           text = text + value
+       }
+    }
+    else {
+       text = element.firstChild.nodeValue;
+    }
     if (!text) return;
     this.assert_blank_line();
     text = text.replace(/^/mg, markup[1]);

Cheers, Dave






This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.