]> git.wincent.com - wikitext.git/commitdiff
Fix pre indentation
authorWincent Colaiuta <win@wincent.com>
Fri, 8 Feb 2008 19:04:45 +0000 (20:04 +0100)
committerWincent Colaiuta <win@wincent.com>
Fri, 8 Feb 2008 19:04:45 +0000 (20:04 +0100)
Adjust the specs and add a missing call to the indent function when
opening a pre span.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
ext/parser.c
spec/pre_spec.rb

index 2a43055f0d708510a6a4e40f19dc7f6622769d64..93ce26ef7877f7f9e4b0ad09a5b958d48f520ec4 100644 (file)
@@ -901,6 +901,7 @@ VALUE Wikitext_parser_parse(int argc, VALUE *argv, VALUE self)
                 if (!ary_includes(scope, PRE))
                 {
                     _Wikitext_pop_excess_elements(parser);
+                    _Wikitext_indent(parser);
                     rb_str_cat(output, pre_start, sizeof(pre_start) - 1);
                     ary_push(scope, PRE);
                 }
index 7744851856359b9177b070a61aa3abd60b09d6f9..0cd48d53fb69984e5dd2d0749a317e4885cbe089 100755 (executable)
@@ -31,21 +31,41 @@ describe Wikitext::Parser, 'parsing <pre> blocks' do
 
   it 'should allow nesting inside a <blockquote> block' do
     # nesting inside single blockquotes
-    @parser.parse(">  foo").should == "<blockquote>\n<pre>foo</pre>\n</blockquote>\n"
+    @parser.parse(">  foo").should == "<blockquote>\n  <pre>foo</pre>\n</blockquote>\n"
 
     # same, but continued over multiple lines
-    @parser.parse(">  foo\n>  bar").should == "<blockquote>\n<pre>foo\nbar</pre>\n</blockquote>\n"
+    @parser.parse(">  foo\n>  bar").should == "<blockquote>\n  <pre>foo\nbar</pre>\n</blockquote>\n"
 
     # nesting inside double blockquotes
-    @parser.parse("> >  foo").should == "<blockquote>\n<blockquote>\n<pre>foo</pre>\n</blockquote>\n</blockquote>\n"
+    @parser.parse("> >  foo").should == <<-END
+<blockquote>
+  <blockquote>
+    <pre>foo</pre>
+  </blockquote>
+</blockquote>
+END
 
     # same, but continued over multiple lines
-    @parser.parse("> >  foo\n> >  bar").should == "<blockquote>\n<blockquote>\n<pre>foo\nbar</pre>\n</blockquote>\n</blockquote>\n"
+    @parser.parse("> >  foo\n> >  bar").should == <<-END
+<blockquote>
+  <blockquote>
+    <pre>foo
+bar</pre>
+  </blockquote>
+</blockquote>
+END
   end
 
   it 'should automatically close preceding blocks at the same depth' do
-    @parser.parse("> foo\n bar").should == "<blockquote>\n<p>foo</p>\n</blockquote>\n<pre>bar</pre>\n"
-    expected = "<blockquote>\n<blockquote>\n<p>foo</p>\n</blockquote>\n</blockquote>\n<pre>bar</pre>\n"
+    @parser.parse("> foo\n bar").should == "<blockquote>\n  <p>foo</p>\n</blockquote>\n<pre>bar</pre>\n"
+    expected = <<-END
+<blockquote>
+  <blockquote>
+    <p>foo</p>
+  </blockquote>
+</blockquote>
+<pre>bar</pre>
+END
     @parser.parse("> > foo\n bar").should == expected
   end