Loading lib/jsduck/doc_formatter.rb +2 −2 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ module JsDuck # normal Markdown, which often causes nested <pre>-blocks. # # To prevent this, we always add extra newline before <pre>. input.gsub!(/([^\n])<pre>/, "\1\n<pre>") input.gsub!(/([^\n])<pre>/, "\\1\n<pre>") # But we remove trailing newline after <pre> to prevent # code-blocks beginning with empty line. input.gsub!(/<pre>(<code>)?\n?/, "<pre>\1") input.gsub!(/<pre>(<code>)?\n?/, "<pre>\\1") replace(RDiscount.new(input).to_html) end Loading spec/doc_formatter_spec.rb +17 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,20 @@ describe JsDuck::DocFormatter do @formatter.format("Hello **world**").should =~ /Hello <strong>world<\/strong>/ end shared_examples_for "code blocks" do it "contains text before" do @html.should =~ /Some code/ end it "contains the code" do @html.include?("if (condition) {\n doSomething();\n}").should == true end it "does not create nested <pre> segments" do @html.should_not =~ /<pre>.*<pre>/m end end describe "<pre>" do before do @html = @formatter.format(<<-EOS) Loading @@ -57,9 +71,7 @@ if (condition) { EOS end it "does not create nested <pre> segments" do @html.should_not =~ /<pre>.*<pre>/m end it_should_behave_like "code blocks" it "avoids newline after <pre>" do @html.should_not =~ /<pre>\n/m Loading @@ -77,14 +89,13 @@ if (condition) { EOS end it "does not create nested <pre><code> segments" do @html.should_not =~ /<pre><code>.*<pre><code>/m end it_should_behave_like "code blocks" it "avoids newline after <pre><code>" do @html.should_not =~ /<pre><code>\n/m end end end end Loading
lib/jsduck/doc_formatter.rb +2 −2 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ module JsDuck # normal Markdown, which often causes nested <pre>-blocks. # # To prevent this, we always add extra newline before <pre>. input.gsub!(/([^\n])<pre>/, "\1\n<pre>") input.gsub!(/([^\n])<pre>/, "\\1\n<pre>") # But we remove trailing newline after <pre> to prevent # code-blocks beginning with empty line. input.gsub!(/<pre>(<code>)?\n?/, "<pre>\1") input.gsub!(/<pre>(<code>)?\n?/, "<pre>\\1") replace(RDiscount.new(input).to_html) end Loading
spec/doc_formatter_spec.rb +17 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,20 @@ describe JsDuck::DocFormatter do @formatter.format("Hello **world**").should =~ /Hello <strong>world<\/strong>/ end shared_examples_for "code blocks" do it "contains text before" do @html.should =~ /Some code/ end it "contains the code" do @html.include?("if (condition) {\n doSomething();\n}").should == true end it "does not create nested <pre> segments" do @html.should_not =~ /<pre>.*<pre>/m end end describe "<pre>" do before do @html = @formatter.format(<<-EOS) Loading @@ -57,9 +71,7 @@ if (condition) { EOS end it "does not create nested <pre> segments" do @html.should_not =~ /<pre>.*<pre>/m end it_should_behave_like "code blocks" it "avoids newline after <pre>" do @html.should_not =~ /<pre>\n/m Loading @@ -77,14 +89,13 @@ if (condition) { EOS end it "does not create nested <pre><code> segments" do @html.should_not =~ /<pre><code>.*<pre><code>/m end it_should_behave_like "code blocks" it "avoids newline after <pre><code>" do @html.should_not =~ /<pre><code>\n/m end end end end