Commit 6425fc93 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix regex for detecting indented code.

For some reason I had always thought \Z is the end of string in Ruby,
but it turns out \z is actually the end of string while \Z will match
right before a newline at the end of string if there happens to be one.

This little difference caused quite an unexpected behavior in one corner
case where the code example is on just a line before the @tag.
parent 321539ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ module JsDuck
    end

    def indented_as_code?
      @current_tag[:doc] =~ /^ {4,}[^\n]*\Z/
      @current_tag[:doc] =~ /^ {4,}[^\n]*\z/
    end

    # Processes anything else beginning with @-sign.
+14 −0
Original line number Diff line number Diff line
@@ -196,4 +196,18 @@ describe JsDuck::DocParser do
    end
  end

  describe "indented code on previous line" do
    before do
      @params = parse_single(<<-EOS.strip).find_all {|t| t[:tagname] == :param }
         * @param x
         *     Foo
         *     Bar
         * @param y
      EOS
    end
    it "doesn't cause the tag to be skipped" do
      @params.length.should == 2
    end
  end

end