Fix parsing of regular links enclosed in []
This commit is contained in:
parent
905648c34b
commit
fb837e04af
4 changed files with 10 additions and 3 deletions
|
@ -197,7 +197,7 @@ func (d *Document) parseAutoLink(input string, start int) (int, int, Node) {
|
|||
}
|
||||
|
||||
func (d *Document) parseRegularLink(input string, start int) (int, Node) {
|
||||
if len(input[start:]) == 0 || input[start+1] != '[' {
|
||||
if len(input[start:]) < 2 || input[start+1] != '[' || input[start+2] == '[' {
|
||||
return 0, nil
|
||||
}
|
||||
input = input[start:]
|
||||
|
|
5
org/testdata/inline.html
vendored
5
org/testdata/inline.html
vendored
|
@ -101,6 +101,11 @@ regular link to https (image) <img src="https://placekitten.com/200/200#.png" al
|
|||
</li>
|
||||
<li>
|
||||
<p>
|
||||
regular link enclosed in [] [<a href="https://www.example.com">https://www.example.com</a>] [<a href="https://www.example.com">example.com</a>]
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
auto link, i.e. not inside <code class="verbatim">\[[square brackets]\]</code> <a href="https://www.example.com">https://www.example.com</a>
|
||||
</p>
|
||||
</li>
|
||||
|
|
3
org/testdata/inline.org
vendored
3
org/testdata/inline.org
vendored
|
@ -25,4 +25,5 @@
|
|||
4. regular link to a file (video) [[my-video.mp4]]
|
||||
5. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
6. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
7. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
7. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
8. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
|
|
3
org/testdata/inline.pretty_org
vendored
3
org/testdata/inline.pretty_org
vendored
|
@ -25,4 +25,5 @@
|
|||
4. regular link to a file (video) [[my-video.mp4]]
|
||||
5. regular link to http (image) [[http://placekitten.com/200/200#.png]]
|
||||
6. regular link to https (image) [[https://placekitten.com/200/200#.png]]
|
||||
7. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
7. regular link enclosed in [] [[[https://www.example.com]]] [[[https://www.example.com][example.com]]]
|
||||
8. auto link, i.e. not inside =\[[square brackets]\]= https://www.example.com
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue