Loading lib/jsduck/doc_formatter.rb +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,10 @@ module JsDuck # To prevent this, we always add extra newline before <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") replace(RDiscount.new(input).to_html) end Loading spec/doc_formatter_spec.rb +33 −4 Original line number Diff line number Diff line Loading @@ -46,15 +46,44 @@ describe JsDuck::DocFormatter do @formatter.format("Hello **world**").should =~ /Hello <strong>world<\/strong>/ end describe "<pre>" do before do @html = @formatter.format(<<-EOS) Some code<pre> if (condition) { doSomething(); } </pre> EOS end it "does not create nested <pre> segments" do html = @formatter.format(" @html.should_not =~ /<pre>.*<pre>/m end it "avoids newline after <pre>" do @html.should_not =~ /<pre>\n/m end end describe "<pre><code>" do before do @html = @formatter.format(<<-EOS) Some code<pre><code> if (condition) { doSomething(); } </code></pre> ") html.should_not =~ /<pre>.*<pre>/m EOS end it "does not create nested <pre><code> segments" do @html.should_not =~ /<pre><code>.*<pre><code>/m end it "avoids newline after <pre><code>" do @html.should_not =~ /<pre><code>\n/m end end end Loading Loading
lib/jsduck/doc_formatter.rb +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,10 @@ module JsDuck # To prevent this, we always add extra newline before <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") replace(RDiscount.new(input).to_html) end Loading
spec/doc_formatter_spec.rb +33 −4 Original line number Diff line number Diff line Loading @@ -46,15 +46,44 @@ describe JsDuck::DocFormatter do @formatter.format("Hello **world**").should =~ /Hello <strong>world<\/strong>/ end describe "<pre>" do before do @html = @formatter.format(<<-EOS) Some code<pre> if (condition) { doSomething(); } </pre> EOS end it "does not create nested <pre> segments" do html = @formatter.format(" @html.should_not =~ /<pre>.*<pre>/m end it "avoids newline after <pre>" do @html.should_not =~ /<pre>\n/m end end describe "<pre><code>" do before do @html = @formatter.format(<<-EOS) Some code<pre><code> if (condition) { doSomething(); } </code></pre> ") html.should_not =~ /<pre>.*<pre>/m EOS end it "does not create nested <pre><code> segments" do @html.should_not =~ /<pre><code>.*<pre><code>/m end it "avoids newline after <pre><code>" do @html.should_not =~ /<pre><code>\n/m end end end Loading