@@ -734,56 +734,19 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
734734 }
735735 break ;
736736 case ')' :
737+ if (peekChar () == '\n' || peekChar () == ' ' ) {
738+ valid = parseMarkdownLinkTags (true , start , previousPosition , tStart , tEnd );
739+ break loop ;
740+ }
741+ break ;
737742 case ']' :
738743 if ((peekChar () == '[' ) || peekChar () == '(' ) {
739744 tStart = start ;
740745 tEnd = this .index - 1 ;
741746 currentChar = readChar ();
742747 start = this .index ;
743748 } else if (peekChar () != ']' ) {
744- int eofBkup = this .scanner .eofPosition ;
745- this .scanner .eofPosition = this .index - 1 ;
746- this .scanner .resetTo (start , this .javadocEnd );
747- this .inlineTagStarted = true ;
748- this .inlineTagStart = previousPosition ;
749- this .tagValue = TAG_LINK_VALUE ;
750- int indexBkup = this .index ;
751- if (currentChar != ']' )
752- valid = parseURLReference ();
753- else
754- valid = parseReference (true );
755- this .index = indexBkup ;
756- // This creates a two level structure. The @link tag is added to
757- // another tag element, which gets added to the astStack
758- // Both tag elements must get the same source range.
759- TagElement previousTag = (TagElement ) this .astStack [this .astPtr ];
760- int parentStart = previousTag .getStartPosition ();
761- previousTag .setSourceRange (parentStart , this .index - parentStart );
762- List fragments = previousTag .fragments ();
763- int size = fragments .size ();
764- if (size == 0 ) {
765- // no existing fragment => just add the element
766- TagElement inlineTag = this .ast .newTagElement ();
767- fragments .add (inlineTag );
768- previousTag = inlineTag ;
769- } else {
770- // If last fragment is a tag, then use it as previous tag
771- ASTNode lastFragment = (ASTNode ) fragments .get (size -1 );
772- if (lastFragment .getNodeType () == ASTNode .TAG_ELEMENT ) {
773- lastFragment .setSourceRange (lastFragment .getStartPosition (), this .index - previousPosition );
774- previousTag = (TagElement ) lastFragment ;
775- }
776- }
777- if (tEnd != -1 ) {
778- TextElement text = this .ast .newTextElement ();
779- text .setText (new String ( this .source , tStart , tEnd -tStart ));
780- text .setSourceRange (tStart , tEnd -tStart );
781- previousTag .fragments ().add (0 , text );
782- }
783- this .tagValue = NO_TAG_VALUE ;
784- this .inlineTagStarted = false ;
785- this .inlineTagStart = -1 ;
786- this .scanner .eofPosition = eofBkup ;
749+ valid = parseMarkdownLinkTags (false , start , previousPosition , tStart , tEnd );
787750 break loop ;
788751 }
789752 break ;
@@ -799,6 +762,54 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
799762 return valid ;
800763 }
801764
765+ private boolean parseMarkdownLinkTags (boolean refFlag , int start , int previousPosition , int tStart , int tEnd ) throws InvalidInputException {
766+ boolean valid = false ;
767+ int eofBkup = this .scanner .eofPosition ;
768+ this .scanner .eofPosition = this .index - 1 ;
769+ this .scanner .resetTo (start , this .javadocEnd );
770+ this .inlineTagStarted = true ;
771+ this .inlineTagStart = previousPosition ;
772+ this .tagValue = TAG_LINK_VALUE ;
773+ int indexBkup = this .index ;
774+ if (refFlag )
775+ valid = parseURLReference ();
776+ else
777+ valid = parseReference (true );
778+ this .index = indexBkup ;
779+ // This creates a two level structure. The @link tag is added to
780+ // another tag element, which gets added to the astStack
781+ // Both tag elements must get the same source range.
782+ TagElement previousTag = (TagElement ) this .astStack [this .astPtr ];
783+ int parentStart = previousTag .getStartPosition ();
784+ previousTag .setSourceRange (parentStart , this .index - parentStart );
785+ List fragments = previousTag .fragments ();
786+ int size = fragments .size ();
787+ if (size == 0 ) {
788+ // no existing fragment => just add the element
789+ TagElement inlineTag = this .ast .newTagElement ();
790+ fragments .add (inlineTag );
791+ previousTag = inlineTag ;
792+ } else {
793+ // If last fragment is a tag, then use it as previous tag
794+ ASTNode lastFragment = (ASTNode ) fragments .get (size -1 );
795+ if (lastFragment .getNodeType () == ASTNode .TAG_ELEMENT ) {
796+ lastFragment .setSourceRange (lastFragment .getStartPosition (), this .index - previousPosition );
797+ previousTag = (TagElement ) lastFragment ;
798+ }
799+ }
800+ if (tEnd != -1 ) {
801+ TextElement text = this .ast .newTextElement ();
802+ text .setText (new String ( this .source , tStart , tEnd -tStart ));
803+ text .setSourceRange (tStart , tEnd -tStart );
804+ previousTag .fragments ().add (0 , text );
805+ }
806+ this .tagValue = NO_TAG_VALUE ;
807+ this .inlineTagStarted = false ;
808+ this .inlineTagStart = -1 ;
809+ this .scanner .eofPosition = eofBkup ;
810+ return valid ;
811+ }
812+
802813 @ Override
803814 protected boolean parseTag (int previousPosition ) throws InvalidInputException {
804815 this .markdownHelper .resetLineStart ();
0 commit comments