This Space for Rent

New Code!

Discount, after a loooong period of bug attraction through beta releases, has finally been pushed up to version 2.0.4 with a large collection of bugfixes and tweaks, and a somewhat smaller collection of new features. The new features are possibly the most interesting things here; one of them is support for building libmarkdown as a shared library on MacOS, Linux, and FreeBSD (the first and the last are tested by me, the middle is tested by David Banks, who contributed the makefile patches that I subsequently hacked into the current shared library support,) and the other is support for php markdown extra-style definition lists, which are just as hideous as discount-style definition lists, but which are supported by more markdown implementations than mine are.

The minor tweaks are to handle edge cases in the language – there are some edge cases that I handled differently from the reference implementation, and I was mishandling unterminated <style>/html blocks (I handled them as blocks without a closing element, which is wrong) – and to clean up the return values from some of the function calls that allocate buffers.

The full list of changes is listed below:

  1. add shared library support
  2. correct some typos
  3. Add manpages for the example programs makepage(1) and mkd2html(1)
  4. Initialize the random number generator and tag list separately, just in case someone really wants to do multiple initialize/deallocate cycles.
  5. Add a library destructor function (mkd_shlib_destructor()) to discard the kw array before unloading a shared library.
  6. Put in a bunch of useless code to make gcc STFU.
  7. Be more picky about what comes before a ^ if we’re superscripting
  8. Unclosed html/style blocks revert to being regular old markup. True, the markup will contain the opening tag (and most of the other html from that block) but it will be regular old markup with additional garbage added in.
  9. Null-terminate the strings generated by mkd_line(), mkd_css() and mkd_toc().
  10. Flip the order of arguments to mkd_generatecss(); should be 1,size, not size,1
  11. It turns out that non-toplevel paragraphs consume adjacent code blocks :-(
  12. Rework (again) indentation inside list items. Indent should never be > 4 for enumerated lists; this means that I have to test and cut back large indents and change my test cases to account for leading whitespace on deeply (2 spaces + enumerated marker + 1 space) indented items.
  13. Add a raft of testcases to cover the new features + bugfixes.
  14. Add markdown extra style definition list support
    • Add a configuration flag (--with-dl={discount|extra|both}) to select which way to do definition lists. Put a DL= into version.c so the user can see how this (compile time because it’s a beta) is configured.
    • If dl is turned off at compile time, mark it off in version.c

There are a few edge cases left untouched (I discovered a defect in the way I do regular footnote links, which will require some code cleanup to repair in a less-kludgy-than-normal way) and some users have requested php markdown extra-style footnote support and I’ve mocked up an implementation that I’m thinking about adding, but neither of those are going to emerge anytime soon. So if it’s New Code! you’re looking for, this is the one that you want to try out.