mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fix #235
This commit is contained in:
parent
b2c88c80f6
commit
4477be72ee
2 changed files with 28 additions and 3 deletions
|
|
@ -171,9 +171,23 @@ http://server.intranet.acme.com:1313
|
||||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
|
||||||
17
|
18
|
||||||
//- - - - - - - - -//
|
//- - - - - - - - -//
|
||||||
https://g.page/foo
|
https://g.page/foo
|
||||||
//- - - - - - - - -//
|
//- - - - - - - - -//
|
||||||
<p><a href="https://g.page/foo">https://g.page/foo</a></p>
|
<p><a href="https://g.page/foo">https://g.page/foo</a></p>
|
||||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
|
||||||
|
19: Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink
|
||||||
|
//- - - - - - - - -//
|
||||||
|
__http://test.com/~/a__
|
||||||
|
__http://test.com/~/__
|
||||||
|
__http://test.com/~__
|
||||||
|
__http://test.com/a/~__
|
||||||
|
//- - - - - - - - -//
|
||||||
|
<p><strong><a href="http://test.com/~/a">http://test.com/~/a</a></strong>
|
||||||
|
<strong><a href="http://test.com/~/">http://test.com/~/</a></strong>
|
||||||
|
<strong><a href="http://test.com/">http://test.com/</a>~</strong>
|
||||||
|
<strong><a href="http://test.com/a/">http://test.com/a/</a>~</strong></p>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
|
||||||
|
|
@ -273,9 +273,20 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
|
||||||
s := segment.WithStop(segment.Start + 1)
|
s := segment.WithStop(segment.Start + 1)
|
||||||
ast.MergeOrAppendTextSegment(parent, s)
|
ast.MergeOrAppendTextSegment(parent, s)
|
||||||
}
|
}
|
||||||
consumes += m[1]
|
i := m[1] - 1
|
||||||
|
for ; i > 0; i-- {
|
||||||
|
c := line[i]
|
||||||
|
switch c {
|
||||||
|
case '?', '!', '.', ',', ':', '*', '_', '~':
|
||||||
|
default:
|
||||||
|
goto endfor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endfor:
|
||||||
|
i++
|
||||||
|
consumes += i
|
||||||
block.Advance(consumes)
|
block.Advance(consumes)
|
||||||
n := ast.NewTextSegment(text.NewSegment(start, start+m[1]))
|
n := ast.NewTextSegment(text.NewSegment(start, start+i))
|
||||||
link := ast.NewAutoLink(typ, n)
|
link := ast.NewAutoLink(typ, n)
|
||||||
link.Protocol = protocol
|
link.Protocol = protocol
|
||||||
return link
|
return link
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue