Closed ivanspasov99 closed 2 years ago
Can't reproduce with mmark (which uses this library, but might be still different):
% ./mmark -html -fragment x.md
<h2 id="resources">Resources</h2>
<ul>
<li><a href="[URL](https://host.host.host.host/design/format/)"><strong>Guidelines:</strong> Formatting Time</a></li>
</ul>
I have found how it is reproduced. It is partially connected with our own custom RenderNodeFunction.
Github supports empty links. If you try to render [link]() it won't be recognise as a link from the library.
But we are having partial node update, we are assigning a specific node.Destination
(in the this case with the empty link, we are making node.Destination = ""
), then leaving the library to write it to the buffer and it makes the markdown panic index out of range [0] with length 0
.
So I guess the solution is to support such empty links
[ Quoting @.***> in "Re: [gomarkdown/markdown] Markdown ..." ]
Github supports empty links. If you try to render link it won't be recognise as a link from the library.
What's an empty link? Something like [url]() ? Is that in common mark?
found it, this is indeed a bit jarring:
[hello](http://bla)
[](http://bla)
the latter renders as: <p>[](<a href="http://bla">http://bla</a>)</p>
, CommonMark seems to render to <p><a href="http://bla"></a></p>
https://github.com/gomarkdown/markdown/pull/258
makes [](bla)
work, won't fix your panic I think, you probably need to catch that in your RenderNode hook.
By empty link I mean one without reference. Example [link]()
If I have markdown as follows:
When
ToHTML
is executed the application panics.