New Code!
Discount has been rolled up to version 1.3.4 with the addition of a couple of bits of new code;
First, I’ve modified the table-of-contents handing so that there’s a new function (
int mkd_toc(Document*,char**)
) which gives you back amalloc()
ed string containing the compiled html for the table of contents (mkd_toc()
returns the # of bytes allocated, 0 if there’s no toc, andEOF
on error.) This is a first step of a planned rework that will arrange things so that every core function that prints to aFILE*
will have a corresponding function that will populate a string for you.Secondly, I just recently became aware that there’s a newer version of the standard Markdown test suite (fallout from the recent Solaris port; the rdiscount gem had a
rake
task which mentioned a 1.0.3 conformance test, which I then found by the traditional method of using a search engine) which isn’t quite compatable with the old 1.0 test suite, and which discount failed on three of the tests.One of the tests was the old bugaboo of “preserve trailing whitespace except on the first line of a codeblock” which was changed to the correct behavior of “preserve trailing whitespace always”, but the other two were a new (and undocumented, except in the test suite) style of implicit reference link that doesn’t have the second set of
[]
on it. So now, a reference link like[foo]
expands to<a href="what foo is">foo</a>
instead of simply being a parenthetical comment with square brackets (or an array index. Whatever works for you.)Supporting this new behavior was a matter of maybe 20 minutes of work, but I also added test suites for it as well as a
mkdio.h
flag (MKD_1_COMPAT
, 0x2000, or-f1.0
for the markdown command line program) to make discount revert back to the oldMarkdownTest_1.0
compatable behavior – and that was enough for one day’s work.
This code should be pretty safe. Yes, it does add new code paths (particularly the table-of-contents code around mkd_toc()
, which I have not tested as thoroughly as the other code (annotations doesn’t use it, nor does the copy of theme that’s embedded in the discount distribution) but it’s not very much new code and the tentacles have been lopped off once already so you should be okay with them. So it’s the ideal candidate for New Code! which you should grab, install, and use starting right about now.
I’ll be over here in the bomb shelter, waiting to hear the bug reports going off (and one already went off! I managed to break the “two trailing spaces becomes a <br/>
” rule. Fixed, and that makes the code version 1.3.4.)