Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…etail?id=5

git-svn-id: https://jscreole.svn.sourceforge.net/svnroot/jscreole@11 ecc56831-dd78-4ae9-9644-fc3fc16e6aa9
  • Loading branch information
codeholic committed Feb 3, 2009
1 parent f7c5b26 commit 6db0d97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions creole.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Parse.Simple.Base.prototype = {
else {
options = this.options;
}
data = data.replace(/\r/g, ''); // for IE
if (options.IE) { data = data.replace(/\r/g, ''); }
this.grammar.root.apply(node, data, options);
if (options.IE) { node.innerHTML = node.innerHTML.replace(/\n/g, '\r\n'); }
}
};

Expand Down Expand Up @@ -102,7 +103,7 @@ Parse.Simple.Base.Rule.prototype = {
if (this.attrs) {
for (var i in this.attrs) {
target.setAttribute(i, this.attrs[i]);
if (i == 'class') { target.className = this.attrs[i]; } // for IE
if (options.IE && i == 'class') { target.className = this.attrs[i]; }
}
}
return this;
Expand Down
12 changes: 7 additions & 5 deletions lib/Parse/Simple/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Parse.Simple.Base.prototype = {
else {
options = this.options;
}
data = data.replace(/\r/g, ''); // for IE
if (options.IE) { data = data.replace(/\r/g, ''); }
this.grammar.root.apply(node, data, options);
if (options.IE) { node.innerHTML = node.innerHTML.replace(/\n/g, '\r\n'); }
}
};

Expand Down Expand Up @@ -77,7 +78,7 @@ Parse.Simple.Base.Rule.prototype = {
if (this.attrs) {
for (var i in this.attrs) {
target.setAttribute(i, this.attrs[i]);
if (i == 'class') { target.className = this.attrs[i]; } // for IE
if (options.IE && i == 'class') { target.className = this.attrs[i]; }
}
}
return this;
Expand Down Expand Up @@ -189,9 +190,10 @@ that also must be an object of any type. The root is cast to a
type specified by C<this.ruleConstructor>, being C<Parse.Simple.Base.Rule>
by default. See L<"Rules"> for more info on defining rule objects.
Options are not used in C<Parse.Simple.Base> itself and present merely for
derived objects' and subinterfaces' convenience. If passed it should be an
object.
Options are optional but if passed it must be an object. The only option
available in C<Parse.Simple.Base> is C<IE>, which should be set C<true> for
Microsoft Internet Explorer compatibility. Derived objects and subinterfaces
may extend the C<options> object with their own options.
=item parse(node, data, options)
Expand Down
12 changes: 6 additions & 6 deletions tests/creole.html
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,9 @@
},
{
name: "Preformatted block + CR",
input: "{{{\r\nsome text\r\n}}}",
output: "<pre>some text\n</pre>"
input: "{{{\r\nsome text\r\nsome text\r\n}}}",
output: "<pre>some text\r\nsome text\r\n</pre>",
options: { IE: true }
},
{
name: "Formatting interwiki links with function",
Expand All @@ -559,21 +560,20 @@
} );

var div = document.createElement('div');
creole.parse(div, '* aaaa');

for (var i in tests) {
var test = tests[i];

var expected = document.createElement('div');
expected.innerHTML = tests[i].output;
expected.innerHTML = test.output;
expected = expected.cloneNode(true);

var div = document.createElement('div');
creole.parse(div, tests[i].input);
creole.parse(div, test.input, test.options);
div.innerHTML = div.innerHTML;
div = div.cloneNode(true);

is(expected.innerHTML, div.innerHTML, tests[i].name);
is(expected.innerHTML, div.innerHTML, test.name);
}
//]]>--></script>
</pre>
Expand Down

0 comments on commit 6db0d97

Please sign in to comment.