This Space for Rent

New (beta) Code!

Discount has been shoved up to version 2.0.4beta3 with a small collection of bug fixes (most of the bugs were reported by (and most of the chrome was suggested by) Gustavo Lopes as fallout from a project he’s working on that uses a shared library version of discount) and a new feature (code, which I brutally extended to provide MacOS support, provided by David Banks) in the form of shared library support (which I am now using here on gehenna and on my MacOS box.)

There are a bunch of bugfixes here:

  1. In mkd_css(), don’t check that *res is non-null.
  2. if definition lists are turned off, note that in version.c
  3. unclosed html & style blocks now revert to being plain old markdown instead of being accepted as unclosed blocks of html or style.
  4. Add a mkd_shlib_destructor function so people who use it as a run-time load(and unload)able shared library can clean up the dynamically allocated html tag list before unloading the library.
  5. repair markdown extra-style dl handling so that skipped blank lines are garbage collected.
  6. Flip the order of arguments to fwrite() inside mkd_generatecss(); it was size, 1 (write 1 element size bytes long; fwrite will return 1 or 0) and it should be 1, size so I can get back the number of bytes actually written.

And some chrome:

  1. Add prototypes for mkd_initialize(), mkd_shlib_destructor(), and mkd_deallocate_tags() to make gcc stfu.
  2. null terminate the buffers generated by mkd_css(), mkd_toc(), and mkd_line() (in the same fashion as elsewhere; the null termination is allocated, but the returned size doesn’t count it. This way a fwrite() writes out the proper number of characters, but a naive fputs() won’t charge off into terra incognito.)
  3. Be more picky about what comes before a superscript “^”; alphanumerics plus “)” are good, other nonspace characters are not.

The single feature is that shared libraries (MacOS, FreeBSD, and Linux only) are now supported through the --shared flag to It’s a fairly rough implementation – I don’t support versioned shared libraries on FreeBSD or Linux, and only support it via a fairly horrible hack on MacOS – but it does actually work and it allows you to (if you wish) enter the modern world of Unixy DLL hell.

So why not try it? It’s really new, and you can be on the bleeding edge of watching your programs explore the frontiers of software development from the comfort of the edge of your seat.