Add escaping to ~ and ^, and disable autolinking inside of link bodies.
Note that the fix for autolinking is different than the one in Snudown;
I didn't want to touch the callbacks table.
"An unordered list followed by an ordered list (separated by double
linebreake) yields only an unordered list with a set of paragraphs
inside it."
Original patch by Igor Bochkariov, backported from Redcarpet.
Previously, block tags like <div>foo</div> were being properly detected,
but tags with attributes such as <div class="blank">foo</div> were
inproperly discarded.
URL escaping fully escapes all URL components to allow embedding an URL
inside of another. URI escaping is what we need to build the links for
<a> tags!
I don't understand what was that check doing there, but it makes no
sense. Emphasis parsing is non-greedy, so it should always close on the
nearest match.
This was the next logical step on the interface revamp for 2.0.
The old API was doing very fishy stuff with allocation: the `rndr`
struct was being called once for every `sd_markdown` call, and the
amount stack space filled with it was just inappropriate (256 bytes
just from the char table and 300 more from pointers in the callback
table).
By creating the renderer on the heap and reusing it, we save a lot of
time on initialization code, at the expense of not being able to
change the enabled extensions on each parse (something which is not
that common anyway).
This will make wrapping Sundown in higher level languages more direct,
given that every other language has OO design, which maps better to
the concept of a reusable renderer.
The old array was not quite optimal, and was not used optimally either.
- The `struct array` that was used for accessing link references has
been replaced with a minimal, fixed-width hash table. This should
be much more straightforward for small documents.
- The `struct parray` used as a string pool has been replaced with
a fast-growing stack. Realloc'ing once per push has never been a
good idea anyway.
Yey for losing boilerplate!