Commit 4a40c4c3 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix support for multiline @links.

parent 2b9ba16b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ module JsDuck
    # attribute links will also contain ext:cls and ext:member
    # attributes.
    def replace(input)
      input.gsub(/\{@link +(\S*?)(?: +(.+?))?\}/) do
      input.gsub(/\{@link\s+(\S*?)(?:\s+(.+?))?\}/m) do
        target = $1
        text = $2
        if target =~ /^(.*)#(.*)$/
+10 −0
Original line number Diff line number Diff line
@@ -38,6 +38,16 @@ describe JsDuck::DocFormatter do
      @formatter.replace("unfinished {@link tag here").should ==
        'unfinished {@link tag here'
    end

    it "handles {@link} spanning multiple lines" do
      @formatter.replace("Look at {@link\nExt.Msg\nsome text}").should ==
        'Look at <a href="Ext.Msg" rel="Ext.Msg">some text</a>'
    end

    it "handles {@link} with label spanning multiple lines" do
      @formatter.replace("Look at {@link Ext.Msg some\ntext}").should ==
        "Look at <a href=\"Ext.Msg\" rel=\"Ext.Msg\">some\ntext</a>"
    end
  end

  describe "#format" do